Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#nestedclasses) \| [Constants](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#constants) \| [Inherited Constants](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#inhconstants) \| [Fields](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#lfields) \| [Methods](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#inhmethods)

# SystemUpdatePolicy

*** ** * ** ***


`
public

final

class
SystemUpdatePolicy
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.admin.SystemUpdatePolicy |

<br />

*** ** * ** ***

Determines when over-the-air system updates are installed on a device. Only a device policy
controller (DPC) running in device owner mode or in profile owner mode for an organization-owned
device can set an update policy for the device by calling the `DevicePolicyManager` method
`https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setSystemUpdatePolicy(android.content.ComponentName,%20android.app.admin.SystemUpdatePolicy)`. An update policy
affects the pending system update (if there is one) and any future updates for the device.

If a policy is set on a device, the system doesn't notify the user about updates.

### Example

The example below shows how a DPC might set a maintenance window for system updates:

    private final MAINTENANCE_WINDOW_START = 1380; // 11pm
    private final MAINTENANCE_WINDOW_END = 120; // 2am

    // ...

    // Create the system update policy
    SystemUpdatePolicy policy = SystemUpdatePolicy.createWindowedInstallPolicy(
        MAINTENANCE_WINDOW_START, MAINTENANCE_WINDOW_END);

    // Get a DevicePolicyManager instance to set the policy on the device
    DevicePolicyManager dpm =
        (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    ComponentName adminComponent = getComponentName(context);
    dpm.setSystemUpdatePolicy(adminComponent, policy);

### Developer guide

To learn more, read [Manage system updates](https://developer.android.com/work/dpc/system-updates).

**Note:** [Google Play system updates](https://source.android.com/docs/core/ota/modular-system) (also called Mainline updates) are automatically downloaded but
require a device reboot to be installed. Refer to the mainline section in [Manage system updates](https://developer.android.com/work/dpc/system-updates#mainline) for further details.
**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setSystemUpdatePolicy(android.content.ComponentName,%20android.app.admin.SystemUpdatePolicy)`
- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getSystemUpdatePolicy()`

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy.ValidationFailedException` An exception class that represents various validation errors thrown from `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#setFreezePeriods(java.util.List<android.app.admin.FreezePeriod>)` and `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setSystemUpdatePolicy(android.content.ComponentName,%20android.app.admin.SystemUpdatePolicy)` |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_AUTOMATIC` Installs system updates (without user interaction) as soon as they become available. |
| `int` | `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_WINDOWED` Installs system updates (without user interaction) during a daily maintenance window. |
| `int` | `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_POSTPONE` Postpones the installation of system updates for 30 days. |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that
the Parcelable object's flattened representation includes a file descriptor.


`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written
is a return value, that is the result of a function such as
"`Parcelable someFunction()`",
"`void someFunction(out Parcelable)`", or
"`void someFunction(inout Parcelable)`".


| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy>` | `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#CREATOR` |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#createAutomaticInstallPolicy()() ` Create a policy object and set it to install update automatically as soon as one is available. |
| ` static https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#createPostponeInstallPolicy()() ` Create a policy object and set it to block installation for a maximum period of 30 days. |
| ` static https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#createWindowedInstallPolicy(int,%20int)(int startTime, int endTime) ` Create a policy object and set it to: new system update will only be installed automatically when the system clock is inside a daily maintenance window. |
| ` int` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/admin/FreezePeriod>` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#getFreezePeriods()() ` Returns the list of freeze periods previously set on this system update policy object. |
| ` int` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#getInstallWindowEnd()() ` Get the end of the maintenance window. |
| ` int` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#getInstallWindowStart()() ` Get the start of the maintenance window. |
| ` int` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#getPolicyType()() ` Returns the type of system update policy, or -1 if no policy has been set. |
| ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#setFreezePeriods(java.util.List<android.app.admin.FreezePeriod>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/admin/FreezePeriod> freezePeriods) ` Configure a list of freeze periods on top of the current policy. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/android/os/Parcelable

` `
abstract


int` `
https://developer.android.com/reference/android/os/Parcelable#describeContents()()
`

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.


`
abstract


void` `
https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags)
`

Flatten this object in to a Parcel.


## Constants

### TYPE_INSTALL_AUTOMATIC

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_INSTALL_AUTOMATIC
```

Installs system updates (without user interaction) as soon as they become available. Setting
this policy type immediately installs any pending updates that might be postponed or waiting
for a maintenance window.

<br />

Constant Value:

1
(0x00000001)


### TYPE_INSTALL_WINDOWED

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_INSTALL_WINDOWED
```

Installs system updates (without user interaction) during a daily maintenance window. Set the
start and end of the daily maintenance window, as minutes of the day, when creating a new
`TYPE_INSTALL_WINDOWED` policy. See `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#createWindowedInstallPolicy(int,%20int)`.

No connectivity, not enough disk space, or a low battery are typical reasons Android might
not install a system update in the daily maintenance window. After 30 days trying to install
an update in the maintenance window (regardless of policy changes in this period), the system
prompts the device user to install the update.

<br />

Constant Value:

2
(0x00000002)


### TYPE_POSTPONE

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_POSTPONE
```

Postpones the installation of system updates for 30 days. After the 30-day period has ended,
the system prompts the device user to install the update.

The system limits each update to one 30-day postponement. The period begins when the
system first postpones the update and setting new `TYPE_POSTPONE` policies won\\u2019t extend
the period. If, after 30 days the update isn't installed (through policy changes), the system
prompts the user to install the update.

**Note**: Device manufacturers or carriers might choose to exempt important
security updates from a postponement policy. Exempted updates notify the device user when
they become available.

<br />

Constant Value:

3
(0x00000003)


## Fields

### CREATOR

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<SystemUpdatePolicy> CREATOR
```

<br />

<br />

## Public methods

### createAutomaticInstallPolicy

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static SystemUpdatePolicy createAutomaticInstallPolicy ()
```

Create a policy object and set it to install update automatically as soon as one is
available.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_AUTOMATIC`

### createPostponeInstallPolicy

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static SystemUpdatePolicy createPostponeInstallPolicy ()
```

Create a policy object and set it to block installation for a maximum period of 30 days. To
learn more about this policy's behavior, see `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_POSTPONE`.

**Note:** security updates (e.g. monthly security patches) will *not* be affected
by this policy.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_POSTPONE`

### createWindowedInstallPolicy

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static SystemUpdatePolicy createWindowedInstallPolicy (int startTime, 
                int endTime)
```

Create a policy object and set it to: new system update will only be installed automatically
when the system clock is inside a daily maintenance window. If the start and end times are
the same, the window is considered to include the *whole 24 hours*. That is, updates can
install at any time. If start time is later than end time, the window is considered spanning
midnight (i.e. the end time denotes a time on the next day). The maintenance window will last
for 30 days for any given update, after which the window will no longer be effective and the
pending update will be made available for manual installation as if no system update policy
were set on the device. See `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_WINDOWED` for the details of this policy's
behavior.

<br />

| Parameters ||
|---|---|
| `startTime` | `int`: the start of the maintenance window, measured as the number of minutes from midnight in the device's local time. Must be in the range of \[0, 1440). <br /> |
| `endTime` | `int`: the end of the maintenance window, measured as the number of minutes from midnight in the device's local time. Must be in the range of \[0, 1440). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | The configured policy. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the `startTime` or `endTime` isn't in the accepted range. |

**See also:**

- `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_WINDOWED`

### describeContents

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getFreezePeriods

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<FreezePeriod> getFreezePeriods ()
```

Returns the list of freeze periods previously set on this system update policy object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/admin/FreezePeriod>` | the list of freeze periods, or an empty list if none was set. <br /> |

### getInstallWindowEnd

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getInstallWindowEnd ()
```

Get the end of the maintenance window.

<br />

| Returns ||
|---|---|
| `int` | the end of the maintenance window measured as the number of minutes from midnight, or -1 if the policy does not have a maintenance window. <br /> |

### getInstallWindowStart

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getInstallWindowStart ()
```

Get the start of the maintenance window.

<br />

| Returns ||
|---|---|
| `int` | the start of the maintenance window measured as the number of minutes from midnight, or -1 if the policy does not have a maintenance window. <br /> |

### getPolicyType

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getPolicyType ()
```

Returns the type of system update policy, or -1 if no policy has been set.

<br />

| Returns ||
|---|---|
| `int` | The policy type or -1 if the type isn't set. Value is one of the following: - `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_AUTOMATIC` - `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_INSTALL_WINDOWED` - `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy#TYPE_POSTPONE` |

### setFreezePeriods

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SystemUpdatePolicy setFreezePeriods (List<FreezePeriod> freezePeriods)
```

Configure a list of freeze periods on top of the current policy. When the device's clock is
within any of the freeze periods, all incoming system updates including security patches will
be blocked and cannot be installed. When the device is outside the freeze periods, the normal
policy behavior will apply.

Each individual freeze period is allowed to be at most 90 days long, and adjacent freeze
periods need to be at least 60 days apart. Also, the list of freeze periods should not
contain duplicates or overlap with each other. If any of these conditions is not met, a
`https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy.ValidationFailedException` will be thrown.

Handling of leap year: we ignore leap years in freeze period calculations, in particular,

- When a freeze period is defined, February 29th is disregarded so even though a freeze period can be specified to start or end on February 29th, it will be treated as if the period started or ended on February 28th.
- When applying freeze period behavior to the device, a system clock of February 29th is treated as if it were February 28th
- When calculating the number of days of a freeze period or separation between two freeze periods, February 29th is also ignored and not counted as one day.

<br />

<br />

| Parameters ||
|---|---|
| `freezePeriods` | `List`: the list of freeze periods <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy` | this instance <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/SystemUpdatePolicy.ValidationFailedException` | if the supplied freeze periods do not meet the requirement set above |

### toString

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |