public AppUsageObserver( int observerId, @NonNull Collection<String> packageNames, long timeLimit, @NonNull TimeUnit timeUnit, @NonNull PendingIntent callbackIntent) { this.observerId = observerId; this.packageNames = packageNames; this.timeLimit = timeLimit; this.timeUnit = timeUnit; this.callbackIntent = callbackIntent; }
@NonNull public PendingIntent getCallbackIntent() { return callbackIntent; }
@NonNull public TimeUnit getTimeUnit() { return timeUnit; }
@NonNull public Collection<String> getPackageNames() { return packageNames; }
@Implementation protected static @NonNull ApkAssets loadOverlayFromPath(@NonNull String idmapPath, boolean system) throws IOException { throw new UnsupportedOperationException(); // return getFromCacheOrLoad( // new Key(fd, friendlyName, system, forceSharedLibrary, false), // () -> directlyOn(ApkAssets.class, "loadFromPath", // ClassParameter.from(FileDescriptor.class, fd), // ClassParameter.from(String.class, friendlyName), // ClassParameter.from(boolean.class, system), // ClassParameter.from(boolean.class, forceSharedLibrary))); }
/** * Adds the given cameraId and characteristics to this shadow. * * <p>The result from {@link #getCameraIdList()} will be in the order in which cameras were added. * * @throws IllegalArgumentException if there's already an existing camera with the given id. */ public void addCamera(@NonNull String cameraId, @NonNull CameraCharacteristics characteristics) { Preconditions.checkNotNull(cameraId); Preconditions.checkNotNull(characteristics); Preconditions.checkArgument(!cameraIdToCharacteristics.containsKey(cameraId)); cameraIdToCharacteristics.put(cameraId, characteristics); } }
@Implementation @NonNull protected CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId) { Preconditions.checkNotNull(cameraId); CameraCharacteristics characteristics = cameraIdToCharacteristics.get(cameraId); Preconditions.checkArgument(characteristics != null); return characteristics; }
/** Returns an incremented track id for the associated muxer. */ @Implementation protected static int nativeAddTrack( long nativeObject, @NonNull String[] keys, @NonNull Object[] values) { AtomicInteger nextTrackIndex = nextTrackIndices.get(nativeObject); if (nextTrackIndex == null) { throw new IllegalStateException("No next track index configured for key: " + nativeObject); } return nextTrackIndex.getAndIncrement(); }
@Implementation @NonNull protected OutputStream openWrite(@NonNull String name, long offsetBytes, long lengthBytes) throws IOException { outputStream = new OutputStream() { @Override public void write(int aByte) throws IOException { } @Override public void close() throws IOException { outputStreamOpen = false; } }; outputStreamOpen = true; return outputStream; }
@Implementation @NonNull protected String[] getCameraIdList() throws CameraAccessException { Set<String> cameraIds = cameraIdToCharacteristics.keySet(); return cameraIds.toArray(new String[0]); }
@Implementation(minSdk = KITKAT) @NonNull protected List<UriPermission> getPersistedUriPermissions() { return uriPermissions; }
@Implementation(minSdk = N) protected @NonNull String getSharedSystemSharedLibraryPackageName() { return ""; }
@Implementation(minSdk = M) protected @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes() { return null; }
@Implementation(minSdk = N) protected @NonNull String getServicesSystemSharedLibraryPackageName() { return null; }
/** * Generates and returns an internal id to track the FileOutputStream corresponding to individual * MediaMuxer instances. */ @Implementation protected static long nativeSetup(@NonNull FileDescriptor fd, int format) throws IOException { FileOutputStream outputStream = fdToStream.get(fd); long potentialKey; do { potentialKey = random.nextLong(); } while (potentialKey == 0 || outputStreams.putIfAbsent(potentialKey, outputStream) != null); nextTrackIndices.put(potentialKey, new AtomicInteger(0)); return potentialKey; }
@Implementation protected void fsync(@NonNull OutputStream out) throws IOException {}
/** * Grants a particular device policy for an active ComponentName. * * @param admin the ComponentName which DeviceAdminReceiver this request is associated with. Must * be an active administrator, or an exception will be thrown. This value must never be null. * @param usesPolicy the uses-policy to check */ public void grantPolicy(@NonNull ComponentName admin, int usesPolicy) { enforceActiveAdmin(admin); Set<Integer> policyGrantedSet = adminPolicyGrantedMap.get(admin); if (policyGrantedSet == null) { policyGrantedSet = new HashSet<>(); policyGrantedSet.add(usesPolicy); adminPolicyGrantedMap.put(admin, policyGrantedSet); } else { policyGrantedSet.add(usesPolicy); } } }
@Implementation protected boolean hasGrantedPolicy(@NonNull ComponentName admin, int usesPolicy) { enforceActiveAdmin(admin); Set<Integer> policyGrantedSet = adminPolicyGrantedMap.get(admin); return policyGrantedSet != null && policyGrantedSet.contains(usesPolicy); }
@Implementation protected void commit(@NonNull IntentSender statusReceiver) { this.statusReceiver = statusReceiver; if (outputStreamOpen) { throw new SecurityException("OutputStream still open"); } shadowPackageInstaller.setSessionSucceeds(sessionId); }