Merge "Removing enforcePermissionsAndGetEnforcingAdmin from cleanCallingIdentity block" into udc-dev am: c831c399fa
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23600711 Change-Id: Ide8b4195b9dc58f59df25efac07a5f4d33ea1661 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -7840,27 +7840,29 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
throw new SecurityException("Cannot wipe data. " + restriction
|
throw new SecurityException("Cannot wipe data. " + restriction
|
||||||
+ " restriction is set for user " + userId);
|
+ " restriction is set for user " + userId);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
boolean isSystemUser = userId == UserHandle.USER_SYSTEM;
|
boolean isSystemUser = userId == UserHandle.USER_SYSTEM;
|
||||||
boolean wipeDevice;
|
boolean wipeDevice;
|
||||||
if (factoryReset == null || !mInjector.isChangeEnabled(EXPLICIT_WIPE_BEHAVIOUR,
|
if (factoryReset == null || !mInjector.isChangeEnabled(EXPLICIT_WIPE_BEHAVIOUR,
|
||||||
adminPackage,
|
adminPackage,
|
||||||
userId)) {
|
userId)) {
|
||||||
// Legacy mode
|
// Legacy mode
|
||||||
wipeDevice = isSystemUser;
|
wipeDevice = isSystemUser;
|
||||||
|
} else {
|
||||||
|
// Explicit behaviour
|
||||||
|
if (factoryReset) {
|
||||||
|
EnforcingAdmin enforcingAdmin = enforcePermissionsAndGetEnforcingAdmin(
|
||||||
|
/*admin=*/ null,
|
||||||
|
/*permission=*/ new String[]{MANAGE_DEVICE_POLICY_WIPE_DATA,
|
||||||
|
MASTER_CLEAR},
|
||||||
|
USES_POLICY_WIPE_DATA,
|
||||||
|
adminPackage,
|
||||||
|
factoryReset ? UserHandle.USER_ALL :
|
||||||
|
getAffectedUser(calledOnParentInstance));
|
||||||
|
wipeDevice = true;
|
||||||
} else {
|
} else {
|
||||||
// Explicit behaviour
|
mInjector.binderWithCleanCallingIdentity(() -> {
|
||||||
if (factoryReset) {
|
|
||||||
EnforcingAdmin enforcingAdmin = enforcePermissionsAndGetEnforcingAdmin(
|
|
||||||
/*admin=*/ null,
|
|
||||||
/*permission=*/ new String[]{MANAGE_DEVICE_POLICY_WIPE_DATA,
|
|
||||||
MASTER_CLEAR},
|
|
||||||
USES_POLICY_WIPE_DATA,
|
|
||||||
adminPackage,
|
|
||||||
factoryReset ? UserHandle.USER_ALL :
|
|
||||||
getAffectedUser(calledOnParentInstance));
|
|
||||||
wipeDevice = true;
|
|
||||||
} else {
|
|
||||||
Preconditions.checkCallAuthorization(!isSystemUser,
|
Preconditions.checkCallAuthorization(!isSystemUser,
|
||||||
"User %s is a system user and cannot be removed", userId);
|
"User %s is a system user and cannot be removed", userId);
|
||||||
boolean isLastNonHeadlessUser = getUserInfo(userId).isFull()
|
boolean isLastNonHeadlessUser = getUserInfo(userId).isFull()
|
||||||
@@ -7871,9 +7873,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
"Removing user %s would leave the device without any active users. "
|
"Removing user %s would leave the device without any active users. "
|
||||||
+ "Consider factory resetting the device instead.",
|
+ "Consider factory resetting the device instead.",
|
||||||
userId);
|
userId);
|
||||||
wipeDevice = false;
|
});
|
||||||
}
|
wipeDevice = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
mInjector.binderWithCleanCallingIdentity(() -> {
|
||||||
if (wipeDevice) {
|
if (wipeDevice) {
|
||||||
forceWipeDeviceNoLock(
|
forceWipeDeviceNoLock(
|
||||||
(flags & WIPE_EXTERNAL_STORAGE) != 0,
|
(flags & WIPE_EXTERNAL_STORAGE) != 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user