Loading core/java/android/app/AppOpsManager.java +30 −6 Original line number Diff line number Diff line Loading @@ -8752,24 +8752,48 @@ public class AppOpsManager { * Restrictions are temporary additional constraints imposed on top of the persisted rules * defined by {@link #setMode}. * * Audio restrictions are keyed by code/usage pairs (i.e. OP_PLAY_AUDIO, USAGE_MEDIA), and have * a value of a MODE and a set of exempted packages, and apply globally. * * @param code The operation to restrict. * @param usage The {@link android.media.AudioAttributes} usage value. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict. * @param usages A set of {@link android.media.AudioAttributes} usage values to apply * restrictions to, overriding any restriction currently in place for that usage. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict * (see key above). * @param exceptionPackages Optional list of packages to exclude from the restriction. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @UnsupportedAppUsage public void setRestriction(int code, @AttributeUsage int usage, @Mode int mode, public void setAudioRestriction(int code, @AttributeUsage int[] usages, @Mode int mode, String[] exceptionPackages) { try { final int uid = Binder.getCallingUid(); mService.setAudioRestriction(code, usage, uid, mode, exceptionPackages); mService.setAudioRestriction(code, usages, mode, exceptionPackages); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * See #setRestriction(int, int[], int, String[]). * * Included for compatibility * * @param code The operation to restrict. * @param usage The {@link android.media.AudioAttributes} usage value. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict. * @param exceptionPackages Optional list of packages to exclude from the restriction. * @deprecated Use {@link #setAudioRestriction(int, int[], int, String[])} instead. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @Deprecated @UnsupportedAppUsage public void setRestriction(int code, @AttributeUsage int usage, @Mode int mode, String[] exceptionPackages) { setAudioRestriction(code, new int[] {usage}, mode, exceptionPackages); } /** @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading core/java/com/android/internal/app/IAppOpsService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ interface IAppOpsService { void setMode(int code, int uid, String packageName, int mode); @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) void resetAllModes(int reqUserId, String reqPackageName); void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages); void setAudioRestriction(int code, in int[] usages, int mode, in String[] exceptionPackages); void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in PackageTagsList excludedPackageTags); Loading services/core/java/com/android/server/appop/AppOpsService.java +7 −6 Original line number Diff line number Diff line Loading @@ -3146,14 +3146,15 @@ public class AppOpsService extends IAppOpsService.Stub { } @Override public void setAudioRestriction(int code, int usage, int uid, int mode, String[] exceptionPackages) { enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), uid); verifyIncomingUid(uid); public void setAudioRestriction(int code, int[] usages, int mode, String[] exceptionPackages) { // Audio restrictions apply to all UIDs enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), -1); verifyIncomingOp(code); for (int usage : usages) { mAudioRestrictionManager.setZenModeAudioRestriction( code, usage, mode, exceptionPackages); } // Only notify default device as other devices are unaffected by restriction changes. mHandler.sendMessage(PooledLambda.obtainMessage( Loading Loading
core/java/android/app/AppOpsManager.java +30 −6 Original line number Diff line number Diff line Loading @@ -8752,24 +8752,48 @@ public class AppOpsManager { * Restrictions are temporary additional constraints imposed on top of the persisted rules * defined by {@link #setMode}. * * Audio restrictions are keyed by code/usage pairs (i.e. OP_PLAY_AUDIO, USAGE_MEDIA), and have * a value of a MODE and a set of exempted packages, and apply globally. * * @param code The operation to restrict. * @param usage The {@link android.media.AudioAttributes} usage value. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict. * @param usages A set of {@link android.media.AudioAttributes} usage values to apply * restrictions to, overriding any restriction currently in place for that usage. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict * (see key above). * @param exceptionPackages Optional list of packages to exclude from the restriction. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @UnsupportedAppUsage public void setRestriction(int code, @AttributeUsage int usage, @Mode int mode, public void setAudioRestriction(int code, @AttributeUsage int[] usages, @Mode int mode, String[] exceptionPackages) { try { final int uid = Binder.getCallingUid(); mService.setAudioRestriction(code, usage, uid, mode, exceptionPackages); mService.setAudioRestriction(code, usages, mode, exceptionPackages); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * See #setRestriction(int, int[], int, String[]). * * Included for compatibility * * @param code The operation to restrict. * @param usage The {@link android.media.AudioAttributes} usage value. * @param mode The restriction mode (MODE_IGNORED,MODE_ERRORED) or MODE_ALLOWED to unrestrict. * @param exceptionPackages Optional list of packages to exclude from the restriction. * @deprecated Use {@link #setAudioRestriction(int, int[], int, String[])} instead. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @Deprecated @UnsupportedAppUsage public void setRestriction(int code, @AttributeUsage int usage, @Mode int mode, String[] exceptionPackages) { setAudioRestriction(code, new int[] {usage}, mode, exceptionPackages); } /** @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading
core/java/com/android/internal/app/IAppOpsService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ interface IAppOpsService { void setMode(int code, int uid, String packageName, int mode); @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) void resetAllModes(int reqUserId, String reqPackageName); void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages); void setAudioRestriction(int code, in int[] usages, int mode, in String[] exceptionPackages); void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in PackageTagsList excludedPackageTags); Loading
services/core/java/com/android/server/appop/AppOpsService.java +7 −6 Original line number Diff line number Diff line Loading @@ -3146,14 +3146,15 @@ public class AppOpsService extends IAppOpsService.Stub { } @Override public void setAudioRestriction(int code, int usage, int uid, int mode, String[] exceptionPackages) { enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), uid); verifyIncomingUid(uid); public void setAudioRestriction(int code, int[] usages, int mode, String[] exceptionPackages) { // Audio restrictions apply to all UIDs enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), -1); verifyIncomingOp(code); for (int usage : usages) { mAudioRestrictionManager.setZenModeAudioRestriction( code, usage, mode, exceptionPackages); } // Only notify default device as other devices are unaffected by restriction changes. mHandler.sendMessage(PooledLambda.obtainMessage( Loading