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

This commit is contained in:
Jonathan Scott
2023-02-17 23:24:37 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 5 deletions

View File

@@ -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()) {

View File

@@ -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;
}));
}