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
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 44760ce..c9f5f9a 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -754,11 +754,12 @@
     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 @@
         }
     }
 
-    /*
-     * 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;
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 7502e1d..48ed45b 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -219,8 +219,8 @@
     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);
diff --git a/core/java/android/app/admin/OtaPolicy.java b/core/java/android/app/admin/SystemUpdatePolicy.java
similarity index 64%
rename from core/java/android/app/admin/OtaPolicy.java
rename to core/java/android/app/admin/SystemUpdatePolicy.java
index 98581a7..de56cd0 100644
--- a/core/java/android/app/admin/OtaPolicy.java
+++ b/core/java/android/app/admin/SystemUpdatePolicy.java
@@ -23,12 +23,12 @@
 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 @@
         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 @@
 
     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 @@
     }
 
     /**
-     * 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 @@
     }
 
     /**
-     * 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).
+     *            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).
+     *            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 @@
     }
 
     /**
-     * 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 @@
     }
 
     /**
-     * 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 @@
     }
 
     /**
-     * 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 {
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index ec57eba..fca5eda 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -311,7 +311,7 @@
     <protected-broadcast android:name="android.internal.policy.action.BURN_IN_PROTECTION" />
     <protected-broadcast android:name="android.service.persistentdata.action.WIPE_IF_ALLOWED" />
 
-    <protected-broadcast android:name="android.app.action.OTA_POLICY_CHANGED" />
+    <protected-broadcast android:name="android.app.action.SYSTEM_UPDATE_POLICY_CHANGED" />
     <!-- ====================================================================== -->
     <!--                          RUNTIME PERMISSIONS                           -->
     <!-- ====================================================================== -->