Skip to content

Most visited

Recently visited

navigation

SystemUpdatePolicy

public class SystemUpdatePolicy
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.admin.SystemUpdatePolicy


A class that represents a local system update policy set by the device owner.

See also:

Summary

Nested classes

class SystemUpdatePolicy.ValidationFailedException

An exception class that represents various validation errors thrown from setFreezePeriods(List>) and setSystemUpdatePolicy(ComponentName, SystemUpdatePolicy)  

Constants

int TYPE_INSTALL_AUTOMATIC

Install system update automatically as soon as one is available.

int TYPE_INSTALL_WINDOWED

Install system update automatically within a daily maintenance window.

int TYPE_POSTPONE

Incoming system updates (except for security updates) will be blocked for a maximum of 30 days, after which the policy will no longer be effective and the system will revert back to its normal behavior as if no policy were set.

Inherited constants

Fields

public static final Creator<SystemUpdatePolicy> CREATOR

Public methods

static SystemUpdatePolicy createAutomaticInstallPolicy()

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

static SystemUpdatePolicy createPostponeInstallPolicy()

Create a policy object and set it to block installation for a maximum period of 30 days.

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.

int describeContents()

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

List<Pair<IntegerInteger>> getFreezePeriods()

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

int getInstallWindowEnd()

Get the end of the maintenance window.

int getInstallWindowStart()

Get the start of the maintenance window.

int getPolicyType()

Returns the type of system update policy.

SystemUpdatePolicy setFreezePeriods(List<Pair<IntegerInteger>> freezePeriods)

Configure a list of freeze periods on top of the current policy.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

TYPE_INSTALL_AUTOMATIC

added in API level 23
int TYPE_INSTALL_AUTOMATIC

Install system update automatically as soon as one is available.

Constant Value: 1 (0x00000001)

TYPE_INSTALL_WINDOWED

added in API level 23
int TYPE_INSTALL_WINDOWED

Install system update automatically within a daily maintenance window. An update can be delayed for a maximum of 30 days, after which the policy will no longer be effective and the system will revert back to its normal behavior as if no policy were set.

After this policy expires, resetting it to any policy other than TYPE_INSTALL_AUTOMATIC will produce no effect, as the 30-day maximum delay has already been used up. The TYPE_INSTALL_AUTOMATIC policy will still take effect to install the delayed system update immediately.

Re-applying this policy or changing it to TYPE_POSTPONE within the 30-day period will not extend policy expiration. However, the expiration will be recalculated when a new system update is made available.

Constant Value: 2 (0x00000002)

TYPE_POSTPONE

added in API level 23
int TYPE_POSTPONE

Incoming system updates (except for security updates) will be blocked for a maximum of 30 days, after which the policy will no longer be effective and the system will revert back to its normal behavior as if no policy were set.

Note: security updates (e.g. monthly security patches) may not be affected by this policy, depending on the policy set by the device manufacturer and carrier.

After this policy expires, resetting it to any policy other than TYPE_INSTALL_AUTOMATIC will produce no effect, as the 30-day maximum delay has already been used up. The TYPE_INSTALL_AUTOMATIC policy will still take effect to install the delayed system update immediately.

Re-applying this policy or changing it to TYPE_INSTALL_WINDOWED within the 30-day period will not extend policy expiration. However, the expiration will be recalculated when a new system update is made available.

Constant Value: 3 (0x00000003)

Fields

CREATOR

added in API level 23
Creator<SystemUpdatePolicy> CREATOR

Public methods

createAutomaticInstallPolicy

added in API level 23
SystemUpdatePolicy createAutomaticInstallPolicy ()

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

Returns
SystemUpdatePolicy

createPostponeInstallPolicy

added in API level 23
SystemUpdatePolicy createPostponeInstallPolicy ()

Create a policy object and set it to block installation for a maximum period of 30 days. After expiration the system will revert back to its normal behavior as if no policy were set.

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

Returns
SystemUpdatePolicy

See also:

createWindowedInstallPolicy

added in API level 23
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 the given window in invalid, an IllegalArgumentException will be thrown. 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, after which the system will revert back to its normal behavior as if no policy were set.

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).

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).

Returns
SystemUpdatePolicy

describeContents

added in API level 23
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 writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getFreezePeriods

List<Pair<IntegerInteger>> getFreezePeriods ()

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

Returns
List<Pair<IntegerInteger>> the list of freeze periods, or an empty list if none was set.

getInstallWindowEnd

added in API level 23
int getInstallWindowEnd ()

Get the end of the maintenance window.

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.

getInstallWindowStart

added in API level 23
int getInstallWindowStart ()

Get the start of the maintenance window.

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.

getPolicyType

added in API level 23
int getPolicyType ()

Returns the type of system update policy.

Returns
int an integer, either one of TYPE_INSTALL_AUTOMATIC, TYPE_INSTALL_WINDOWED and TYPE_POSTPONE, or -1 if no policy has been set.

Value is TYPE_INSTALL_AUTOMATIC, TYPE_INSTALL_WINDOWED or TYPE_POSTPONE.

setFreezePeriods

SystemUpdatePolicy setFreezePeriods (List<Pair<IntegerInteger>> 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 freeze period is defined by a starting and finishing date (both inclusive). Since the freeze period repeats annually, both of these dates are simply represented by integers counting the number of days since year start, similar to getDayOfYear(). We do not consider leap year when handling freeze period so the valid range of the integer is always [1,365] (see last section for more details on leap year). If the finishing date is smaller than the starting date, the freeze period is considered to be spanning across year-end.

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 SystemUpdatePolicy.ValidationFailedException will be thrown.

Handling of leap year: we do not consider leap year when handling freeze period, in particular,

  • When a freeze period is defined by the day of year, February 29th does not count as one day, so day 59 is February 28th while day 60 is March 1st.
  • 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.

Parameters
freezePeriods List: the list of freeze periods

Returns
SystemUpdatePolicy this instance

Throws
SystemUpdatePolicy.ValidationFailedException if the supplied freeze periods do not meet the requirement set above

toString

added in API level 23
String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

added in API level 23
void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)