Merge "Upgrade case for setAutoTimeRequired" into rvc-dev am: 0131d50188 am: 12e5a4f03d
Change-Id: Idd86c174bef0ffa75e09152d63ef62401fff33b6
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -1864,7 +1865,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
|
||||
Bundle getEffectiveRestrictions() {
|
||||
return addSyntheticRestrictions(
|
||||
removeDeprecatedRestrictions(ensureUserRestrictions()));
|
||||
removeDeprecatedRestrictions(new Bundle(ensureUserRestrictions())));
|
||||
}
|
||||
|
||||
Bundle getLocalUserRestrictions(int adminType) {
|
||||
@@ -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(
|
||||
@@ -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(
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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.
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user