@Implementation @Nullable protected <T> T get(Key<T> key) { return (T) charactersKeyToValue.get(key); }
@Implementation @Nullable protected PackageInstaller.SessionInfo getSessionInfo(int sessionId) { return sessionInfos.get(sessionId); }
@Implementation protected @Nullable String getNameForUid(int uid) { return namesForUid.get(uid); }
@Implementation(minSdk = M) protected @Nullable Object getPrimaryStorageCurrentVolume() { return null; }
/** Prevents calling Android-only methods on basic ByteBuffer objects. */ @Implementation(minSdk = LOLLIPOP) protected void invalidateByteBuffer(@Nullable ByteBuffer[] buffers, int index) {}
/** Prevents attempting to free non-direct ByteBuffer objects. */ @Implementation(minSdk = LOLLIPOP) protected void freeByteBuffer(@Nullable ByteBuffer buffer) {}
/** Prevents calling Android-only methods on basic ByteBuffer objects. */ @Implementation(minSdk = LOLLIPOP) protected void validateInputByteBuffer(@Nullable ByteBuffer[] buffers, int index) {}
/** Prevents calling Android-only methods on basic ByteBuffer objects. */ @Implementation(minSdk = LOLLIPOP) protected void revalidateByteBuffer(@Nullable ByteBuffer[] buffers, int index) {}
/** Prevents calling Android-only methods on basic ByteBuffer objects. */ @Implementation(minSdk = LOLLIPOP) protected void invalidateByteBuffers(@Nullable ByteBuffer[] buffers) {}
@Implementation protected @Nullable String[] getPackagesForUid(int uid) { String[] packageNames = packagesForUid.get(uid); if (packageNames != null) { return packageNames; } Set<String> results = new HashSet<>(); for (PackageInfo packageInfo : packageInfos.values()) { if (packageInfo.applicationInfo != null && packageInfo.applicationInfo.uid == uid) { results.add(packageInfo.packageName); } } return results.isEmpty() ? null : results.toArray(new String[results.size()]); }
@Nullable @Implementation protected Drawable getDrawable( String packageName, @DrawableRes int resId, @Nullable ApplicationInfo appInfo) { Drawable result = drawables.get(new Pair<>(packageName, resId)); if (result != null) { return result; } return Shadow.directlyOn(realObject, ApplicationPackageManager.class) .getDrawable(packageName, resId, appInfo); }
@Nullable public ModeAndException getRestriction(int code, @AttributeUsage int usage) { // this gives us room for 256 op_codes. There are 78 as of P. return audioRestrictions.get(getAudioRestrictionKey(code, usage)); }
/** * Prevents calling Android-only methods on basic ByteBuffer objects. Replicates existing behavior * adjusting buffer positions and limits. */ @Implementation(minSdk = LOLLIPOP) protected void validateOutputByteBuffer( @Nullable ByteBuffer[] buffers, int index, @NonNull BufferInfo info) { if (buffers != null && index >= 0 && index < buffers.length) { ByteBuffer buffer = buffers[index]; if (buffer != null) { buffer.limit(info.offset + info.size).position(info.offset); } } }
@Implementation(minSdk = LOLLIPOP) @Nullable protected List<String> getPermittedInputMethods(ComponentName admin) { enforceDeviceOwnerOrProfileOwner(admin); return permittedInputMethods; }
@Implementation(minSdk = LOLLIPOP) @Nullable protected List<String> getPermittedAccessibilityServices(ComponentName admin) { enforceDeviceOwnerOrProfileOwner(admin); return permittedAccessibilityServices; }
/** * Forwards the call to {@link #sendBroadcast(Intent,String)}, disregarding {@code user} param. */ @Implementation(minSdk = JELLY_BEAN_MR1) @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) protected void sendBroadcastAsUser( @RequiresPermission Intent intent, UserHandle user, @Nullable String receiverPermission) { sendBroadcast(intent, receiverPermission); }
private void postFakeNativeEvent(int what, int arg1, int arg2, @Nullable Object obj) { ReflectionHelpers.callInstanceMethod( MediaCodec.class, realCodec, "postEventFromNative", ReflectionHelpers.ClassParameter.from(int.class, what), ReflectionHelpers.ClassParameter.from(int.class, arg1), ReflectionHelpers.ClassParameter.from(int.class, arg2), ReflectionHelpers.ClassParameter.from(Object.class, obj)); }
@Implementation(minSdk = P) protected static @Nullable String nativeGetResourcePackageName(long ptr, @AnyRes int resid) { CppAssetManager2 assetmanager = AssetManagerFromLong(ptr); final ResourceName name = new ResourceName(); if (!assetmanager.GetResourceName(resid, name)) { return null; } if (name.package_ != null) { return name.package_; } return null; }
@Implementation(minSdk = P) protected static @Nullable String nativeGetResourceTypeName(long ptr, @AnyRes int resid) { CppAssetManager2 assetmanager = AssetManagerFromLong(ptr); final ResourceName name = new ResourceName(); if (!assetmanager.GetResourceName(resid, name)) { return null; } if (name.type != null) { return name.type; // } else if (name.get().type16 != null) { // return name.get().type16; // env.NewString(reinterpret_cast<jchar*>(name.type16), name.type_len); } return null; }
@Implementation(minSdk = P) protected static @Nullable String nativeGetResourceEntryName(long ptr, @AnyRes int resid) { CppAssetManager2 assetmanager = AssetManagerFromLong(ptr); final ResourceName name = new ResourceName(); if (!assetmanager.GetResourceName(resid, name)) { return null; } if (name.entry != null) { return name.entry; // } else if (name.entry16 != null) { // return name.entry16; // env.NewString(reinterpret_cast<jchar*>(name.entry16), name.entry_len); } return null; }