Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d562d4d authored by Tao Bao's avatar Tao Bao Committed by Gerrit Code Review
Browse files

Merge "Clean up the uncrypted OTA package on bootup."

parents c2b9c538 87212ad6
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -341,6 +341,10 @@ public class RecoverySystem {
        } 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
@@ -501,6 +505,25 @@ public class RecoverySystem {
            Log.e(TAG, "Error reading recovery log", e);
        }

        if (UNCRYPT_FILE.exists()) {
            String filename = null;
            try {
                filename = FileUtils.readTextFile(UNCRYPT_FILE, 0, null);
            } catch (IOException e) {
                Log.e(TAG, "Error reading uncrypt file", e);
            }

            // Remove the OTA package on /data that has been (possibly
            // partially) processed. (Bug: 24973532)
            if (filename != null && filename.startsWith("/data")) {
                if (UNCRYPT_FILE.delete()) {
                    Log.i(TAG, "Deleted: " + filename);
                } else {
                    Log.e(TAG, "Can't delete: " + filename);
                }
            }
        }

        // Delete everything in RECOVERY_DIR except those beginning
        // with LAST_PREFIX
        String[] names = RECOVERY_DIR.list();