Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +13 −5 Original line number Diff line number Diff line Loading @@ -1836,8 +1836,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Bundle addSyntheticRestrictions(Bundle restrictions) { if (disableCamera) { restrictions.putBoolean(UserManager.DISALLOW_CAMERA, true); } else { restrictions.remove(UserManager.DISALLOW_CAMERA); } if (requireAutoTime) { restrictions.putBoolean(UserManager.DISALLOW_CONFIG_DATE_TIME, true); } return restrictions; } Loading @@ -1864,7 +1865,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Bundle getEffectiveRestrictions() { return addSyntheticRestrictions( removeDeprecatedRestrictions(ensureUserRestrictions())); removeDeprecatedRestrictions(new Bundle(ensureUserRestrictions()))); } Bundle getLocalUserRestrictions(int adminType) { Loading Loading @@ -2747,6 +2748,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // The following policies weren't available to PO, but will be available after migration. parentAdmin.disableCamera = doAdmin.disableCamera; parentAdmin.requireAutoTime = doAdmin.requireAutoTime; // TODO(b/143516163): Uncomment once corresponding APIs are available via parent instance. // parentAdmin.disableScreenCapture = doAdmin.disableScreenCapture; // parentAdmin.accountTypesWithManagementDisabled.addAll( Loading Loading @@ -7839,16 +7842,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } Objects.requireNonNull(who, "ComponentName is null"); final int userHandle = UserHandle.getCallingUserId(); boolean requireAutoTimeChanged = false; synchronized (getLockObject()) { ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (admin.requireAutoTime != required) { admin.requireAutoTime = required; saveSettingsLocked(userHandle); requireAutoTimeChanged = true; } } // TODO: (b/145604635) Add upgrade case // requireAutoTime is now backed by DISALLOW_CONFIG_DATE_TIME restriction, so propagate // updated restrictions to the framework. if (requireAutoTimeChanged) { pushUserRestrictions(userHandle); } // Turn AUTO_TIME on in settings if it is required if (required) { mInjector.binderWithCleanCallingIdentity( Loading services/tests/servicestests/res/raw/comp_policies_primary.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ <admin name="com.android.frameworks.servicestests/com.android.server.devicepolicy.DummyDeviceAdmins$Admin1"> <policies flags="991"/> <password-history-length value="33" /> <require_auto_time value="true" /> <user-restrictions no_bluetooth="true" /> </admin> </policies> services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -385,6 +385,15 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { assertFalse("User restriction was put into non-parent PO instance", dpm.getUserRestrictions(admin1).containsKey(UserManager.DISALLOW_BLUETOOTH)); assertTrue("User restriction wasn't migrated to PO parent instance", dpms.getProfileOwnerAdminLocked(COPE_PROFILE_USER_ID) .getParentActiveAdmin() .getEffectiveRestrictions() .containsKey(UserManager.DISALLOW_CONFIG_DATE_TIME)); assertFalse("User restriction was put into non-parent PO instance", dpms.getProfileOwnerAdminLocked(COPE_PROFILE_USER_ID) .getEffectiveRestrictions() .containsKey(UserManager.DISALLOW_CONFIG_DATE_TIME)); // TODO(b/143516163): verify more policies. }); } Loading services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −8 Original line number Diff line number Diff line Loading @@ -2032,13 +2032,17 @@ public class DevicePolicyManagerTest extends DpmTestBase { eq(false)); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_CAMERA), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); parentDpm.setCameraDisabled(admin1, false); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); reset(getServices().userManagerInternal); } Loading @@ -2053,7 +2057,9 @@ public class DevicePolicyManagerTest extends DpmTestBase { parentDpm.clearUserRestriction(admin1, restriction); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); } Loading Loading @@ -2088,11 +2094,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { private void assertNoDeviceOwnerRestrictions() { DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), getDeviceOwner().ensureUserRestrictions() ); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), dpm.getUserRestrictions(admin1) getDeviceOwner().getEffectiveRestrictions() ); } Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +13 −5 Original line number Diff line number Diff line Loading @@ -1836,8 +1836,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Bundle addSyntheticRestrictions(Bundle restrictions) { if (disableCamera) { restrictions.putBoolean(UserManager.DISALLOW_CAMERA, true); } else { restrictions.remove(UserManager.DISALLOW_CAMERA); } if (requireAutoTime) { restrictions.putBoolean(UserManager.DISALLOW_CONFIG_DATE_TIME, true); } return restrictions; } Loading @@ -1864,7 +1865,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Bundle getEffectiveRestrictions() { return addSyntheticRestrictions( removeDeprecatedRestrictions(ensureUserRestrictions())); removeDeprecatedRestrictions(new Bundle(ensureUserRestrictions()))); } Bundle getLocalUserRestrictions(int adminType) { Loading Loading @@ -2747,6 +2748,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // The following policies weren't available to PO, but will be available after migration. parentAdmin.disableCamera = doAdmin.disableCamera; parentAdmin.requireAutoTime = doAdmin.requireAutoTime; // TODO(b/143516163): Uncomment once corresponding APIs are available via parent instance. // parentAdmin.disableScreenCapture = doAdmin.disableScreenCapture; // parentAdmin.accountTypesWithManagementDisabled.addAll( Loading Loading @@ -7839,16 +7842,21 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } Objects.requireNonNull(who, "ComponentName is null"); final int userHandle = UserHandle.getCallingUserId(); boolean requireAutoTimeChanged = false; synchronized (getLockObject()) { ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (admin.requireAutoTime != required) { admin.requireAutoTime = required; saveSettingsLocked(userHandle); requireAutoTimeChanged = true; } } // TODO: (b/145604635) Add upgrade case // requireAutoTime is now backed by DISALLOW_CONFIG_DATE_TIME restriction, so propagate // updated restrictions to the framework. if (requireAutoTimeChanged) { pushUserRestrictions(userHandle); } // Turn AUTO_TIME on in settings if it is required if (required) { mInjector.binderWithCleanCallingIdentity( Loading
services/tests/servicestests/res/raw/comp_policies_primary.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ <admin name="com.android.frameworks.servicestests/com.android.server.devicepolicy.DummyDeviceAdmins$Admin1"> <policies flags="991"/> <password-history-length value="33" /> <require_auto_time value="true" /> <user-restrictions no_bluetooth="true" /> </admin> </policies>
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -385,6 +385,15 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { assertFalse("User restriction was put into non-parent PO instance", dpm.getUserRestrictions(admin1).containsKey(UserManager.DISALLOW_BLUETOOTH)); assertTrue("User restriction wasn't migrated to PO parent instance", dpms.getProfileOwnerAdminLocked(COPE_PROFILE_USER_ID) .getParentActiveAdmin() .getEffectiveRestrictions() .containsKey(UserManager.DISALLOW_CONFIG_DATE_TIME)); assertFalse("User restriction was put into non-parent PO instance", dpms.getProfileOwnerAdminLocked(COPE_PROFILE_USER_ID) .getEffectiveRestrictions() .containsKey(UserManager.DISALLOW_CONFIG_DATE_TIME)); // TODO(b/143516163): verify more policies. }); } Loading
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −8 Original line number Diff line number Diff line Loading @@ -2032,13 +2032,17 @@ public class DevicePolicyManagerTest extends DpmTestBase { eq(false)); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_CAMERA), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); parentDpm.setCameraDisabled(admin1, false); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); reset(getServices().userManagerInternal); } Loading @@ -2053,7 +2057,9 @@ public class DevicePolicyManagerTest extends DpmTestBase { parentDpm.clearUserRestriction(admin1, restriction); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), parentDpm.getUserRestrictions(admin1) dpms.getProfileOwnerAdminLocked(DpmMockContext.CALLER_USER_HANDLE) .getParentActiveAdmin() .getEffectiveRestrictions() ); } Loading Loading @@ -2088,11 +2094,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { private void assertNoDeviceOwnerRestrictions() { DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), getDeviceOwner().ensureUserRestrictions() ); DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), dpm.getUserRestrictions(admin1) getDeviceOwner().getEffectiveRestrictions() ); } Loading