diff options
author | Pat Erley <perley@cyngn.com> | 2016-05-20 14:35:13 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-23 17:58:48 -0700 |
commit | ed671ae44aa112b15607731f057f988bde679a5a (patch) | |
tree | 44d823e17ab2f5f81a317c4fcb1f8c4981953df4 /core | |
parent | 2b21b18e109ddab30d7a0ff47dd900e55167ec37 (diff) | |
download | frameworks_base-ed671ae44aa112b15607731f057f988bde679a5a.zip frameworks_base-ed671ae44aa112b15607731f057f988bde679a5a.tar.gz frameworks_base-ed671ae44aa112b15607731f057f988bde679a5a.tar.bz2 |
Only call uncrypt when we're encrypted
We were always generating a block map for encrypted update, even
when the device was not encrypted. This leads to a spectacular
failure. Fix this by only calling uncrypt when we're encrypted.
Additionally, only pass block.map as the update file in the case
that the device was encrypted and requires it.
NIGHTLIES-3012
Change-Id: Ia34eb5115ac4365605fd57f76179854a6042c5e4
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/RecoverySystem.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 4b6e6c1..a10b1ec 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -335,22 +335,27 @@ public class RecoverySystem { throws IOException { String filename = packageFile.getCanonicalPath(); - FileWriter uncryptFile = new FileWriter(UNCRYPT_FILE); - try { - uncryptFile.write(filename + "\n"); - } finally { - uncryptFile.close(); - } - // UNCRYPT_FILE needs to be readable by system server on bootup. - if (!UNCRYPT_FILE.setReadable(true, false)) { - Log.e(TAG, "Error setting readable for " + UNCRYPT_FILE.getCanonicalPath()); - } - Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!"); + final String cryptoStatus = SystemProperties.get("ro.crypto.state", "unsupported"); + final boolean isEncrypted = "encrypted".equalsIgnoreCase(cryptoStatus); - // If the package is on the /data partition, write the block map file - // into COMMAND_FILE instead. - if (filename.startsWith("/data/")) { - filename = "@/cache/recovery/block.map"; + if (isEncrypted) { + FileWriter uncryptFile = new FileWriter(UNCRYPT_FILE); + try { + uncryptFile.write(filename + "\n"); + } finally { + uncryptFile.close(); + } + // UNCRYPT_FILE needs to be readable by system server on bootup. + if (!UNCRYPT_FILE.setReadable(true, false)) { + Log.e(TAG, "Error setting readable for " + UNCRYPT_FILE.getCanonicalPath()); + } + Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!"); + + // If the package is on the /data partition, write the block map file + // into COMMAND_FILE instead. + if (filename.startsWith("/data/")) { + filename = "@/cache/recovery/block.map"; + } } final String filenameArg = "--update_package=" + filename; |