Loading core/java/android/app/IWallpaperManager.aidl +9 −1 Original line number Diff line number Diff line Loading @@ -58,13 +58,21 @@ interface IWallpaperManager { @UnsupportedAppUsage void setWallpaperComponent(in ComponentName name); /** * Get the wallpaper for a given user. * @deprecated Use {@link #getWallpaperWithFeature(String, IWallpaperManagerCallback, int, * Bundle, int)} */ @UnsupportedAppUsage ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId); /** * Get the wallpaper for a given user. */ ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId); /** * Retrieve the given user's current wallpaper ID of the given kind. */ Loading core/java/android/app/WallpaperManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -458,8 +458,9 @@ public class WallpaperManager { try { Bundle params = new Bundle(); ParcelFileDescriptor fd = mService.getWallpaper(context.getOpPackageName(), this, FLAG_SYSTEM, params, userId); ParcelFileDescriptor fd = mService.getWallpaperWithFeature( context.getOpPackageName(), context.getFeatureId(), this, FLAG_SYSTEM, params, userId); if (fd != null) { try { BitmapFactory.Options options = new BitmapFactory.Options(); Loading Loading @@ -985,8 +986,8 @@ public class WallpaperManager { } else { try { Bundle outParams = new Bundle(); return sGlobals.mService.getWallpaper(mContext.getOpPackageName(), null, which, outParams, userId); return sGlobals.mService.getWallpaperWithFeature(mContext.getOpPackageName(), mContext.getFeatureId(), null, which, outParams, userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (SecurityException e) { Loading core/java/android/os/storage/StorageManager.java +58 −38 Original line number Diff line number Diff line Loading @@ -1645,10 +1645,10 @@ public class StorageManager { * Check that given app holds both permission and appop. * @hide */ public static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op, true); public static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, @NonNull String featureId, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, featureId, permission, op, true); } /** Loading @@ -1657,16 +1657,17 @@ public class StorageManager { */ public static boolean checkPermissionAndCheckOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op, false); return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, null /* featureId is not needed when not noting */, permission, op, false); } /** * Check that given app holds both permission and appop. * @hide */ private static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op, boolean note) { private static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, @Nullable String featureId, String permission, int op, boolean note) { if (context.checkPermission(permission, pid, uid) != PERMISSION_GRANTED) { if (enforce) { throw new SecurityException( Loading @@ -1679,7 +1680,7 @@ public class StorageManager { AppOpsManager appOps = context.getSystemService(AppOpsManager.class); final int mode; if (note) { mode = appOps.noteOpNoThrow(op, uid, packageName); mode = appOps.noteOpNoThrow(op, uid, packageName, featureId, null); } else { try { appOps.checkPackage(uid, packageName); Loading Loading @@ -1711,14 +1712,15 @@ public class StorageManager { } } private boolean checkPermissionAndAppOp(boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, permission, op); private boolean checkPermissionAndAppOp(boolean enforce, int pid, int uid, String packageName, @Nullable String featureId, String permission, int op) { return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, featureId, permission, op); } private boolean noteAppOpAllowingLegacy(boolean enforce, int pid, int uid, String packageName, int op) { final int mode = mAppOps.noteOpNoThrow(op, uid, packageName); int pid, int uid, String packageName, @Nullable String featureId, int op) { final int mode = mAppOps.noteOpNoThrow(op, uid, packageName, featureId, null); switch (mode) { case AppOpsManager.MODE_ALLOWED: return true; Loading Loading @@ -1749,50 +1751,68 @@ public class StorageManager { /** {@hide} */ public boolean checkPermissionReadAudio(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_AUDIO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_AUDIO); } /** {@hide} */ public boolean checkPermissionWriteAudio(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_AUDIO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_AUDIO); } /** {@hide} */ public boolean checkPermissionReadVideo(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_VIDEO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_VIDEO); } /** {@hide} */ public boolean checkPermissionWriteVideo(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_VIDEO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_VIDEO); } /** {@hide} */ public boolean checkPermissionReadImages(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_IMAGES); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_IMAGES); } /** {@hide} */ public boolean checkPermissionWriteImages(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_IMAGES); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_IMAGES); } /** {@hide} */ Loading services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -2170,14 +2170,21 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } } @Deprecated @Override public ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId) { return getWallpaperWithFeature(callingPkg, null, cb, which, outParams, wallpaperUserId); } @Override public ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId, IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId) { final int hasPrivilege = mContext.checkCallingOrSelfPermission( android.Manifest.permission.READ_WALLPAPER_INTERNAL); if (hasPrivilege != PackageManager.PERMISSION_GRANTED) { mContext.getSystemService(StorageManager.class).checkPermissionReadImages(true, Binder.getCallingPid(), Binder.getCallingUid(), callingPkg); Binder.getCallingPid(), Binder.getCallingUid(), callingPkg, callingFeatureId); } wallpaperUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Loading Loading
core/java/android/app/IWallpaperManager.aidl +9 −1 Original line number Diff line number Diff line Loading @@ -58,13 +58,21 @@ interface IWallpaperManager { @UnsupportedAppUsage void setWallpaperComponent(in ComponentName name); /** * Get the wallpaper for a given user. * @deprecated Use {@link #getWallpaperWithFeature(String, IWallpaperManagerCallback, int, * Bundle, int)} */ @UnsupportedAppUsage ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId); /** * Get the wallpaper for a given user. */ ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId); /** * Retrieve the given user's current wallpaper ID of the given kind. */ Loading
core/java/android/app/WallpaperManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -458,8 +458,9 @@ public class WallpaperManager { try { Bundle params = new Bundle(); ParcelFileDescriptor fd = mService.getWallpaper(context.getOpPackageName(), this, FLAG_SYSTEM, params, userId); ParcelFileDescriptor fd = mService.getWallpaperWithFeature( context.getOpPackageName(), context.getFeatureId(), this, FLAG_SYSTEM, params, userId); if (fd != null) { try { BitmapFactory.Options options = new BitmapFactory.Options(); Loading Loading @@ -985,8 +986,8 @@ public class WallpaperManager { } else { try { Bundle outParams = new Bundle(); return sGlobals.mService.getWallpaper(mContext.getOpPackageName(), null, which, outParams, userId); return sGlobals.mService.getWallpaperWithFeature(mContext.getOpPackageName(), mContext.getFeatureId(), null, which, outParams, userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (SecurityException e) { Loading
core/java/android/os/storage/StorageManager.java +58 −38 Original line number Diff line number Diff line Loading @@ -1645,10 +1645,10 @@ public class StorageManager { * Check that given app holds both permission and appop. * @hide */ public static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op, true); public static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, @NonNull String featureId, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, featureId, permission, op, true); } /** Loading @@ -1657,16 +1657,17 @@ public class StorageManager { */ public static boolean checkPermissionAndCheckOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, permission, op, false); return checkPermissionAndAppOp(context, enforce, pid, uid, packageName, null /* featureId is not needed when not noting */, permission, op, false); } /** * Check that given app holds both permission and appop. * @hide */ private static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, String permission, int op, boolean note) { private static boolean checkPermissionAndAppOp(Context context, boolean enforce, int pid, int uid, String packageName, @Nullable String featureId, String permission, int op, boolean note) { if (context.checkPermission(permission, pid, uid) != PERMISSION_GRANTED) { if (enforce) { throw new SecurityException( Loading @@ -1679,7 +1680,7 @@ public class StorageManager { AppOpsManager appOps = context.getSystemService(AppOpsManager.class); final int mode; if (note) { mode = appOps.noteOpNoThrow(op, uid, packageName); mode = appOps.noteOpNoThrow(op, uid, packageName, featureId, null); } else { try { appOps.checkPackage(uid, packageName); Loading Loading @@ -1711,14 +1712,15 @@ public class StorageManager { } } private boolean checkPermissionAndAppOp(boolean enforce, int pid, int uid, String packageName, String permission, int op) { return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, permission, op); private boolean checkPermissionAndAppOp(boolean enforce, int pid, int uid, String packageName, @Nullable String featureId, String permission, int op) { return checkPermissionAndAppOp(mContext, enforce, pid, uid, packageName, featureId, permission, op); } private boolean noteAppOpAllowingLegacy(boolean enforce, int pid, int uid, String packageName, int op) { final int mode = mAppOps.noteOpNoThrow(op, uid, packageName); int pid, int uid, String packageName, @Nullable String featureId, int op) { final int mode = mAppOps.noteOpNoThrow(op, uid, packageName, featureId, null); switch (mode) { case AppOpsManager.MODE_ALLOWED: return true; Loading Loading @@ -1749,50 +1751,68 @@ public class StorageManager { /** {@hide} */ public boolean checkPermissionReadAudio(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_AUDIO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_AUDIO); } /** {@hide} */ public boolean checkPermissionWriteAudio(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_AUDIO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_AUDIO); } /** {@hide} */ public boolean checkPermissionReadVideo(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_VIDEO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_VIDEO); } /** {@hide} */ public boolean checkPermissionWriteVideo(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_VIDEO); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_VIDEO); } /** {@hide} */ public boolean checkPermissionReadImages(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_READ_MEDIA_IMAGES); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, READ_EXTERNAL_STORAGE, OP_READ_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_READ_MEDIA_IMAGES); } /** {@hide} */ public boolean checkPermissionWriteImages(boolean enforce, int pid, int uid, String packageName) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) return false; return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, OP_WRITE_MEDIA_IMAGES); int pid, int uid, String packageName, @Nullable String featureId) { if (!checkPermissionAndAppOp(enforce, pid, uid, packageName, featureId, WRITE_EXTERNAL_STORAGE, OP_WRITE_EXTERNAL_STORAGE)) { return false; } return noteAppOpAllowingLegacy(enforce, pid, uid, packageName, featureId, OP_WRITE_MEDIA_IMAGES); } /** {@hide} */ Loading
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -2170,14 +2170,21 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } } @Deprecated @Override public ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId) { return getWallpaperWithFeature(callingPkg, null, cb, which, outParams, wallpaperUserId); } @Override public ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId, IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId) { final int hasPrivilege = mContext.checkCallingOrSelfPermission( android.Manifest.permission.READ_WALLPAPER_INTERNAL); if (hasPrivilege != PackageManager.PERMISSION_GRANTED) { mContext.getSystemService(StorageManager.class).checkPermissionReadImages(true, Binder.getCallingPid(), Binder.getCallingUid(), callingPkg); Binder.getCallingPid(), Binder.getCallingUid(), callingPkg, callingFeatureId); } wallpaperUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Loading