summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Johnston <acjohnston@google.com> 2022-04-26 15:34:38 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-04-26 15:34:38 +0000
commit9736fb2a2bc642c216f198eb4ac26cd3a3a0c05b (patch)
tree472607ca5209e3eaa0957540af5246eb546ee52c
parent4e612ce97167dbe36eda8b434635706d6d8cda86 (diff)
parent37259089a220aeb67a76af2aa60e732e0e623363 (diff)
Merge "Only a test admin can be unmarked as a COPE admin" into tm-dev
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 973f5a968ea4..2c4fa30b5113 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -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)) {