Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b38aba8 authored by Ayush Sharma's avatar Ayush Sharma
Browse files

Make getContentProtectionPolicy api UserHandleAware

Bug: 356865968
Test: atest ContentProtectionPolicyTest
Flag: EXEMPT security patch fix
Change-Id: Ic50f2df0ae73e4678f78d7c42350d4f7f9a6fbb1
parent 12b7d297
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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();
            }
+1 −1
Original line number Diff line number Diff line
@@ -619,7 +619,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);

+3 −3
Original line number Diff line number Diff line
@@ -23457,6 +23457,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.
@@ -24092,15 +24094,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) {