Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6732,6 +6732,7 @@ package android.app.admin { method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName); method public boolean getAutoTime(@NonNull android.content.ComponentName); method @Deprecated public boolean getAutoTimeRequired(); method public boolean getAutoTimeZone(@NonNull android.content.ComponentName); method @NonNull public java.util.List<android.os.UserHandle> getBindDeviceAdminTargetUsers(@NonNull android.content.ComponentName); method public boolean getBluetoothContactSharingDisabled(@NonNull android.content.ComponentName); method public boolean getCameraDisabled(@Nullable android.content.ComponentName); Loading Loading @@ -6850,6 +6851,7 @@ package android.app.admin { method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException; method public void setAutoTime(@NonNull android.content.ComponentName, boolean); method @Deprecated public void setAutoTimeRequired(@NonNull android.content.ComponentName, boolean); method public void setAutoTimeZone(@NonNull android.content.ComponentName, boolean); method public void setBackupServiceEnabled(@NonNull android.content.ComponentName, boolean); method public void setBluetoothContactSharingDisabled(@NonNull android.content.ComponentName, boolean); method public void setCameraDisabled(@NonNull android.content.ComponentName, boolean); core/java/android/app/admin/DevicePolicyManager.java +43 −0 Original line number Diff line number Diff line Loading @@ -5809,6 +5809,49 @@ public class DevicePolicyManager { return false; } /** * 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> Loading core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -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); Loading core/proto/android/stats/devicepolicy/device_policy_enums.proto +1 −0 Original line number Diff line number Diff line Loading @@ -152,4 +152,5 @@ enum EventId { CROSS_PROFILE_APPS_GET_TARGET_USER_PROFILES = 125; CROSS_PROFILE_APPS_START_ACTIVITY_AS_USER = 126; SET_AUTO_TIME = 127; SET_AUTO_TIME_ZONE = 128; } services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +37 −1 Original line number Diff line number Diff line Loading @@ -7440,7 +7440,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } /** * Returns whether or auto time is used on the device or not. * Returns whether auto time is used on the device or not. */ @Override public boolean getAutoTime(ComponentName who) { Loading @@ -7453,6 +7453,42 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) > 0; } /** * Set whether auto time zone is enabled on the device. */ @Override public void setAutoTimeZone(ComponentName who, boolean enabled) { if (!mHasFeature) { return; } Preconditions.checkNotNull(who, "ComponentName is null"); // TODO (b/145286957) Refactor security checks enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned(); mInjector.binderWithCleanCallingIdentity(() -> mInjector.settingsGlobalPutInt(Global.AUTO_TIME_ZONE, enabled ? 1 : 0)); DevicePolicyEventLogger .createEvent(DevicePolicyEnums.SET_AUTO_TIME_ZONE) .setAdmin(who) .setBoolean(enabled) .write(); } /** * Returns whether auto time zone is used on the device or not. */ @Override public boolean getAutoTimeZone(ComponentName who) { if (!mHasFeature) { return false; } Preconditions.checkNotNull(who, "ComponentName is null"); enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned(); return mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) > 0; } @Override public void setForceEphemeralUsers(ComponentName who, boolean forceEphemeralUsers) { if (!mHasFeature) { Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6732,6 +6732,7 @@ package android.app.admin { method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName); method public boolean getAutoTime(@NonNull android.content.ComponentName); method @Deprecated public boolean getAutoTimeRequired(); method public boolean getAutoTimeZone(@NonNull android.content.ComponentName); method @NonNull public java.util.List<android.os.UserHandle> getBindDeviceAdminTargetUsers(@NonNull android.content.ComponentName); method public boolean getBluetoothContactSharingDisabled(@NonNull android.content.ComponentName); method public boolean getCameraDisabled(@Nullable android.content.ComponentName); Loading Loading @@ -6850,6 +6851,7 @@ package android.app.admin { method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException; method public void setAutoTime(@NonNull android.content.ComponentName, boolean); method @Deprecated public void setAutoTimeRequired(@NonNull android.content.ComponentName, boolean); method public void setAutoTimeZone(@NonNull android.content.ComponentName, boolean); method public void setBackupServiceEnabled(@NonNull android.content.ComponentName, boolean); method public void setBluetoothContactSharingDisabled(@NonNull android.content.ComponentName, boolean); method public void setCameraDisabled(@NonNull android.content.ComponentName, boolean);
core/java/android/app/admin/DevicePolicyManager.java +43 −0 Original line number Diff line number Diff line Loading @@ -5809,6 +5809,49 @@ public class DevicePolicyManager { return false; } /** * 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> Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
core/proto/android/stats/devicepolicy/device_policy_enums.proto +1 −0 Original line number Diff line number Diff line Loading @@ -152,4 +152,5 @@ enum EventId { CROSS_PROFILE_APPS_GET_TARGET_USER_PROFILES = 125; CROSS_PROFILE_APPS_START_ACTIVITY_AS_USER = 126; SET_AUTO_TIME = 127; SET_AUTO_TIME_ZONE = 128; }
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +37 −1 Original line number Diff line number Diff line Loading @@ -7440,7 +7440,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } /** * Returns whether or auto time is used on the device or not. * Returns whether auto time is used on the device or not. */ @Override public boolean getAutoTime(ComponentName who) { Loading @@ -7453,6 +7453,42 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) > 0; } /** * Set whether auto time zone is enabled on the device. */ @Override public void setAutoTimeZone(ComponentName who, boolean enabled) { if (!mHasFeature) { return; } Preconditions.checkNotNull(who, "ComponentName is null"); // TODO (b/145286957) Refactor security checks enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned(); mInjector.binderWithCleanCallingIdentity(() -> mInjector.settingsGlobalPutInt(Global.AUTO_TIME_ZONE, enabled ? 1 : 0)); DevicePolicyEventLogger .createEvent(DevicePolicyEnums.SET_AUTO_TIME_ZONE) .setAdmin(who) .setBoolean(enabled) .write(); } /** * Returns whether auto time zone is used on the device or not. */ @Override public boolean getAutoTimeZone(ComponentName who) { if (!mHasFeature) { return false; } Preconditions.checkNotNull(who, "ComponentName is null"); enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned(); return mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) > 0; } @Override public void setForceEphemeralUsers(ComponentName who, boolean forceEphemeralUsers) { if (!mHasFeature) { Loading