Merge "Only a test admin can be unmarked as a COPE admin" into tm-dev am: 9736fb2a2b am: 25211cdd5d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17822403

Change-Id: Ic56074544dce23366cd6c6c8ef8ecdd713aef124
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alex Johnston
2022-04-26 16:12:14 +00:00
committed by Automerger Merge Worker

View File

@@ -14656,6 +14656,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
throw new SecurityException(
"Only the system can mark a profile owner of organization-owned device.");
}
// Only a test admin can be unmarked as a profile owner on an organization-owned device.
synchronized (getLockObject()) {
if (!isProfileOwnerOnOrganizationOwnedDevice && !isAdminTestOnlyLocked(who, userId)) {
throw new SecurityException("Only a test admin can be unmarked as a "
+ "profile owner of organization-owned device.");
}
}
if (isAdb(caller)) {
if (hasIncompatibleAccountsOrNonAdbNoLock(caller, userId, who)) {