Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +15 −3 Original line number Diff line number Diff line Loading @@ -7867,15 +7867,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return null; } synchronized (getLockObject()) { final ComponentName doComponent = mOwners.getDeviceOwnerComponent(); final ComponentName poComponent = mOwners.getProfileOwnerComponent(userHandle.getIdentifier()); // Return test only admin by default. if (isAdminTestOnlyLocked(doComponent, userHandle.getIdentifier())) { return doComponent; } else if (isAdminTestOnlyLocked(poComponent, userHandle.getIdentifier())) { return poComponent; } final String supervisor = mContext.getResources().getString( com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); if (supervisor == null) { return null; } final ComponentName supervisorComponent = ComponentName.unflattenFromString(supervisor); final ComponentName doComponent = mOwners.getDeviceOwnerComponent(); final ComponentName poComponent = mOwners.getProfileOwnerComponent(userHandle.getIdentifier()); if (supervisorComponent.equals(doComponent) || supervisorComponent.equals( poComponent)) { return supervisorComponent; Loading Loading @@ -10225,6 +10231,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { throw new SecurityException( "User " + userId + " is not allowed to call setSecondaryLockscreenEnabled"); } synchronized (getLockObject()) { if (isAdminTestOnlyLocked(who, userId)) { // Allow testOnly admins to bypass supervision config requirement. return; } } // Only the default supervision app can use this API. final String supervisor = mContext.getResources().getString( com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); Loading services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -4392,6 +4392,16 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testSecondaryLockscreen_nonSupervisionApp() throws Exception { mContext.binder.callingUid = DpmMockContext.CALLER_UID; // Ensure packages are *not* flagged as test_only. doReturn(new ApplicationInfo()).when(getServices().ipackageManager).getApplicationInfo( eq(admin1.getPackageName()), anyInt(), eq(CALLER_USER_HANDLE)); doReturn(new ApplicationInfo()).when(getServices().ipackageManager).getApplicationInfo( eq(admin2.getPackageName()), anyInt(), eq(CALLER_USER_HANDLE)); // Initial state is disabled. assertFalse(dpm.isSecondaryLockscreenEnabled(UserHandle.of(CALLER_USER_HANDLE))); Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +15 −3 Original line number Diff line number Diff line Loading @@ -7867,15 +7867,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return null; } synchronized (getLockObject()) { final ComponentName doComponent = mOwners.getDeviceOwnerComponent(); final ComponentName poComponent = mOwners.getProfileOwnerComponent(userHandle.getIdentifier()); // Return test only admin by default. if (isAdminTestOnlyLocked(doComponent, userHandle.getIdentifier())) { return doComponent; } else if (isAdminTestOnlyLocked(poComponent, userHandle.getIdentifier())) { return poComponent; } final String supervisor = mContext.getResources().getString( com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); if (supervisor == null) { return null; } final ComponentName supervisorComponent = ComponentName.unflattenFromString(supervisor); final ComponentName doComponent = mOwners.getDeviceOwnerComponent(); final ComponentName poComponent = mOwners.getProfileOwnerComponent(userHandle.getIdentifier()); if (supervisorComponent.equals(doComponent) || supervisorComponent.equals( poComponent)) { return supervisorComponent; Loading Loading @@ -10225,6 +10231,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { throw new SecurityException( "User " + userId + " is not allowed to call setSecondaryLockscreenEnabled"); } synchronized (getLockObject()) { if (isAdminTestOnlyLocked(who, userId)) { // Allow testOnly admins to bypass supervision config requirement. return; } } // Only the default supervision app can use this API. final String supervisor = mContext.getResources().getString( com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent); Loading
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -4392,6 +4392,16 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testSecondaryLockscreen_nonSupervisionApp() throws Exception { mContext.binder.callingUid = DpmMockContext.CALLER_UID; // Ensure packages are *not* flagged as test_only. doReturn(new ApplicationInfo()).when(getServices().ipackageManager).getApplicationInfo( eq(admin1.getPackageName()), anyInt(), eq(CALLER_USER_HANDLE)); doReturn(new ApplicationInfo()).when(getServices().ipackageManager).getApplicationInfo( eq(admin2.getPackageName()), anyInt(), eq(CALLER_USER_HANDLE)); // Initial state is disabled. assertFalse(dpm.isSecondaryLockscreenEnabled(UserHandle.of(CALLER_USER_HANDLE))); Loading