DevicePolicyManager.SetSystemUpdatePolicy Method

Definition

Called by device owners or profile owners of an organization-owned managed profile to to set a local system update policy.

[Android.Runtime.Register("setSystemUpdatePolicy", "(Landroid/content/ComponentName;Landroid/app/admin/SystemUpdatePolicy;)V", "GetSetSystemUpdatePolicy_Landroid_content_ComponentName_Landroid_app_admin_SystemUpdatePolicy_Handler", ApiSince=23)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_SYSTEM_UPDATES")]
public virtual void SetSystemUpdatePolicy (Android.Content.ComponentName admin, Android.App.Admin.SystemUpdatePolicy? policy);
[<Android.Runtime.Register("setSystemUpdatePolicy", "(Landroid/content/ComponentName;Landroid/app/admin/SystemUpdatePolicy;)V", "GetSetSystemUpdatePolicy_Landroid_content_ComponentName_Landroid_app_admin_SystemUpdatePolicy_Handler", ApiSince=23)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_SYSTEM_UPDATES")>]
abstract member SetSystemUpdatePolicy : Android.Content.ComponentName * Android.App.Admin.SystemUpdatePolicy -> unit
override this.SetSystemUpdatePolicy : Android.Content.ComponentName * Android.App.Admin.SystemUpdatePolicy -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with. All components in the package can set system update policies and the most recent policy takes effect. This should be null if the caller is not a device admin.

policy
SystemUpdatePolicy

the new policy, or null to clear the current policy.

Attributes

Remarks

Called by device owners or profile owners of an organization-owned managed profile to to set a local system update policy. When a new policy is set, #ACTION_SYSTEM_UPDATE_POLICY_CHANGED is broadcast.

If the supplied system update policy has freeze periods set but the freeze periods do not meet 90-day maximum length or 60-day minimum separation requirement set out in SystemUpdatePolicy#setFreezePeriods, SystemUpdatePolicy.ValidationFailedException will the thrown. Note that the system keeps a record of freeze periods the device experienced previously, and combines them with the new freeze periods to be set when checking the maximum freeze length and minimum freeze separation constraints. As a result, freeze periods that passed validation during SystemUpdatePolicy#setFreezePeriods might fail the additional checks here due to the freeze period history. If this is causing issues during development, adb shell dpm clear-freeze-period-record can be used to clear the record.

Java documentation for android.app.admin.DevicePolicyManager.setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to