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

Commit 079504b3 authored by Elis Elliott's avatar Elis Elliott
Browse files

Use new setUserRestriction API in policy engine.

Test: btest a.d.c.TelephonyTest -c yes
Test: btest a.d.c.SafeBootTest -c yes
Test: btest a.d.c.InstallUnknownSourcesTest -c yes
Test: btest a.d.c.TimeTest -c yes
Test: btest a.d.c.ModifyUsersTest -c yes
Test: btest a.d.c.DebuggingTest -c yes
Change-Id: I267e310af2ec8656f6b02daf9ad50a6b2f0ec141
parent a0961285
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -12823,11 +12823,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) {
@@ -12835,7 +12836,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;
        }));
    }