Loading api/current.txt +4 −2 Original line number Diff line number Diff line Loading @@ -6726,7 +6726,8 @@ package android.app.admin { method @Nullable public String getAlwaysOnVpnPackage(@NonNull android.content.ComponentName); method @NonNull @WorkerThread public android.os.Bundle getApplicationRestrictions(@Nullable android.content.ComponentName, String); method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName); method public boolean getAutoTimeRequired(); method public boolean getAutoTime(@NonNull android.content.ComponentName); method @Deprecated public boolean getAutoTimeRequired(); 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 @@ -6842,7 +6843,8 @@ package android.app.admin { method public boolean setApplicationHidden(@NonNull android.content.ComponentName, String, boolean); method @WorkerThread public void setApplicationRestrictions(@Nullable android.content.ComponentName, String, android.os.Bundle); method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException; method public void setAutoTimeRequired(@NonNull android.content.ComponentName, boolean); method public void setAutoTime(@NonNull android.content.ComponentName, boolean); method @Deprecated public void setAutoTimeRequired(@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 +53 −0 Original line number Diff line number Diff line Loading @@ -5696,11 +5696,21 @@ public class DevicePolicyManager { * <p> * The calling device admin must be a device owner, or alternatively a profile owner from * Android 8.0 (API level 26) or higher. If it is not, a security exception will be thrown. * <p> * Staring from Android 11, this API switches to use * {@link UserManager#DISALLOW_CONFIG_DATE_TIME} to enforce the auto time settings. Calling * this API to enforce auto time will result in * {@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. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param required Whether auto time is set required or not. * @throws SecurityException if {@code admin} is not a device owner. * @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #setAutoTime} * to turn auto time on or off and use {@link UserManager#DISALLOW_CONFIG_DATE_TIME} * to prevent the user from changing this setting. */ @Deprecated public void setAutoTimeRequired(@NonNull ComponentName admin, boolean required) { throwIfParentInstance("setAutoTimeRequired"); if (mService != null) { Loading @@ -5714,7 +5724,9 @@ public class DevicePolicyManager { /** * @return true if auto time is required. * @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #getAutoTime} */ @Deprecated public boolean getAutoTimeRequired() { throwIfParentInstance("getAutoTimeRequired"); if (mService != null) { Loading @@ -5727,6 +5739,47 @@ 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 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. Instead, the network date * and time will be used. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param enabled Whether time 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 setAutoTime(@NonNull ComponentName admin, boolean enabled) { if (mService != null) { try { mService.setAutoTime(admin, enabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** * @return true if auto time 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 getAutoTime(@NonNull ComponentName admin) { if (mService != null) { try { return mService.getAutoTime(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 @@ -295,6 +295,9 @@ interface IDevicePolicyManager { void setAutoTimeRequired(in ComponentName who, boolean required); boolean getAutoTimeRequired(); void setAutoTime(in ComponentName who, boolean enabled); boolean getAutoTime(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 @@ -151,4 +151,5 @@ enum EventId { PROVISIONING_FLOW_TYPE = 124; CROSS_PROFILE_APPS_GET_TARGET_USER_PROFILES = 125; CROSS_PROFILE_APPS_START_ACTIVITY_AS_USER = 126; SET_AUTO_TIME = 127; } packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +0 −17 Original line number Diff line number Diff line Loading @@ -407,23 +407,6 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils { ? enforcedAdmin : null; } /** * Checks if {@link android.app.admin.DevicePolicyManager#setAutoTimeRequired} is enforced * on the device. * * @return EnforcedAdmin Object containing the device owner component and * userId the device owner is running as, or {@code null} setAutoTimeRequired is not enforced. */ public static EnforcedAdmin checkIfAutoTimeRequired(Context context) { DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm == null || !dpm.getAutoTimeRequired()) { return null; } ComponentName adminComponent = dpm.getDeviceOwnerComponentOnCallingUser(); return new EnforcedAdmin(adminComponent, getUserHandleOf(UserHandle.myUserId())); } /** * Checks if an admin has enforced minimum password quality requirements on the given user. * Loading Loading
api/current.txt +4 −2 Original line number Diff line number Diff line Loading @@ -6726,7 +6726,8 @@ package android.app.admin { method @Nullable public String getAlwaysOnVpnPackage(@NonNull android.content.ComponentName); method @NonNull @WorkerThread public android.os.Bundle getApplicationRestrictions(@Nullable android.content.ComponentName, String); method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName); method public boolean getAutoTimeRequired(); method public boolean getAutoTime(@NonNull android.content.ComponentName); method @Deprecated public boolean getAutoTimeRequired(); 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 @@ -6842,7 +6843,8 @@ package android.app.admin { method public boolean setApplicationHidden(@NonNull android.content.ComponentName, String, boolean); method @WorkerThread public void setApplicationRestrictions(@Nullable android.content.ComponentName, String, android.os.Bundle); method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException; method public void setAutoTimeRequired(@NonNull android.content.ComponentName, boolean); method public void setAutoTime(@NonNull android.content.ComponentName, boolean); method @Deprecated public void setAutoTimeRequired(@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 +53 −0 Original line number Diff line number Diff line Loading @@ -5696,11 +5696,21 @@ public class DevicePolicyManager { * <p> * The calling device admin must be a device owner, or alternatively a profile owner from * Android 8.0 (API level 26) or higher. If it is not, a security exception will be thrown. * <p> * Staring from Android 11, this API switches to use * {@link UserManager#DISALLOW_CONFIG_DATE_TIME} to enforce the auto time settings. Calling * this API to enforce auto time will result in * {@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. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param required Whether auto time is set required or not. * @throws SecurityException if {@code admin} is not a device owner. * @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #setAutoTime} * to turn auto time on or off and use {@link UserManager#DISALLOW_CONFIG_DATE_TIME} * to prevent the user from changing this setting. */ @Deprecated public void setAutoTimeRequired(@NonNull ComponentName admin, boolean required) { throwIfParentInstance("setAutoTimeRequired"); if (mService != null) { Loading @@ -5714,7 +5724,9 @@ public class DevicePolicyManager { /** * @return true if auto time is required. * @deprecated From {@link android.os.Build.VERSION_CODES#R}. Use {@link #getAutoTime} */ @Deprecated public boolean getAutoTimeRequired() { throwIfParentInstance("getAutoTimeRequired"); if (mService != null) { Loading @@ -5727,6 +5739,47 @@ 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 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. Instead, the network date * and time will be used. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param enabled Whether time 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 setAutoTime(@NonNull ComponentName admin, boolean enabled) { if (mService != null) { try { mService.setAutoTime(admin, enabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** * @return true if auto time 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 getAutoTime(@NonNull ComponentName admin) { if (mService != null) { try { return mService.getAutoTime(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 @@ -295,6 +295,9 @@ interface IDevicePolicyManager { void setAutoTimeRequired(in ComponentName who, boolean required); boolean getAutoTimeRequired(); void setAutoTime(in ComponentName who, boolean enabled); boolean getAutoTime(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 @@ -151,4 +151,5 @@ enum EventId { PROVISIONING_FLOW_TYPE = 124; CROSS_PROFILE_APPS_GET_TARGET_USER_PROFILES = 125; CROSS_PROFILE_APPS_START_ACTIVITY_AS_USER = 126; SET_AUTO_TIME = 127; }
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +0 −17 Original line number Diff line number Diff line Loading @@ -407,23 +407,6 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils { ? enforcedAdmin : null; } /** * Checks if {@link android.app.admin.DevicePolicyManager#setAutoTimeRequired} is enforced * on the device. * * @return EnforcedAdmin Object containing the device owner component and * userId the device owner is running as, or {@code null} setAutoTimeRequired is not enforced. */ public static EnforcedAdmin checkIfAutoTimeRequired(Context context) { DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm == null || !dpm.getAutoTimeRequired()) { return null; } ComponentName adminComponent = dpm.getDeviceOwnerComponentOnCallingUser(); return new EnforcedAdmin(adminComponent, getUserHandleOf(UserHandle.myUserId())); } /** * Checks if an admin has enforced minimum password quality requirements on the given user. * Loading