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; }
@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))); }
@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 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 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); }
@Implementation @NonNull protected PackageInstaller.Session openSession(int sessionId) throws IOException { if (!sessionInfos.containsKey(sessionId)) { throw new SecurityException("Invalid session Id: " + sessionId); } PackageInstaller.Session session = new PackageInstaller.Session(null); ShadowSession shadowSession = Shadow.extract(session); shadowSession.setShadowPackageInstaller(sessionId, this); sessions.put(sessionId, session); return session; }
@Implementation protected static PendingIntent getActivity( Context context, int requestCode, @NonNull Intent intent, int flags) { return create(context, new Intent[] {intent}, Type.ACTIVITY, requestCode, flags); }
@Implementation protected static PendingIntent getActivity( Context context, int requestCode, @NonNull Intent intent, int flags, Bundle options) { return create(context, new Intent[] {intent}, Type.ACTIVITY, requestCode, flags); }
@Implementation(minSdk = 19) protected void removeCaptioningChangeListener(@NonNull CaptioningChangeListener listener) { listeners.remove(listener); } }
@Implementation(minSdk = O) protected static PendingIntent getForegroundService( Context context, int requestCode, @NonNull Intent intent, int flags) { return create(context, new Intent[] {intent}, Type.FOREGROUND_SERVICE, requestCode, flags); }
@Implementation protected static PendingIntent getActivities( Context context, int requestCode, @NonNull Intent[] intents, int flags) { return create(context, intents, Type.ACTIVITY, requestCode, flags); }
@Implementation protected static PendingIntent getBroadcast( Context context, int requestCode, @NonNull Intent intent, int flags) { return create(context, new Intent[] {intent}, Type.BROADCAST, requestCode, flags); }
@Implementation protected static PendingIntent getService( Context context, int requestCode, @NonNull Intent intent, int flags) { return create(context, new Intent[] {intent}, Type.SERVICE, requestCode, flags); }
@Implementation protected Resources getResourcesForApplication(@NonNull ApplicationInfo applicationInfo) throws PackageManager.NameNotFoundException { return getResourcesForApplication(applicationInfo.packageName); }
private void addUriPermission(@NonNull Uri uri, int modeFlags) { UriPermission perm = ReflectionHelpers.callConstructor( UriPermission.class, ClassParameter.from(Uri.class, uri), ClassParameter.from(int.class, modeFlags), ClassParameter.from(long.class, System.currentTimeMillis())); uriPermissions.add(perm); }
@Implementation protected static @NonNull ApkAssets loadFromPath(@NonNull String path, boolean system, boolean forceSharedLibrary) throws IOException { return getFromCacheOrLoad( new Key(null, path, system, forceSharedLibrary, false), () -> directlyOn(ApkAssets.class, "loadFromPath", ClassParameter.from(String.class, path), ClassParameter.from(boolean.class, system), ClassParameter.from(boolean.class, forceSharedLibrary))); }