Enable system service to notify device owners about pending update

Create a DevicePolicyManager API which can be used by OTA subsystem
to tell device owners about pending updates. Device owners will get
a callback from its DeviceAdminReceiver when the update service sends
out such notifications.

Bug: 20213644
Change-Id: Ifcc755655e4f441980cf77d76175a046112ca9ae
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 9e2da61..a20aa668 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -4301,4 +4301,24 @@
             Log.w(TAG, "Failed talking with device policy service", re);
         }
     }
+
+    /**
+     * Callable by the system update service to notify device owners about pending updates.
+     * The caller must hold {@link android.Manifest.permission#NOTIFY_PENDING_SYSTEM_UPDATE}
+     * permission.
+     *
+     * @param updateReceivedTime The time as given by {@link System#currentTimeMillis()} indicating
+     *        when the current pending update was first available. -1 if no update is available.
+     * @hide
+     */
+    @SystemApi
+    public void notifyPendingSystemUpdate(long updateReceivedTime) {
+        if (mService != null) {
+            try {
+                mService.notifyPendingSystemUpdate(updateReceivedTime);
+            } catch (RemoteException re) {
+                Log.w(TAG, "Could not notify device owner about pending system update", re);
+            }
+        }
+    }
 }