diff options
| author | Alex Johnston <acjohnston@google.com> | 2019-12-12 15:34:35 +0000 |
|---|---|---|
| committer | Alex Johnston <acjohnston@google.com> | 2019-12-16 14:57:50 +0000 |
| commit | a44d7296a1395d974978a86186da1c1505b3ce8c (patch) | |
| tree | 3f57ca4a1e683f447185a4983a5d6b5a15ff7036 /core/java | |
| parent | f707567c6bb154aabfd03dfbc7bd5ef3af45cb58 (diff) | |
Add new APIs setAutoTimeZone and getAutoTimeZone
* Added new API methods setAutoTimeZone and getAutoTimeZone.
* DPCs are recommended to combine these new APIs together with the DISALLOW_CONFIG_DATE_TIME
restriction to prevent the user from changing auto time zone settings.
* The new methods can also be called by the WP PO (COPE mode).
Bug: 138709470
Test: Manual testing with testdpc and the set auto time zone toggle
atest com.android.server.devicepolicy.DevicePolicyManagerTest
atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testSetAutoTimeZone
atest com.android.cts.devicepolicy.ManagedProfileTest#testParentProfileApiDisabled
Change-Id: I841d31f76a848e9679d2d9087426e1d5bb7efd1d
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 43 | ||||
| -rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 915e4572c035..e8027b49acd8 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -5805,6 +5805,49 @@ public class DevicePolicyManager { } /** + * Called by a device owner, a profile owner for the primary user or a profile + * owner of an organization-owned managed profile to turn auto time zone on and off. + * Callers are recommended to use {@link UserManager#DISALLOW_CONFIG_DATE_TIME} + * to prevent the user from changing this setting. + * <p> + * If user restriction {@link UserManager#DISALLOW_CONFIG_DATE_TIME} is used, + * no user will be able set the date and time zone. Instead, the network date + * and time zone will be used. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param enabled Whether time zone should be obtained automatically from the network or not. + * @throws SecurityException if caller is not a device owner, a profile owner for the + * primary user, or a profile owner of an organization-owned managed profile. + */ + public void setAutoTimeZone(@NonNull ComponentName admin, boolean enabled) { + throwIfParentInstance("setAutoTimeZone"); + if (mService != null) { + try { + mService.setAutoTimeZone(admin, enabled); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + } + + /** + * @return true if auto time zone is enabled on the device. + * @throws SecurityException if caller is not a device owner, a profile owner for the + * primary user, or a profile owner of an organization-owned managed profile. + */ + public boolean getAutoTimeZone(@NonNull ComponentName admin) { + throwIfParentInstance("getAutoTimeZone"); + if (mService != null) { + try { + return mService.getAutoTimeZone(admin); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + return false; + } + + /** * Called by a device owner to set whether all users created on the device should be ephemeral. * <p> * The system user is exempt from this policy - it is never ephemeral. diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 34246fa808bd..e6efcc233479 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -298,6 +298,9 @@ interface IDevicePolicyManager { void setAutoTime(in ComponentName who, boolean enabled); boolean getAutoTime(in ComponentName who); + void setAutoTimeZone(in ComponentName who, boolean enabled); + boolean getAutoTimeZone(in ComponentName who); + void setForceEphemeralUsers(in ComponentName who, boolean forceEpehemeralUsers); boolean getForceEphemeralUsers(in ComponentName who); |
