From 89d3375fae67ea1cab8458e0a8e771c6ddecbb6c Mon Sep 17 00:00:00 2001 From: Jonathan Scott Date: Tue, 13 Dec 2022 13:37:58 +0000 Subject: [PATCH 1/4] Remove assumption that COPE profile owner is on profile of system user Test: btest CtsDevicePolicyTestCases Fixes: 261831953 Change-Id: I95d8ec76659bc382fe639b0b35d1adefaef2dda8 --- .../DevicePolicyManagerService.java | 146 +++++++++++++++--- 1 file changed, 127 insertions(+), 19 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index c42ddf81dfd40..8304d2dcafd6a 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -721,6 +721,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { private static final String KEEP_PROFILES_RUNNING_FLAG = "enable_keep_profiles_running"; private static final boolean DEFAULT_KEEP_PROFILES_RUNNING_FLAG = false; + // TODO(b/261999445) remove the flag after rollout. + private static final String HEADLESS_FLAG = "headless"; + private static final boolean DEFAULT_HEADLESS_FLAG = true; + /** * This feature flag is checked once after boot and this value us used until the next reboot to * avoid needing to handle the flag changing on the fly. @@ -7063,8 +7067,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Preconditions.checkCallAuthorization(frpManagementAgentUid == caller.getUid() || hasCallingPermission(permission.MASTER_CLEAR), "Must be called by the FRP management agent on device"); - admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.getUserId(frpManagementAgentUid)); + // TODO(b/261999445): Remove + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.getUserId(frpManagementAgentUid)); + } } else { Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) @@ -7105,8 +7114,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { hasCallingOrSelfPermission(permission.TRIGGER_LOST_MODE)); synchronized (getLockObject()) { - final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + // TODO(b/261999445): Remove + ActiveAdmin admin; + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } Preconditions.checkState(admin != null, "Lost mode location updates can only be sent on an organization-owned device."); mInjector.binderWithCleanCallingIdentity(() -> { @@ -8774,6 +8789,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return null; } + /** + * @deprecated Use the version which does not take a user id. + */ + @Deprecated ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(int userId) { ensureLocked(); ActiveAdmin admin = getDeviceOwnerAdminLocked(); @@ -8783,6 +8802,19 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin; } + ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked() { + ensureLocked(); + ActiveAdmin admin = getDeviceOwnerAdminLocked(); + if (admin == null) { + admin = getProfileOwnerOfOrganizationOwnedDeviceLocked(); + } + return admin; + } + + /** + * @deprecated Use the version which does not take a user id. + */ + @Deprecated ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(int userId) { ensureLocked(); ActiveAdmin admin = getDeviceOwnerAdminLocked(); @@ -8793,6 +8825,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin != null ? admin.getParentActiveAdmin() : null; } + ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked() { + ensureLocked(); + ActiveAdmin admin = getDeviceOwnerAdminLocked(); + if (admin != null) { + return admin; + } + admin = getProfileOwnerOfOrganizationOwnedDeviceLocked(); + return admin != null ? admin.getParentActiveAdmin() : null; + } + @Override public void clearDeviceOwner(String packageName) { Objects.requireNonNull(packageName, "packageName is null"); @@ -9325,6 +9367,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin; } + /** + * @deprecated use the version which does not take a user id. + */ + @Deprecated @GuardedBy("getLockObject()") ActiveAdmin getProfileOwnerOfOrganizationOwnedDeviceLocked(int userHandle) { return mInjector.binderWithCleanCallingIdentity(() -> { @@ -9341,6 +9387,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { }); } + @GuardedBy("getLockObject()") + ActiveAdmin getProfileOwnerOfOrganizationOwnedDeviceLocked() { + return mInjector.binderWithCleanCallingIdentity(() -> { + for (UserInfo userInfo : mUserManager.getUsers()) { + if (userInfo.isManagedProfile()) { + if (getProfileOwnerAsUser(userInfo.id) != null + && isProfileOwnerOfOrganizationOwnedDevice(userInfo.id)) { + ComponentName who = getProfileOwnerAsUser(userInfo.id); + return getActiveAdminUncheckedLocked(who, userInfo.id); + } + } + } + return null; + }); + } + /** * This API is cached: invalidate with invalidateBinderCaches(). */ @@ -17415,8 +17477,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { synchronized (getLockObject()) { // Only DO or COPE PO can turn on CC mode, so take a shortcut here and only look at // their ActiveAdmin, instead of iterating through all admins. - final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + ActiveAdmin admin; + // TODO(b/261999445): remove + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } return admin != null ? admin.mCommonCriteriaMode : false; } } @@ -18819,8 +18887,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } private boolean isUsbDataSignalingEnabledInternalLocked() { - final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + // TODO(b/261999445): remove + ActiveAdmin admin; + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } return admin == null || admin.mUsbDataSignalingEnabled; } @@ -18870,8 +18944,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public int getMinimumRequiredWifiSecurityLevel() { synchronized (getLockObject()) { - final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + ActiveAdmin admin; + // TODO(b/261999445): remove + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } return (admin == null) ? DevicePolicyManager.WIFI_SECURITY_OPEN : admin.mWifiMinimumSecurityLevel; } @@ -18887,8 +18967,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { + "a profile owner on an organization-owned device or " + "an app with the QUERY_ADMIN_POLICY permission."); synchronized (getLockObject()) { - final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + ActiveAdmin admin; + // TODO(b/261999445): remove + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } return admin != null ? admin.mWifiSsidPolicy : null; } } @@ -19260,9 +19346,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { || isProfileOwnerOfOrganizationOwnedDevice(caller)); } synchronized (getLockObject()) { - ActiveAdmin admin = - getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + // TODO(b/261999445): Remove + ActiveAdmin admin; + if (isHeadlessFlagEnabled()) { + admin = + getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = + getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } + if (admin != null) { final String memtagProperty = "arm64.memtag.bootctl"; if (flags == DevicePolicyManager.MTE_ENABLED) { @@ -19284,12 +19378,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { || isProfileOwnerOfOrganizationOwnedDevice(caller) || isSystemUid(caller)); synchronized (getLockObject()) { - ActiveAdmin admin = - getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); + // TODO(b/261999445): Remove + ActiveAdmin admin; + if (isHeadlessFlagEnabled()) { + admin = + getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + } else { + admin = + getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( + UserHandle.USER_SYSTEM); + } return admin != null ? admin.mtePolicy : DevicePolicyManager.MTE_NOT_CONTROLLED_BY_POLICY; } } -} + + private boolean isHeadlessFlagEnabled() { + return DeviceConfig.getBoolean( + NAMESPACE_DEVICE_POLICY_MANAGER, + HEADLESS_FLAG, + DEFAULT_HEADLESS_FLAG); + } +} \ No newline at end of file From a3d321a176095ac2c39f00bb5bb1de892bde38ca Mon Sep 17 00:00:00 2001 From: Jonathan Scott Date: Tue, 13 Dec 2022 13:47:07 +0000 Subject: [PATCH 2/4] Don't supress failures in adopting shell permission identity. This is required as we've seen recent flakiness in our tests where the only way to find out the root cause (DeadObjectException when adopting permissions) is to look in logcat. Test: btest CtsDevicePolicyTestCases Bug: 262371074 Change-Id: I2291984c77494a4afca0e403938e75cab1363ba6 --- core/java/android/app/UiAutomation.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index 814f38b2f3e64..e75b503d5f69c 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -76,7 +76,6 @@ import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.TimeoutException; @@ -484,7 +483,7 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.adoptShellPermissionIdentity(Process.myUid(), null); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error executing adopting shell permission identity!", re); + throw re.rethrowFromSystemServer(); } } @@ -509,7 +508,7 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.adoptShellPermissionIdentity(Process.myUid(), permissions); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error executing adopting shell permission identity!", re); + throw re.rethrowFromSystemServer(); } } @@ -525,7 +524,7 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.dropShellPermissionIdentity(); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error executing dropping shell permission identity!", re); + throw re.rethrowFromSystemServer(); } } @@ -543,8 +542,7 @@ public final class UiAutomation { final List permissions = mUiAutomationConnection.getAdoptedShellPermissions(); return permissions == null ? ALL_PERMISSIONS : new ArraySet<>(permissions); } catch (RemoteException re) { - Log.e(LOG_TAG, "Error getting adopted shell permissions", re); - return Collections.emptySet(); + throw re.rethrowFromSystemServer(); } } From 9a3079a231ee099544f1084b186839523a983e66 Mon Sep 17 00:00:00 2001 From: Jonathan Scott Date: Tue, 13 Dec 2022 13:49:43 +0000 Subject: [PATCH 3/4] Stop silently eating exceptions in DPMS. This can result in really hard to debug issues. Ideally we'd throw an exception but that could have unintended consequences so just adding a wtf log first. Test: btest CtsDevicePolicyTestCase Change-Id: Iaa27f34a20aeb63a01a9b635c6e3e328b45b642d --- .../DevicePolicyManagerService.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 8304d2dcafd6a..7c697058c394f 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1235,6 +1235,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException re) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Error handling package changes", re); } } if (removedAdmin) { @@ -1292,6 +1293,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { && mIPackageManager.getPackageInfo(targetPackage, 0, userHandle) == null; } catch (RemoteException e) { // Shouldn't happen + Slogf.wtf(LOG_TAG, "Error checking isRemovedPackage", e); } return false; @@ -1314,6 +1316,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { null, null, null, PLATFORM_PACKAGE_NAME, userHandle); } catch (RemoteException ignored) { // shouldn't happen. + Slogf.wtf(LOG_TAG, "Error handling new package installed", ignored); } } @@ -2232,6 +2235,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { packageName, MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, userId); } catch (RemoteException e) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Error getting application info", e); return; } if (appInfo == null) { @@ -2866,6 +2870,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userHandle); } catch (RemoteException e) { // shouldn't happen. + Slogf.wtf(LOG_TAG, "Error getting receiver info", e); return null; } }); @@ -6773,6 +6778,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException re) { // Shouldn't happen + Slogf.wtf(LOG_TAG, "Error forcing wipe user", re); } finally { if (!success) SecurityLog.writeEvent(SecurityLog.TAG_WIPE_FAILURE); } @@ -9120,6 +9126,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { pushUserRestrictions(userId); } catch (RemoteException re) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Failing in updatePermissionFlagsForAllApps", re); } } @@ -9859,7 +9866,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } return currentUser.id; } catch (RemoteException e) { - Slogf.wtf(LOG_TAG, "cannot get current user"); + Slogf.wtf(LOG_TAG, "cannot get current user", e); } return UserHandle.USER_NULL; } @@ -10089,6 +10096,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mIPackageManager.flushPackageRestrictionsAsUser(userHandle); } catch (RemoteException re) { // Shouldn't happen + Slog.wtf(LOG_TAG, "Error adding persistent preferred activity", re); } finally { mInjector.binderRestoreCallingIdentity(id); } @@ -10117,6 +10125,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mIPackageManager.flushPackageRestrictionsAsUser(userHandle); } catch (RemoteException re) { // Shouldn't happen + Slogf.wtf( + LOG_TAG, "Error when clearing package persistent preferred activities", re); } finally { mInjector.binderRestoreCallingIdentity(id); } @@ -10314,6 +10324,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException re) { // Shouldn't happen + Slogf.wtf(LOG_TAG, "Error adding cross profile intent filter", re); } finally { mInjector.binderRestoreCallingIdentity(id); } @@ -10364,6 +10375,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mIPackageManager.clearCrossProfileIntentFilters(parent.id, who.getPackageName()); } catch (RemoteException re) { // Shouldn't happen + Slogf.wtf(LOG_TAG, "Error clearing cross profile intent filters", re); } finally { mInjector.binderRestoreCallingIdentity(id); } @@ -11888,7 +11900,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException e) { // shouldn't happen - Slogf.wtf(LOG_TAG, "Failed to resolve intent for: " + intent); + Slogf.wtf(LOG_TAG, "Failed to resolve intent for: " + intent, e); return 0; } finally { mInjector.binderRestoreCallingIdentity(id); @@ -11942,6 +11954,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { == PackageManager.INSTALL_SUCCEEDED; } catch (RemoteException re) { // shouldn't happen + Slogf.wtf(LOG_TAG, "Error installing package", re); return false; } finally { mInjector.binderRestoreCallingIdentity(id); @@ -14585,6 +14598,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return ai == null ? 0 : ai.targetSdkVersion; } catch (RemoteException e) { // Shouldn't happen + Slogf.wtf(LOG_TAG, "Error getting application info", e); return 0; } } @@ -18301,6 +18315,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException e) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Error setting application enabled", e); } } @@ -18336,6 +18351,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { callerPackage); } catch (RemoteException e) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Error starting user", e); } finally { mContext.unregisterReceiver(unlockedReceiver); } @@ -18658,6 +18674,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } catch (RemoteException e) { // Shouldn't happen. + Slogf.wtf(LOG_TAG, "Error resetting default cross profile intent filters", e); } }); } From 6aee9d4d59c9dcb9cb88700acd9b29c0addbfd79 Mon Sep 17 00:00:00 2001 From: Jonathan Scott Date: Tue, 13 Dec 2022 13:56:22 +0000 Subject: [PATCH 4/4] Correctly identify the COPE user for screenshot policy. Test: btest "android.devicepolicy.cts.ScreenCaptureDisabledTest#setScreenCaptureDisabled_true_works[IncludeRunOnParentOfOrganizationOwnedProfileOwnerUsingParentInstance]" -sy Bug: 258561494 Change-Id: I9e940e5ba7faadbcfdb71461400886fa8a11ca69 --- .../DevicePolicyManagerService.java | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7c697058c394f..667f41f0ad4db 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -2588,7 +2588,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { ensureLocked(); // Try to find an admin which can use reqPolicy final ComponentName poAdminComponent = mOwners.getProfileOwnerComponent(userId); - final ComponentName doAdminComponent = mOwners.getDeviceOwnerComponent(); if (poAdminComponent != null) { return getProfileOwnerLocked(userId); @@ -7762,9 +7761,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // be disabled device-wide. private void pushScreenCapturePolicy(int adminUserId) { // Update screen capture device-wide if disabled by the DO or COPE PO on the parent profile. - ActiveAdmin admin = - getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked( - UserHandle.USER_SYSTEM); + // TODO(b/261999445): remove + ActiveAdmin admin; + if (isHeadlessFlagEnabled()) { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked( + mUserManagerInternal.getProfileParentId(adminUserId)); + } else { + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked( + UserHandle.USER_SYSTEM); + } if (admin != null && admin.disableScreenCapture) { setScreenCaptureDisabled(UserHandle.USER_ALL); } else { @@ -8817,10 +8822,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin; } - /** - * @deprecated Use the version which does not take a user id. - */ - @Deprecated ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(int userId) { ensureLocked(); ActiveAdmin admin = getDeviceOwnerAdminLocked(); @@ -8831,16 +8832,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin != null ? admin.getParentActiveAdmin() : null; } - ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked() { - ensureLocked(); - ActiveAdmin admin = getDeviceOwnerAdminLocked(); - if (admin != null) { - return admin; - } - admin = getProfileOwnerOfOrganizationOwnedDeviceLocked(); - return admin != null ? admin.getParentActiveAdmin() : null; - } - @Override public void clearDeviceOwner(String packageName) { Objects.requireNonNull(packageName, "packageName is null"); @@ -9374,10 +9365,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return admin; } - /** - * @deprecated use the version which does not take a user id. - */ - @Deprecated @GuardedBy("getLockObject()") ActiveAdmin getProfileOwnerOfOrganizationOwnedDeviceLocked(int userHandle) { return mInjector.binderWithCleanCallingIdentity(() -> {