Merge "Removing enforcePermissionsAndGetEnforcingAdmin from cleanCallingIdentity block" into udc-dev

This commit is contained in:
TreeHugger Robot
2023-06-07 17:18:06 +00:00
committed by Android (Google) Code Review

View File

@@ -7840,6 +7840,7 @@ 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;
@@ -7861,6 +7862,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
getAffectedUser(calledOnParentInstance)); getAffectedUser(calledOnParentInstance));
wipeDevice = true; wipeDevice = true;
} else { } else {
mInjector.binderWithCleanCallingIdentity(() -> {
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,