Loading core/java/android/app/admin/DevicePolicyManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -3735,13 +3735,13 @@ public class DevicePolicyManager { } /** * Called by a device owner to set whether auto time is required. If auto time is required the * user cannot set the date and time, but has to use network date and time. * Called by a device or profile owner to set whether auto time is required. If auto time is * required, no user will be able set the date and time and network date and time will be used. * <p> * Note: if auto time is required the user can still manually set the time zone. * <p> * The calling device admin must be a device owner. If it is not, a security exception will be * thrown. * The calling device admin must be a device or profile owner. If it is not, a security * exception will be thrown. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param required Whether auto time is set required or not. Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +17 −4 Original line number Diff line number Diff line Loading @@ -5574,7 +5574,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } /** * Set whether auto time is required by the specified admin (must be device owner). * Set whether auto time is required by the specified admin (must be device or profile owner). */ @Override public void setAutoTimeRequired(ComponentName who, boolean required) { Loading @@ -5585,7 +5585,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final int userHandle = UserHandle.getCallingUserId(); synchronized (this) { ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (admin.requireAutoTime != required) { admin.requireAutoTime = required; saveSettingsLocked(userHandle); Loading @@ -5604,7 +5604,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } /** * Returns whether or not auto time is required by the device owner. * Returns whether or not auto time is required by the device owner or any profile owner. */ @Override public boolean getAutoTimeRequired() { Loading @@ -5613,7 +5613,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } synchronized (this) { ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked(); return (deviceOwner != null) ? deviceOwner.requireAutoTime : false; if (deviceOwner != null && deviceOwner.requireAutoTime) { // If the device owner enforces auto time, we don't need to check the PO's return true; } // Now check to see if any profile owner on any user enforces auto time for (Integer userId : mOwners.getProfileOwnerKeys()) { ActiveAdmin profileOwner = getProfileOwnerAdminLocked(userId); if (profileOwner != null && profileOwner.requireAutoTime) { return true; } } return false; } } Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -3735,13 +3735,13 @@ public class DevicePolicyManager { } /** * Called by a device owner to set whether auto time is required. If auto time is required the * user cannot set the date and time, but has to use network date and time. * Called by a device or profile owner to set whether auto time is required. If auto time is * required, no user will be able set the date and time and network date and time will be used. * <p> * Note: if auto time is required the user can still manually set the time zone. * <p> * The calling device admin must be a device owner. If it is not, a security exception will be * thrown. * The calling device admin must be a device or profile owner. If it is not, a security * exception will be thrown. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param required Whether auto time is set required or not. Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +17 −4 Original line number Diff line number Diff line Loading @@ -5574,7 +5574,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } /** * Set whether auto time is required by the specified admin (must be device owner). * Set whether auto time is required by the specified admin (must be device or profile owner). */ @Override public void setAutoTimeRequired(ComponentName who, boolean required) { Loading @@ -5585,7 +5585,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final int userHandle = UserHandle.getCallingUserId(); synchronized (this) { ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (admin.requireAutoTime != required) { admin.requireAutoTime = required; saveSettingsLocked(userHandle); Loading @@ -5604,7 +5604,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } /** * Returns whether or not auto time is required by the device owner. * Returns whether or not auto time is required by the device owner or any profile owner. */ @Override public boolean getAutoTimeRequired() { Loading @@ -5613,7 +5613,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } synchronized (this) { ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked(); return (deviceOwner != null) ? deviceOwner.requireAutoTime : false; if (deviceOwner != null && deviceOwner.requireAutoTime) { // If the device owner enforces auto time, we don't need to check the PO's return true; } // Now check to see if any profile owner on any user enforces auto time for (Integer userId : mOwners.getProfileOwnerKeys()) { ActiveAdmin profileOwner = getProfileOwnerAdminLocked(userId); if (profileOwner != null && profileOwner.requireAutoTime) { return true; } } return false; } } Loading