Move REBOOT_READY broadcast into Device Scheduling

Moves the definition of the REBOOT_READY broadcast into
the Device Scheduling module.

Test: atest CtsRebootReadinessTestCases
Test: atest RebootReadinessHostTest
Bug: 183938070
Change-Id: Iabf45065a204d983efa0d310d842bec9b3c963c9
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index 54146cc..5b76cd4 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -7,6 +7,8 @@
     method @RequiresPermission(android.Manifest.permission.REBOOT) public boolean isReadyToReboot();
     method @RequiresPermission(android.Manifest.permission.REBOOT) public void markRebootPending();
     method @RequiresPermission(android.Manifest.permission.SIGNAL_REBOOT_READINESS) public void removeRequestRebootReadinessStatusListener(@NonNull android.scheduling.RebootReadinessManager.RequestRebootReadinessStatusListener);
+    field public static final String ACTION_REBOOT_READY = "android.scheduling.action.REBOOT_READY";
+    field public static final String EXTRA_IS_READY_TO_REBOOT = "android.scheduling.extra.IS_READY_TO_REBOOT";
   }
 
   public static final class RebootReadinessManager.RebootReadinessStatus {
diff --git a/framework/java/android/scheduling/RebootReadinessManager.java b/framework/java/android/scheduling/RebootReadinessManager.java
index dc27d0b..b25d947 100644
--- a/framework/java/android/scheduling/RebootReadinessManager.java
+++ b/framework/java/android/scheduling/RebootReadinessManager.java
@@ -20,10 +20,10 @@
 import android.annotation.CurrentTimeMillisLong;
 import android.annotation.NonNull;
 import android.annotation.RequiresPermission;
+import android.annotation.SdkConstant;
 import android.annotation.SystemApi;
 import android.annotation.SystemService;
 import android.content.Context;
-import android.content.Intent;
 import android.os.Bundle;
 import android.os.RemoteCallback;
 import android.os.RemoteException;
@@ -41,8 +41,8 @@
  * an updater has notified this service that there is a pending update that requires a reboot, this
  * service will periodically check several signals which contribute to the reboot readiness
  * decision. When the device's reboot-readiness changes, a
- * {@link Intent#ACTION_REBOOT_READY} broadcast will be sent. The associated extra
- * {@link Intent#EXTRA_IS_READY_TO_REBOOT} will be {@code true} when the device is ready to reboot,
+ * {@link #ACTION_REBOOT_READY} broadcast will be sent. The associated extra
+ * {@link #EXTRA_IS_READY_TO_REBOOT} will be {@code true} when the device is ready to reboot,
  * and {@code false} when it is not ready to reboot.
  *
  * <p>Subsystems may register callbacks with this service. These callbacks allow subsystems to
@@ -63,6 +63,33 @@
             RebootReadinessCallbackProxy> mProxyList = new ArrayMap<>();
 
     /**
+     * Broadcast Action: Indicates that the device's reboot readiness has changed.
+     *
+     * <p>This broadcast will be sent with an extra that indicates whether or not the device is
+     * ready to reboot.
+     * <p>
+     * The receiver <em>must</em> have the {@link android.Manifest.permission#REBOOT} permission.
+     * <p class="note">
+     * This is a protected intent that can only be sent by the system.
+     *
+     * @see #EXTRA_IS_READY_TO_REBOOT
+     * @hide
+     */
+    @SystemApi
+    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_REBOOT_READY = "android.scheduling.action.REBOOT_READY";
+
+    /**
+     * A boolean extra used with {@link #ACTION_REBOOT_READY} which indicates if the
+     * device is ready to reboot.
+     * Will be {@code true} if ready to reboot, {@code false} otherwise.
+     * @hide
+     */
+    @SystemApi
+    public static final String EXTRA_IS_READY_TO_REBOOT =
+            "android.scheduling.extra.IS_READY_TO_REBOOT";
+
+    /**
      * Key used to communicate between {@link RebootReadinessManager} and the system server,
      * indicating the reboot readiness of a component that has registered a
      * {@link RequestRebootReadinessStatusListener}. The associated value is a boolean.
@@ -224,8 +251,8 @@
      * Notifies the RebootReadinessManager that there is a pending update that requires a reboot to
      * be applied.
      *
-     * <p>When the device's reboot-readiness changes, a {@link Intent#ACTION_REBOOT_READY} broadcast
-     * will be sent. The associated extra {@link Intent#EXTRA_IS_READY_TO_REBOOT} will be
+     * <p>When the device's reboot-readiness changes, a {@link #ACTION_REBOOT_READY} broadcast
+     * will be sent. The associated extra {@link #EXTRA_IS_READY_TO_REBOOT} will be
      * {@code true} when the device is ready to reboot, and {@code false} when it is not ready to
      * reboot.
      *
diff --git a/service/java/com/android/server/scheduling/RebootReadinessManagerService.java b/service/java/com/android/server/scheduling/RebootReadinessManagerService.java
index afa5372..7d3af42 100644
--- a/service/java/com/android/server/scheduling/RebootReadinessManagerService.java
+++ b/service/java/com/android/server/scheduling/RebootReadinessManagerService.java
@@ -429,8 +429,8 @@
         synchronized (mLock) {
             Log.i(TAG, "Reboot readiness state changed to " + isReadyToReboot);
             mReadyToReboot = isReadyToReboot;
-            Intent intent = new Intent(Intent.ACTION_REBOOT_READY);
-            intent.putExtra(Intent.EXTRA_IS_READY_TO_REBOOT, isReadyToReboot);
+            Intent intent = new Intent(RebootReadinessManager.ACTION_REBOOT_READY);
+            intent.putExtra(RebootReadinessManager.EXTRA_IS_READY_TO_REBOOT, isReadyToReboot);
 
             // Send state change broadcast to any packages which have a pending update
             for (int i = 0; i < mCallingUidToPackageMap.size(); i++) {
diff --git a/tests/hostsidetests/testapp/src/com/android/tests/scheduling/RebootReadinessTest.java b/tests/hostsidetests/testapp/src/com/android/tests/scheduling/RebootReadinessTest.java
index 607bb01..d21162b 100644
--- a/tests/hostsidetests/testapp/src/com/android/tests/scheduling/RebootReadinessTest.java
+++ b/tests/hostsidetests/testapp/src/com/android/tests/scheduling/RebootReadinessTest.java
@@ -54,12 +54,13 @@
         BroadcastReceiver receiver = new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
-                if (intent.getBooleanExtra(Intent.EXTRA_IS_READY_TO_REBOOT, false)) {
+                if (intent.getBooleanExtra(
+                        RebootReadinessManager.EXTRA_IS_READY_TO_REBOOT, false)) {
                     latch.countDown();
                 }
             }
         };
-        IntentFilter filter = new IntentFilter(Intent.ACTION_REBOOT_READY);
+        IntentFilter filter = new IntentFilter(RebootReadinessManager.ACTION_REBOOT_READY);
         InstrumentationRegistry.getContext().registerReceiver(receiver, filter);
         if (rebootReadinessManager != null) {
             rebootReadinessManager.markRebootPending();
diff --git a/tests/src/com/android/cts/scheduling/RebootReadinessManagerTest.java b/tests/src/com/android/cts/scheduling/RebootReadinessManagerTest.java
index 86d8d08..d7beaba 100644
--- a/tests/src/com/android/cts/scheduling/RebootReadinessManagerTest.java
+++ b/tests/src/com/android/cts/scheduling/RebootReadinessManagerTest.java
@@ -147,14 +147,15 @@
             boolean mExpectedExtra = true;
             @Override
             public void onReceive(Context context, Intent intent) {
-                boolean extra = intent.getBooleanExtra(Intent.EXTRA_IS_READY_TO_REBOOT, false);
+                boolean extra = intent.getBooleanExtra(
+                        RebootReadinessManager.EXTRA_IS_READY_TO_REBOOT, false);
                 assertThat(extra).isEqualTo(mExpectedExtra);
                 mExpectedExtra = !mExpectedExtra;
                 latch.countDown();
             }
         };
         InstrumentationRegistry.getContext().registerReceiver(receiver,
-                new IntentFilter(Intent.ACTION_REBOOT_READY));
+                new IntentFilter(RebootReadinessManager.ACTION_REBOOT_READY));
         mRebootReadinessManager.addRequestRebootReadinessStatusListener(
                 sHandlerExecutor, READY_CALLBACK);
         assertThat(isReadyToReboot()).isTrue();
@@ -216,7 +217,7 @@
             }
         };
         InstrumentationRegistry.getContext().registerReceiver(receiver,
-                new IntentFilter(Intent.ACTION_REBOOT_READY));
+                new IntentFilter(RebootReadinessManager.ACTION_REBOOT_READY));
         mRebootReadinessManager.removeRequestRebootReadinessStatusListener(BLOCKING_CALLBACK);
 
         // Ensure that no broadcast is received when reboot readiness checks are canceled.