Merge "Refactor permission checks removeActiveAdmin" into sc-v2-dev

This commit is contained in:
Ayush Sharma
2021-12-22 16:44:34 +00:00
committed by Android (Google) Code Review

View File

@@ -3796,7 +3796,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
final CallerIdentity caller = getCallerIdentity();
final CallerIdentity caller = hasCallingOrSelfPermission(permission.MANAGE_DEVICE_ADMINS)
? getCallerIdentity() : getCallerIdentity(adminReceiver);
Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_REMOVE_ACTIVE_ADMIN);
enforceUserUnlocked(userHandle);
@@ -3813,8 +3814,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
+ adminReceiver);
return;
}
Preconditions.checkCallAuthorization(admin.getUid() == caller.getUid()
|| hasCallingOrSelfPermission(permission.MANAGE_DEVICE_ADMINS));
mInjector.binderWithCleanCallingIdentity(() ->
removeActiveAdminLocked(adminReceiver, userHandle));
}