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

Commit 968adb1a authored by Ayush Sharma's avatar Ayush Sharma Committed by Android (Google) Code Review
Browse files

Merge "Make getContentProtectionPolicy api UserHandleAware" into main

parents 75dc3353 2b38aba8
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
@@ -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);

+3 −3
Original line number Diff line number Diff line
@@ -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) {