summaryrefslogtreecommitdiff
path: root/core/java/android/os/RecoverySystem.java
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-01-13 09:45:14 -0800
committerTao Bao <tbao@google.com>2017-01-13 09:59:38 -0800
commit9f7a0acd2d383b825bcdcbef25d6b42f9875acfe (patch)
tree269220d6598eb263f36f25da1cdcd2da6f5abe55 /core/java/android/os/RecoverySystem.java
parent0938b22c0ab3f28acfcbcc4099b93dc0a43a691a (diff)
RecoverySystem: Fix the issue in installPackage().
Commit 794c8b0b3fe16051843c22232d58d6b184dde49b fixed the race condition when requesting data wipes via uncrypt. We have similar issue with RecoverySystem.installPackage(). It first requests to set up the BCB, then triggers a reboot. These two steps should finish atomically. This CL switches to calling RecoverySystemService.rebootRecoveryWithCommand(), which guards the two steps with synchronized blocks. Bug: 34239871 Test: Having two apps: one calls RecoverySystem.cancelScheduledUpdate() continuously, and the other calls RecoverySystem.installPackage() just once. The install request should not be cancelled by the other. Change-Id: I5ec56fcaa70eae7c33e3cc8e6cfc7472b935ce4e
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
-rw-r--r--core/java/android/os/RecoverySystem.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index d48431afe691..7f9ea438cb95 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -491,15 +491,10 @@ public class RecoverySystem {
command += securityArg;
}
+ // RECOVERY_SERVICE writes to BCB (bootloader control block) and triggers the reboot.
RecoverySystem rs = (RecoverySystem) context.getSystemService(
Context.RECOVERY_SERVICE);
- if (!rs.setupBcb(command)) {
- throw new IOException("Setup BCB failed");
- }
-
- // Having set up the BCB (bootloader control block), go ahead and reboot
- PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
- pm.reboot(PowerManager.REBOOT_RECOVERY_UPDATE);
+ rs.rebootRecoveryWithCommand(command, true /* update */);
throw new IOException("Reboot failed (no permissions?)");
}
@@ -713,7 +708,7 @@ public class RecoverySystem {
// 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());
+ rs.rebootRecoveryWithCommand(command.toString(), false);
throw new IOException("Reboot failed (no permissions?)");
}
@@ -913,9 +908,9 @@ public class RecoverySystem {
* Talks to RecoverySystemService via Binder to set up the BCB command and
* reboot into recovery accordingly.
*/
- private void rebootRecoveryWithCommand(String command) {
+ private void rebootRecoveryWithCommand(String command, boolean update) {
try {
- mService.rebootRecoveryWithCommand(command);
+ mService.rebootRecoveryWithCommand(command, update);
} catch (RemoteException ignored) {
}
}