Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5faad8e4 authored by Rubin Xu's avatar Rubin Xu
Browse files

Rename public OTA policy APIs in DevicePolicyManager

Use the term "SystemUpdate" instead of "OTA", in public
DevicePolicyManager APIs that handle OTA policies.

Bug: 19650524
Change-Id: Iebdaea91337d617147cb411b6f47e0f3fae8671c
parent 103d48ec
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -5712,7 +5712,6 @@ package android.app.admin {
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public android.app.admin.OtaPolicy getOtaPolicy();
    method public long getPasswordExpiration(android.content.ComponentName);
    method public long getPasswordExpirationTimeout(android.content.ComponentName);
    method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -5730,6 +5729,7 @@ package android.app.admin {
    method public boolean getScreenCaptureDisabled(android.content.ComponentName);
    method public boolean getStorageEncryption(android.content.ComponentName);
    method public int getStorageEncryptionStatus();
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
@@ -5766,7 +5766,6 @@ package android.app.admin {
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOtaPolicy(android.content.ComponentName, android.app.admin.OtaPolicy);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
    method public void setPasswordMinimumLength(android.content.ComponentName, int);
@@ -5787,6 +5786,7 @@ package android.app.admin {
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public void setStatusBarEnabledState(android.content.ComponentName, boolean);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
    method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);
    method public void setUninstallBlocked(android.content.ComponentName, java.lang.String, boolean);
    method public boolean setUserEnabled(android.content.ComponentName);
@@ -5797,10 +5797,10 @@ package android.app.admin {
    method public void wipeData(int);
    field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_PROVISIONED = "android.app.action.MANAGED_PROFILE_PROVISIONED";
    field public static final java.lang.String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
    field public static final java.lang.String ACTION_PROVISION_MANAGED_PROFILE = "android.app.action.PROVISION_MANAGED_PROFILE";
    field public static final java.lang.String ACTION_SET_NEW_PASSWORD = "android.app.action.SET_NEW_PASSWORD";
    field public static final java.lang.String ACTION_START_ENCRYPTION = "android.app.action.START_ENCRYPTION";
    field public static final java.lang.String ACTION_SYSTEM_UPDATE_POLICY_CHANGED = "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED";
    field public static final int ENCRYPTION_STATUS_ACTIVATING = 2; // 0x2
    field public static final int ENCRYPTION_STATUS_ACTIVE = 3; // 0x3
    field public static final int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY = 4; // 0x4
@@ -5865,21 +5865,21 @@ package android.app.admin {
    field public static final int WIPE_RESET_PROTECTION_DATA = 2; // 0x2
  }
  public class OtaPolicy {
    ctor public OtaPolicy();
  public class SystemUpdatePolicy {
    ctor public SystemUpdatePolicy();
    method public int getInstallWindowEnd();
    method public int getInstallWindowStart();
    method public int getPolicyType();
    method public void setAutomaticInstallPolicy();
    method public void setPostponeInstallPolicy();
    method public void setWindowedInstallPolicy(int, int) throws android.app.admin.OtaPolicy.InvalidWindowException;
    method public void setWindowedInstallPolicy(int, int) throws android.app.admin.SystemUpdatePolicy.InvalidWindowException;
    field public static final int TYPE_INSTALL_AUTOMATIC = 1; // 0x1
    field public static final int TYPE_INSTALL_WINDOWED = 2; // 0x2
    field public static final int TYPE_POSTPONE = 3; // 0x3
  }
  public static class OtaPolicy.InvalidWindowException extends java.lang.Exception {
    ctor public OtaPolicy.InvalidWindowException(java.lang.String);
  public static class SystemUpdatePolicy.InvalidWindowException extends java.lang.Exception {
    ctor public SystemUpdatePolicy.InvalidWindowException(java.lang.String);
  }
}
+8 −8
Original line number Diff line number Diff line
@@ -5811,7 +5811,6 @@ package android.app.admin {
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public android.app.admin.OtaPolicy getOtaPolicy();
    method public long getPasswordExpiration(android.content.ComponentName);
    method public long getPasswordExpirationTimeout(android.content.ComponentName);
    method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -5833,6 +5832,7 @@ package android.app.admin {
    method public boolean getScreenCaptureDisabled(android.content.ComponentName);
    method public boolean getStorageEncryption(android.content.ComponentName);
    method public int getStorageEncryptionStatus();
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
@@ -5870,7 +5870,6 @@ package android.app.admin {
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOtaPolicy(android.content.ComponentName, android.app.admin.OtaPolicy);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
    method public void setPasswordMinimumLength(android.content.ComponentName, int);
@@ -5891,6 +5890,7 @@ package android.app.admin {
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public void setStatusBarEnabledState(android.content.ComponentName, boolean);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
    method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);
    method public void setUninstallBlocked(android.content.ComponentName, java.lang.String, boolean);
    method public boolean setUserEnabled(android.content.ComponentName);
@@ -5901,12 +5901,12 @@ package android.app.admin {
    method public void wipeData(int);
    field public static final java.lang.String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_PROVISIONED = "android.app.action.MANAGED_PROFILE_PROVISIONED";
    field public static final java.lang.String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
    field public static final java.lang.String ACTION_PROVISION_MANAGED_PROFILE = "android.app.action.PROVISION_MANAGED_PROFILE";
    field public static final java.lang.String ACTION_SEND_DEVICE_INITIALIZER_STATUS = "android.app.action.SEND_DEVICE_INITIALIZER_STATUS";
    field public static final java.lang.String ACTION_SET_NEW_PASSWORD = "android.app.action.SET_NEW_PASSWORD";
    field public static final java.lang.String ACTION_SET_PROFILE_OWNER = "android.app.action.SET_PROFILE_OWNER";
    field public static final java.lang.String ACTION_START_ENCRYPTION = "android.app.action.START_ENCRYPTION";
    field public static final java.lang.String ACTION_SYSTEM_UPDATE_POLICY_CHANGED = "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED";
    field public static final int ENCRYPTION_STATUS_ACTIVATING = 2; // 0x2
    field public static final int ENCRYPTION_STATUS_ACTIVE = 3; // 0x3
    field public static final int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY = 4; // 0x4
@@ -5974,21 +5974,21 @@ package android.app.admin {
    field public static final int WIPE_RESET_PROTECTION_DATA = 2; // 0x2
  }
  public class OtaPolicy {
    ctor public OtaPolicy();
  public class SystemUpdatePolicy {
    ctor public SystemUpdatePolicy();
    method public int getInstallWindowEnd();
    method public int getInstallWindowStart();
    method public int getPolicyType();
    method public void setAutomaticInstallPolicy();
    method public void setPostponeInstallPolicy();
    method public void setWindowedInstallPolicy(int, int) throws android.app.admin.OtaPolicy.InvalidWindowException;
    method public void setWindowedInstallPolicy(int, int) throws android.app.admin.SystemUpdatePolicy.InvalidWindowException;
    field public static final int TYPE_INSTALL_AUTOMATIC = 1; // 0x1
    field public static final int TYPE_INSTALL_WINDOWED = 2; // 0x2
    field public static final int TYPE_POSTPONE = 3; // 0x3
  }
  public static class OtaPolicy.InvalidWindowException extends java.lang.Exception {
    ctor public OtaPolicy.InvalidWindowException(java.lang.String);
  public static class SystemUpdatePolicy.InvalidWindowException extends java.lang.Exception {
    ctor public SystemUpdatePolicy.InvalidWindowException(java.lang.String);
  }
}
+21 −20
Original line number Diff line number Diff line
@@ -754,11 +754,12 @@ public class DevicePolicyManager {
    public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 0x0002;

    /**
     * Broadcast action: notify that a new local OTA policy has been set by the device owner.
     * The new policy can be retrieved by {@link #getOtaPolicy()}.
     * Broadcast action: notify that a new local system update policy has been set by the device
     * owner. The new policy can be retrieved by {@link #getSystemUpdatePolicy()}.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_OTA_POLICY_CHANGED = "android.app.action.OTA_POLICY_CHANGED";
    public static final String ACTION_SYSTEM_UPDATE_POLICY_CHANGED
            = "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED";


    /**
@@ -4143,46 +4144,46 @@ public class DevicePolicyManager {
        }
    }

    /*
     * Called by device owners to set a local OTA update policy. When a new OTA policy is set,
     * {@link #ACTION_OTA_POLICY_CHANGED} is broadcasted.
    /**
     * Called by device owners to set a local system update policy. When a new policy is set,
     * {@link #ACTION_SYSTEM_UPDATE_POLICY_CHANGED} is broadcasted.
     *
     * @param who Which {@link DeviceAdminReceiver} this request is associated with. All components
     * in the device owner package can set OTA policies and the most recent policy takes effect.
     * @param policy the new OTA policy, or null to clear the current policy.
     * @see OtaPolicy
     * in the device owner package can set system update policies and the most recent policy takes
     * effect.
     * @param policy the new policy, or null to clear the current policy.
     * @see SystemUpdatePolicy
     */
    public void setOtaPolicy(ComponentName who, OtaPolicy policy) {
    public void setSystemUpdatePolicy(ComponentName who, SystemUpdatePolicy policy) {
        if (mService != null) {
            try {
                if (policy != null) {
                    mService.setOtaPolicy(who, policy.getPolicyBundle());
                    mService.setSystemUpdatePolicy(who, policy.getPolicyBundle());
                } else {
                    mService.setOtaPolicy(who, null);
                    mService.setSystemUpdatePolicy(who, null);
                }
            } catch (RemoteException re) {
                Log.w(TAG, "Error calling setOtaPolicy", re);
                Log.w(TAG, "Error calling setSystemUpdatePolicy", re);
            }
        }
    }

    /**
     * Retrieve a local OTA update policy set previously by {@link #setOtaPolicy}.
     * Retrieve a local system update policy set previously by {@link #setSystemUpdatePolicy}.
     *
     * @return The current OTA policy object, or null if no policy is set or the system does not
     * support managed OTA.
     * @return The current policy object, or null if no policy is set.
     */
    public OtaPolicy getOtaPolicy() {
    public SystemUpdatePolicy getSystemUpdatePolicy() {
        if (mService != null) {
            try {
                PersistableBundle bundle = mService.getOtaPolicy();
                PersistableBundle bundle = mService.getSystemUpdatePolicy();
                if (bundle != null) {
                    return new OtaPolicy(bundle);
                    return new SystemUpdatePolicy(bundle);
                } else {
                    return null;
                }
            } catch (RemoteException re) {
                Log.w(TAG, "Error calling getOtaPolicy", re);
                Log.w(TAG, "Error calling getSystemUpdatePolicy", re);
            }
        }
        return null;
+2 −2
Original line number Diff line number Diff line
@@ -219,8 +219,8 @@ interface IDevicePolicyManager {
    void setUserIcon(in ComponentName admin, in Bitmap icon);

    void sendDeviceInitializerStatus(int statusCode, String description);
    void setOtaPolicy(in ComponentName who, in PersistableBundle policy);
    PersistableBundle getOtaPolicy();
    void setSystemUpdatePolicy(in ComponentName who, in PersistableBundle policy);
    PersistableBundle getSystemUpdatePolicy();

    boolean setKeyguardEnabledState(in ComponentName admin, boolean enabled);
    void setStatusBarEnabledState(in ComponentName who, boolean enabled);
+37 −27
Original line number Diff line number Diff line
@@ -23,12 +23,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * A class that represents a local OTA policy set by the device owner.
 * A class that represents a local system update policy set by the device owner.
 *
 * @see DevicePolicyManager#setOtaPolicy
 * @see DevicePolicyManager#getOtaPolicy
 * @see DevicePolicyManager#setSystemUpdatePolicy
 * @see DevicePolicyManager#getSystemUpdatePolicy
 */
public class OtaPolicy {
public class SystemUpdatePolicy {

    /** @hide */
    @IntDef({
@@ -36,22 +36,27 @@ public class OtaPolicy {
        TYPE_INSTALL_WINDOWED,
        TYPE_POSTPONE})
    @Retention(RetentionPolicy.SOURCE)
    @interface OtaPolicyType {}
    @interface SystemUpdatePolicyType {}

    /**
     * Install OTA update automatically as soon as one is available.
     * Install system update automatically as soon as one is available.
     */
    public static final int TYPE_INSTALL_AUTOMATIC = 1;

    /**
     * Install OTA update automatically within a daily maintenance window, for a maximum of two-week
     * period. After that period the OTA will be installed automatically.
     * Install system update automatically within a daily maintenance window, for a maximum of 30
     * days. After the expiration the policy will no longer be effective and the system should
     * revert back to its normal behavior as if no policy were set. The only exception is
     * {@link #TYPE_INSTALL_AUTOMATIC} which should still take effect to install system update
     * immediately.
     */
    public static final int TYPE_INSTALL_WINDOWED = 2;

    /**
     * Incoming OTA will be blocked for a maximum of two weeks, after which it will be installed
     * automatically.
     * Incoming system update will be blocked for a maximum of 30 days, after which the system
     * should revert back to its normal behavior as if no policy were set. The only exception is
     * {@link #TYPE_INSTALL_AUTOMATIC} which should still take effect to install system update
     * immediately.
     */
    public static final int TYPE_POSTPONE = 3;

@@ -61,15 +66,15 @@ public class OtaPolicy {

    private PersistableBundle mPolicy;

    public  OtaPolicy() {
    public  SystemUpdatePolicy() {
        mPolicy = new PersistableBundle();
    }

    /**
     * Construct an OtaPolicy object from a bundle.
     * Construct an SystemUpdatePolicy object from a bundle.
     * @hide
     */
    public OtaPolicy(PersistableBundle in) {
    public SystemUpdatePolicy(PersistableBundle in) {
        mPolicy = new PersistableBundle(in);
    }

@@ -82,7 +87,9 @@ public class OtaPolicy {
    }

    /**
     * Set the OTA policy to: install OTA update automatically as soon as one is available.
     * Set the policy to: install update automatically as soon as one is available.
     *
     * @see #TYPE_INSTALL_AUTOMATIC
     */
    public void setAutomaticInstallPolicy() {
        mPolicy.clear();
@@ -90,18 +97,19 @@ public class OtaPolicy {
    }

    /**
     * Set the OTA policy to: new OTA update will only be installed automatically when the system
     * Set the policy 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, OTAs can install at any time. If
     * the given window in invalid, a {@link OtaPolicy.InvalidWindowException} will be thrown. If
     * start time is later than end time, the window is considered spanning midnight, i.e. end time
     * donates a time on the next day. The maintenance window will last for two weeks, after which
     * the OTA will be installed automatically.
     * window is considered to include the WHOLE 24 hours, that is, updates can install at any time.
     * If the given window in invalid, a {@link SystemUpdatePolicy.InvalidWindowException} will be
     * thrown. If start time is later than end time, the window is considered spanning midnight,
     * i.e. end time donates a time on the next day. The maintenance window will last for 30 days,
     * after which the system should revert back to its normal behavior as if no policy were set.
     *
     * @param startTime 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).
     * @param endTime 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).
     * @see #TYPE_INSTALL_WINDOWED
     */
    public void setWindowedInstallPolicy(int startTime, int endTime) throws InvalidWindowException{
        if (startTime < 0 || startTime >= 1440 || endTime < 0 || endTime >= 1440) {
@@ -114,8 +122,10 @@ public class OtaPolicy {
    }

    /**
     * Set the OTA policy to: block installation for a maximum period of two weeks. After the
     * block expires the OTA will be installed automatically.
     * Set the policy to: block installation for a maximum period of 30 days. After expiration the
     * system should revert back to its normal behavior as if no policy were set.
     *
     * @see #TYPE_POSTPONE
     */
    public void setPostponeInstallPolicy() {
        mPolicy.clear();
@@ -123,12 +133,12 @@ public class OtaPolicy {
    }

    /**
     * Returns the type of OTA policy.
     * Returns the type of system update policy.
     *
     * @return an integer, either one of {@link #TYPE_INSTALL_AUTOMATIC},
     * {@link #TYPE_INSTALL_WINDOWED} and {@link #TYPE_POSTPONE}, or -1 if no policy has been set.
     */
    @OtaPolicyType
    @SystemUpdatePolicyType
    public int getPolicyType() {
        return mPolicy.getInt(KEY_POLICY_TYPE, -1);
    }
@@ -167,7 +177,7 @@ public class OtaPolicy {
    }

    /**
     * Exception thrown by {@link OtaPolicy#setWindowedInstallPolicy(int, int)} in case the
     * Exception thrown by {@link SystemUpdatePolicy#setWindowedInstallPolicy(int, int)} in case the
     * specified window is invalid.
     */
    public static class InvalidWindowException extends Exception {
Loading