From 859b914c6e27a36747e84387c8864f11cfa78498 Mon Sep 17 00:00:00 2001 From: Jason Parks Date: Wed, 8 Mar 2023 16:18:39 +0000 Subject: [PATCH] Clear user restriction for managed profiles when the user is deleted. Bug: 270046713 Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testUserRestrictionsSetOnParentAreNotPersisted Change-Id: I2bdc1dd7dad520568102aea541e075b9423c78bb --- .../devicepolicy/DevicePolicyManagerService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index a220ad1510505..6cd9f1c3f9a05 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -2237,6 +2237,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } isOrgOwned = mOwners.isProfileOwnerOfOrganizationOwnedDevice(userHandle); + // Clear any restrictions set by the a profile owner and the parent admin. + final ActiveAdmin admin = getProfileOwnerLocked(userHandle); + if (admin != null) { + admin.userRestrictions = null; + final ActiveAdmin parentAdmin = admin.getParentActiveAdmin(); + if (parentAdmin != null) { + parentAdmin.userRestrictions = null; + } + pushUserRestrictions(userHandle); + } mOwners.removeProfileOwner(userHandle); mOwners.writeProfileOwner(userHandle); pushScreenCapturePolicy(userHandle);