diff options
author | 2024-08-22 10:15:07 +0000 | |
---|---|---|
committer | 2024-08-22 10:15:07 +0000 | |
commit | 968adb1a103b6c6b198a593f302fa2545c1fdc5f (patch) | |
tree | fdbc88bf4582e04df454843724155e7ebf6a16d1 | |
parent | 75dc3353569ce25124b2396b8846dd0a1c750fcc (diff) | |
parent | 2b38aba85a79fa4f5a6d271ac13c0d926cc3dd40 (diff) |
Merge "Make getContentProtectionPolicy api UserHandleAware" into main
3 files changed, 7 insertions, 5 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 965e3c43cca1..ba1dc5677b21 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -4334,11 +4334,13 @@ public class DevicePolicyManager { */ @RequiresPermission(value = MANAGE_DEVICE_POLICY_CONTENT_PROTECTION, conditional = true) @FlaggedApi(android.view.contentprotection.flags.Flags.FLAG_MANAGE_DEVICE_POLICY_ENABLED) + @UserHandleAware public @ContentProtectionPolicy int getContentProtectionPolicy(@Nullable ComponentName admin) { throwIfParentInstance("getContentProtectionPolicy"); if (mService != null) { try { - return mService.getContentProtectionPolicy(admin, mContext.getPackageName()); + return mService.getContentProtectionPolicy(admin, mContext.getPackageName(), + myUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index c393a9eeae30..d4e5c9960c2a 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -621,7 +621,7 @@ interface IDevicePolicyManager { void calculateHasIncompatibleAccounts(); void setContentProtectionPolicy(in ComponentName who, String callerPackageName, int policy); - int getContentProtectionPolicy(in ComponentName who, String callerPackageName); + int getContentProtectionPolicy(in ComponentName who, String callerPackageName, int userId); int[] getSubscriptionIds(String callerPackageName); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index d5013517cd88..1290fb7ef91a 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -23501,6 +23501,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { MANAGE_DEVICE_POLICY_ACROSS_USERS); CROSS_USER_PERMISSIONS.put(MANAGE_DEVICE_POLICY_WIPE_DATA, MANAGE_DEVICE_POLICY_ACROSS_USERS); + CROSS_USER_PERMISSIONS.put(MANAGE_DEVICE_POLICY_CONTENT_PROTECTION, + MANAGE_DEVICE_POLICY_ACROSS_USERS); // These permissions may grant access to user data and therefore must be protected with // MANAGE_DEVICE_POLICY_ACROSS_USERS_FULL for cross-user calls. @@ -24136,15 +24138,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public @ContentProtectionPolicy int getContentProtectionPolicy( - ComponentName who, String callerPackageName) { + ComponentName who, String callerPackageName, int userId) { if (!android.view.contentprotection.flags.Flags.manageDevicePolicyEnabled()) { return CONTENT_PROTECTION_DISABLED; } CallerIdentity caller = getCallerIdentity(who, callerPackageName); - int userId = caller.getUserId(); enforceCanQuery(MANAGE_DEVICE_POLICY_CONTENT_PROTECTION, callerPackageName, userId); - Integer policy = mDevicePolicyEngine.getResolvedPolicy(PolicyDefinition.CONTENT_PROTECTION, userId); if (policy == null) { |