Merge "Clear DISALLOW_ADD_USER user restriction when dpm remove-active-admin is called from shell"

This commit is contained in:
TreeHugger Robot
2016-12-08 13:54:38 +00:00
committed by Android (Google) Code Review

View File

@@ -3093,6 +3093,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// If admin is a device or profile owner tidy that up first.
if (isDeviceOwner(adminReceiver, userHandle)) {
clearDeviceOwnerLocked(getDeviceOwnerAdminLocked(), userHandle);
clearDeviceOwnerUserRestrictionLocked(UserHandle.of(userHandle));
}
if (isProfileOwner(adminReceiver, userHandle)) {
final ActiveAdmin admin = getActiveAdminUncheckedLocked(adminReceiver,
@@ -3108,6 +3109,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
// It's temporary solution to clear DISALLOW_ADD_USER after CTS
// TODO: b/31952368 when the restriction is moved from system to the device owner,
// it can be removed.
private void clearDeviceOwnerUserRestrictionLocked(UserHandle userHandle) {
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER, userHandle)) {
mUserManager.setUserRestriction(UserManager.DISALLOW_ADD_USER, false, userHandle);
}
}
/**
* Return if a given package has testOnly="true", in which case we'll relax certain rules
* for CTS.