diff options
author | Alex Kershaw <alexkershaw@google.com> | 2020-12-17 17:22:22 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-12-17 17:22:22 +0000 |
commit | 2e6c54c29375d70f56cd3a636b0973775bfd1146 (patch) | |
tree | 6a112ab827df61c27601ba00501a4ca6d2c329db /services/devicepolicy | |
parent | cff7cd0d2182b34c7e3d6667affe208e063b1ae5 (diff) | |
parent | f764d9e98f9fadb1c76b89e768683bb02595363c (diff) |
DO NOT MERGE Correctly reset cross-profile app-op am: f764d9e98f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13236705
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Iea45f7508d51a3a2f2a7be513549b2d8d34e1bb9
Diffstat (limited to 'services/devicepolicy')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index dd83780826e5..90a7dccec9e2 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -125,6 +125,7 @@ import android.app.ActivityThread; import android.app.AlarmManager; import android.app.AppGlobals; import android.app.AppOpsManager; +import android.app.AppOpsManager.Mode; import android.app.BroadcastOptions; import android.app.IActivityManager; import android.app.IActivityTaskManager; @@ -12832,6 +12833,28 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { public ComponentName getProfileOwnerAsUser(int userHandle) { return DevicePolicyManagerService.this.getProfileOwnerAsUser(userHandle); } + + @Override + public boolean supportsResetOp(int op) { + return op == AppOpsManager.OP_INTERACT_ACROSS_PROFILES + && LocalServices.getService(CrossProfileAppsInternal.class) != null; + } + + @Override + public void resetOp(int op, String packageName, @UserIdInt int userId) { + if (op != AppOpsManager.OP_INTERACT_ACROSS_PROFILES) { + throw new IllegalArgumentException("Unsupported op for DPM reset: " + op); + } + LocalServices.getService(CrossProfileAppsInternal.class) + .setInteractAcrossProfilesAppOp( + packageName, findInteractAcrossProfilesResetMode(packageName), userId); + } + + private @Mode int findInteractAcrossProfilesResetMode(String packageName) { + return getDefaultCrossProfilePackages().contains(packageName) + ? AppOpsManager.MODE_ALLOWED + : AppOpsManager.opToDefaultMode(AppOpsManager.OP_INTERACT_ACROSS_PROFILES); + } } private Intent createShowAdminSupportIntent(ComponentName admin, int userId) { |