summaryrefslogtreecommitdiff
path: root/core/java/android/os/RecoverySystem.java
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-03-14 17:11:05 -0700
committerTao Bao <tbao@google.com>2016-03-15 10:36:19 -0700
commit36baafe92cdf9139ec9c2215cbe62d6df1b32b3f (patch)
tree377dc0687b72ab1631547fe03b3a6b693dda0e53 /core/java/android/os/RecoverySystem.java
parent658e4c5eceefcb2f0d070d478fb1ab0af27a1bbe (diff)
Don't reboot into recovery if block map file is missing.
We added a third parameter to RecoverySystem.installPackage() to let the caller to indicate the package has been processed (uncrypt'd). We need to ensure the caller's claim is true by checking the existence of the block map. Otherwise the device will fail for sure when booting into recovery. Bug: 27620932 Change-Id: I6325455253480055f14eb0cf020689ac37328602
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
-rw-r--r--core/java/android/os/RecoverySystem.java44
1 files changed, 27 insertions, 17 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index ddcd63520549..b25b33d00aa8 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -434,25 +434,35 @@ public class RecoverySystem {
String filename = packageFile.getCanonicalPath();
Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!");
- if (!processed && filename.startsWith("/data/")) {
- FileWriter uncryptFile = new FileWriter(UNCRYPT_PACKAGE_FILE);
- try {
- uncryptFile.write(filename + "\n");
- } finally {
- uncryptFile.close();
- }
- // UNCRYPT_PACKAGE_FILE needs to be readable and writable by system server.
- if (!UNCRYPT_PACKAGE_FILE.setReadable(true, false)
- || !UNCRYPT_PACKAGE_FILE.setWritable(true, false)) {
- Log.e(TAG, "Error setting permission for " + UNCRYPT_PACKAGE_FILE);
- }
+ // If the package is on the /data partition, the package needs to
+ // be processed (i.e. uncrypt'd). The caller specifies if that has
+ // been done in 'processed' parameter.
+ if (filename.startsWith("/data/")) {
+ if (processed) {
+ if (!BLOCK_MAP_FILE.exists()) {
+ Log.e(TAG, "Package claimed to have been processed but failed to find "
+ + "the block map file.");
+ throw new IOException("Failed to find block map file");
+ }
+ } else {
+ FileWriter uncryptFile = new FileWriter(UNCRYPT_PACKAGE_FILE);
+ try {
+ uncryptFile.write(filename + "\n");
+ } finally {
+ uncryptFile.close();
+ }
+ // UNCRYPT_PACKAGE_FILE needs to be readable and writable
+ // by system server.
+ if (!UNCRYPT_PACKAGE_FILE.setReadable(true, false)
+ || !UNCRYPT_PACKAGE_FILE.setWritable(true, false)) {
+ Log.e(TAG, "Error setting permission for " + UNCRYPT_PACKAGE_FILE);
+ }
- BLOCK_MAP_FILE.delete();
- }
+ BLOCK_MAP_FILE.delete();
+ }
- // If the package is on the /data partition, use the block map file as
- // the package name instead.
- if (filename.startsWith("/data/")) {
+ // If the package is on the /data partition, use the block map
+ // file as the package name instead.
filename = "@/cache/recovery/block.map";
}