diff options
author | Doug Zongker <dougz@android.com> | 2014-01-14 12:29:06 -0800 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2014-01-16 12:54:59 -0800 |
commit | 3b0218b0ae1fad67f539ff3c10d6d2f3abec1a11 (patch) | |
tree | b3c4fb8ceb77dc98aad753f617c78ade054665e9 /services/core/java | |
parent | 09d30981f8e882ffaa336aa4665bfe348557895a (diff) | |
download | frameworks_base-3b0218b0ae1fad67f539ff3c10d6d2f3abec1a11.zip frameworks_base-3b0218b0ae1fad67f539ff3c10d6d2f3abec1a11.tar.gz frameworks_base-3b0218b0ae1fad67f539ff3c10d6d2f3abec1a11.tar.bz2 |
boot into recovery via the pre-recovery service
Change PowerManagerService to start the pre-recovery service rather
than rebooting directly, when requested to reboot into recovery. Add
a new RECOVERY permission which a caller needs (in addition to REBOOT)
in order to go to recovery.
Bug: 12188746
Change-Id: I39121b701c4724558fe751adfbad79f8567faa43
Diffstat (limited to 'services/core/java')
-rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 7f03cc0..3692d76 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -1830,9 +1830,10 @@ public final class PowerManagerService extends com.android.server.SystemService } /** - * Low-level function to reboot the device. On success, this function - * doesn't return. If more than 5 seconds passes from the time, - * a reboot is requested, this method returns. + * Low-level function to reboot the device. On success, this + * function doesn't return. If more than 20 seconds passes from + * the time a reboot is requested (120 seconds for reboot to + * recovery), this method returns. * * @param reason code to pass to the kernel (e.g. "recovery"), or null. */ @@ -1840,9 +1841,24 @@ public final class PowerManagerService extends com.android.server.SystemService if (reason == null) { reason = ""; } - SystemProperties.set("sys.powerctl", "reboot," + reason); + long duration; + if (reason.equals(PowerManager.REBOOT_RECOVERY)) { + // If we are rebooting to go into recovery, instead of + // setting sys.powerctl directly we'll start the + // pre-recovery service which will do some preparation for + // recovery and then reboot for us. + // + // This preparation can take more than 20 seconds if + // there's a very large update package, so lengthen the + // timeout. + SystemProperties.set("ctl.start", "pre-recovery"); + duration = 120 * 1000L; + } else { + SystemProperties.set("sys.powerctl", "reboot," + reason); + duration = 20 * 1000L; + } try { - Thread.sleep(20000); + Thread.sleep(duration); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } @@ -2524,6 +2540,9 @@ public final class PowerManagerService extends com.android.server.SystemService @Override // Binder call public void reboot(boolean confirm, String reason, boolean wait) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null); + if (PowerManager.REBOOT_RECOVERY.equals(reason)) { + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.RECOVERY, null); + } final long ident = Binder.clearCallingIdentity(); try { |