add reboot() method to PowerManager
In order to unbundle System Update, we need some to expose in the SDK
some way to reboot the device into recovery. Add a reboot() method to
PowerManager, protected by the android.permission.REBOOT permission.
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 444c8de..0e22f86 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -59,6 +59,7 @@
import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN;
import java.io.FileDescriptor;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -2091,6 +2092,20 @@
}
/**
+ * Reboot the device immediately, passing 'reason' (may be null)
+ * to the underlying __reboot system call. Should not return.
+ */
+ public void reboot(String reason)
+ {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
+ try {
+ Power.reboot(reason);
+ } catch (IOException e) {
+ Log.e(TAG, "reboot failed", e);
+ }
+ }
+
+ /**
* Returns the time the screen has been on since boot, in millis.
* @return screen on time
*/