Merge "setAutoTimeRequired disabled on managed profile" into rvc-dev

This commit is contained in:
Alex Johnston
2020-05-21 10:08:51 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 1 deletions

View File

@@ -6031,10 +6031,12 @@ public class DevicePolicyManager {
* this API to enforce auto time will result in * this API to enforce auto time will result in
* {@link UserManager#DISALLOW_CONFIG_DATE_TIME} being set, while calling this API to lift * {@link UserManager#DISALLOW_CONFIG_DATE_TIME} being set, while calling this API to lift
* the requirement will result in {@link UserManager#DISALLOW_CONFIG_DATE_TIME} being cleared. * the requirement will result in {@link UserManager#DISALLOW_CONFIG_DATE_TIME} being cleared.
* From Android 11, this API can also no longer be called on a managed profile.
* *
* @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param required Whether auto time is set required or not. * @param required Whether auto time is set required or not.
* @throws SecurityException if {@code admin} is not a device owner. * @throws SecurityException if {@code admin} is not a device owner, not a profile owner or
* if this API is called on a managed profile.
* @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #setAutoTimeEnabled} * @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #setAutoTimeEnabled}
* to turn auto time on or off and use {@link UserManager#DISALLOW_CONFIG_DATE_TIME} * to turn auto time on or off and use {@link UserManager#DISALLOW_CONFIG_DATE_TIME}
* to prevent the user from changing this setting. * to prevent the user from changing this setting.

View File

@@ -7973,6 +7973,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
final int userHandle = UserHandle.getCallingUserId(); final int userHandle = UserHandle.getCallingUserId();
boolean requireAutoTimeChanged = false; boolean requireAutoTimeChanged = false;
synchronized (getLockObject()) { synchronized (getLockObject()) {
if (isManagedProfile(userHandle)) {
throw new SecurityException("Managed profile cannot set auto time required");
}
ActiveAdmin admin = getActiveAdminForCallerLocked(who, ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
if (admin.requireAutoTime != required) { if (admin.requireAutoTime != required) {