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

Commit 14cc6847 authored by Jonathan Scott's avatar Jonathan Scott Committed by Android (Google) Code Review
Browse files

Merge "Use new setUserRestriction API in policy engine." into udc-dev

parents ac849f6a 079504b3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -12899,11 +12899,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_SET_USER_RESTRICTION);
        if (useDevicePolicyEngine(caller, /* delegateScope= */ null)) {
            int affectedUserId = parent ? getProfileParentId(userId) : userId;
            EnforcingAdmin admin = enforcePermissionForUserRestriction(
                    who,
                    key,
                    caller.getPackageName(),
                    userId);
                    affectedUserId);
            PolicyDefinition<Boolean> policyDefinition =
                    PolicyDefinition.getPolicyDefinitionForUserRestriction(key);
            if (enabledFromThisOwner) {
@@ -12911,7 +12912,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                        policyDefinition,
                        admin,
                        new BooleanPolicyValue(true),
                        parent ? getProfileParentId(userId) : userId);
                        affectedUserId);
            } else {
                // Remove any local and global policy that was set by the admin
                if (!policyDefinition.isLocalOnlyPolicy()) {
+2 −3
Original line number Diff line number Diff line
@@ -215,10 +215,9 @@ final class PolicyEnforcerCallbacks {
            }
            UserRestrictionPolicyKey parsedKey =
                    (UserRestrictionPolicyKey) policyKey;
            // TODO: call into new UserManager API when merged
            UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
//            userManager.setUserRestriction(
//                    userId, parsedKey.getRestriction(), enabled != null && enabled);
            userManager.setUserRestriction(
                    userId, parsedKey.getRestriction(), enabled != null && enabled);
            return true;
        }));
    }