diff options
| author | Tao Bao <tbao@google.com> | 2016-09-30 20:46:05 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2016-09-30 20:46:05 +0000 |
| commit | ade17dea88b65e96258f6e8b0054a668193f6592 (patch) | |
| tree | 705c4c56124754c13ae2c65d4e13ea093e8ab01e /core/java/android/os/RecoverySystem.java | |
| parent | aa36af0287b3015b2a3f3f0c43ce37087c3a3e48 (diff) | |
| parent | 86df8ecdf3281708a2378b3a3dc41b486885bbc7 (diff) | |
Merge "Handle the race condition when calling uncrypt services." am: 42d25b5992
am: 86df8ecdf3
Change-Id: I1dc6ea14b4de99bf65f9efff4f22c0bd99e2f86f
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
| -rw-r--r-- | core/java/android/os/RecoverySystem.java | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 2d5a144bdfc1..662e14cce49b 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -671,28 +671,22 @@ public class RecoverySystem { * @throws IOException if something goes wrong. */ private static void bootCommand(Context context, String... args) throws IOException { - synchronized (sRequestLock) { - LOG_FILE.delete(); + LOG_FILE.delete(); - StringBuilder command = new StringBuilder(); - for (String arg : args) { - if (!TextUtils.isEmpty(arg)) { - command.append(arg); - command.append("\n"); - } + StringBuilder command = new StringBuilder(); + for (String arg : args) { + if (!TextUtils.isEmpty(arg)) { + command.append(arg); + command.append("\n"); } + } - // Write the command into BCB (bootloader control block). - RecoverySystem rs = (RecoverySystem) context.getSystemService( - Context.RECOVERY_SERVICE); - rs.setupBcb(command.toString()); - - // Having set up the BCB, go ahead and reboot. - PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - pm.reboot(PowerManager.REBOOT_RECOVERY); + // Write the command into BCB (bootloader control block) and boot from + // there. Will not return unless failed. + RecoverySystem rs = (RecoverySystem) context.getSystemService(Context.RECOVERY_SERVICE); + rs.rebootRecoveryWithCommand(command.toString()); - throw new IOException("Reboot failed (no permissions?)"); - } + throw new IOException("Reboot failed (no permissions?)"); } // Read last_install; then report time (in seconds) and I/O (in MiB) for @@ -887,6 +881,17 @@ public class RecoverySystem { } /** + * Talks to RecoverySystemService via Binder to set up the BCB command and + * reboot into recovery accordingly. + */ + private void rebootRecoveryWithCommand(String command) { + try { + mService.rebootRecoveryWithCommand(command); + } catch (RemoteException ignored) { + } + } + + /** * Internally, recovery treats each line of the command file as a separate * argv, so we only need to protect against newlines and nulls. */ |
