Loading core/java/android/app/admin/DevicePolicyManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -9262,6 +9262,21 @@ public class DevicePolicyManager { return null; } /** * Checks if the specified component is the supervision component. * @hide */ public boolean isSupervisionComponent(@NonNull ComponentName who) { if (mService != null) { try { return getService().isSupervisionComponent(who); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return false; } /** * @hide * @return the human readable name of the organisation associated with this DPM or {@code null} Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ interface IDevicePolicyManager { boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle); ComponentName getProfileOwnerAsUser(int userHandle); ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(in UserHandle userHandle); boolean isSupervisionComponent(in ComponentName who); String getProfileOwnerName(int userHandle); void setProfileEnabled(in ComponentName who); void setProfileName(in ComponentName who, String profileName); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +26 −7 Original line number Diff line number Diff line Loading @@ -9292,11 +9292,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } // Check profile owner first as that is what most likely is set. if (isSupervisionComponent(poComponent)) { if (isSupervisionComponentLocked(poComponent)) { return poComponent; } if (isSupervisionComponent(doComponent)) { if (isSupervisionComponentLocked(doComponent)) { return doComponent; } Loading @@ -9304,7 +9304,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private boolean isSupervisionComponent(@Nullable ComponentName who) { /** * Returns if the specified component is the supervision component. */ @Override public boolean isSupervisionComponent(@NonNull ComponentName who) { if (!mHasFeature) { return false; } synchronized (getLockObject()) { if (mConstants.USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT) { final CallerIdentity caller = getCallerIdentity(); if (isAdminTestOnlyLocked(who, caller.getUserId())) { return true; } } return isSupervisionComponentLocked(who); } } private boolean isSupervisionComponentLocked(@Nullable ComponentName who) { if (who == null) { return false; } Loading Loading @@ -9508,7 +9527,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { "Cannot set the profile owner on a user which is already set-up"); if (!mIsWatch) { if (!isSupervisionComponent(owner)) { if (!isSupervisionComponentLocked(owner)) { throw new IllegalStateException("Unable to set non-default profile owner" + " post-setup " + owner); } Loading Loading @@ -12102,8 +12121,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { synchronized (getLockObject()) { // Allow testOnly admins to bypass supervision config requirement. Preconditions.checkCallAuthorization(isAdminTestOnlyLocked(who, caller.getUserId()) || isSupervisionComponent(caller.getComponentName()), "Admin %s is not the " + "default supervision component", caller.getComponentName()); || isSupervisionComponentLocked(caller.getComponentName()), "Admin %s is not " + "the default supervision component", caller.getComponentName()); DevicePolicyData policy = getUserData(caller.getUserId()); policy.mSecondaryLockscreenEnabled = enabled; saveSettingsLocked(caller.getUserId()); Loading Loading @@ -13004,7 +13023,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } return isSupervisionComponent(admin.info.getComponent()); return isSupervisionComponentLocked(admin.info.getComponent()); } } services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -3360,9 +3360,11 @@ public class DevicePolicyManagerTest extends DpmTestBase { assertThat(dpmi.isActiveSupervisionApp(uid)).isTrue(); assertThat(dpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(user)) .isEqualTo(admin1); assertThat(dpm.isSupervisionComponent(admin1)).isTrue(); } else { assertThat(dpmi.isActiveSupervisionApp(uid)).isFalse(); assertThat(dpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(user)).isNull(); assertThat(dpm.isSupervisionComponent(admin1)).isFalse(); } } Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -9262,6 +9262,21 @@ public class DevicePolicyManager { return null; } /** * Checks if the specified component is the supervision component. * @hide */ public boolean isSupervisionComponent(@NonNull ComponentName who) { if (mService != null) { try { return getService().isSupervisionComponent(who); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return false; } /** * @hide * @return the human readable name of the organisation associated with this DPM or {@code null} Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ interface IDevicePolicyManager { boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle); ComponentName getProfileOwnerAsUser(int userHandle); ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(in UserHandle userHandle); boolean isSupervisionComponent(in ComponentName who); String getProfileOwnerName(int userHandle); void setProfileEnabled(in ComponentName who); void setProfileName(in ComponentName who, String profileName); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +26 −7 Original line number Diff line number Diff line Loading @@ -9292,11 +9292,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } // Check profile owner first as that is what most likely is set. if (isSupervisionComponent(poComponent)) { if (isSupervisionComponentLocked(poComponent)) { return poComponent; } if (isSupervisionComponent(doComponent)) { if (isSupervisionComponentLocked(doComponent)) { return doComponent; } Loading @@ -9304,7 +9304,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private boolean isSupervisionComponent(@Nullable ComponentName who) { /** * Returns if the specified component is the supervision component. */ @Override public boolean isSupervisionComponent(@NonNull ComponentName who) { if (!mHasFeature) { return false; } synchronized (getLockObject()) { if (mConstants.USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT) { final CallerIdentity caller = getCallerIdentity(); if (isAdminTestOnlyLocked(who, caller.getUserId())) { return true; } } return isSupervisionComponentLocked(who); } } private boolean isSupervisionComponentLocked(@Nullable ComponentName who) { if (who == null) { return false; } Loading Loading @@ -9508,7 +9527,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { "Cannot set the profile owner on a user which is already set-up"); if (!mIsWatch) { if (!isSupervisionComponent(owner)) { if (!isSupervisionComponentLocked(owner)) { throw new IllegalStateException("Unable to set non-default profile owner" + " post-setup " + owner); } Loading Loading @@ -12102,8 +12121,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { synchronized (getLockObject()) { // Allow testOnly admins to bypass supervision config requirement. Preconditions.checkCallAuthorization(isAdminTestOnlyLocked(who, caller.getUserId()) || isSupervisionComponent(caller.getComponentName()), "Admin %s is not the " + "default supervision component", caller.getComponentName()); || isSupervisionComponentLocked(caller.getComponentName()), "Admin %s is not " + "the default supervision component", caller.getComponentName()); DevicePolicyData policy = getUserData(caller.getUserId()); policy.mSecondaryLockscreenEnabled = enabled; saveSettingsLocked(caller.getUserId()); Loading Loading @@ -13004,7 +13023,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } return isSupervisionComponent(admin.info.getComponent()); return isSupervisionComponentLocked(admin.info.getComponent()); } }
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -3360,9 +3360,11 @@ public class DevicePolicyManagerTest extends DpmTestBase { assertThat(dpmi.isActiveSupervisionApp(uid)).isTrue(); assertThat(dpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(user)) .isEqualTo(admin1); assertThat(dpm.isSupervisionComponent(admin1)).isTrue(); } else { assertThat(dpmi.isActiveSupervisionApp(uid)).isFalse(); assertThat(dpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(user)).isNull(); assertThat(dpm.isSupervisionComponent(admin1)).isFalse(); } } Loading