From 3a66fc41e3b1341af37254554610b9e72da4675a Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 9 Jun 2017 15:50:14 -0700 Subject: [PATCH] Fix the issue that uncrypt isn't called under quiescent mode OTA fails on fugu under quiescent mode because the reboot reason changes from "recovery-update" to "recovery-update,quiescent". The new reason isn't checked in shutdown thread so that shutdown thread doesn't call uncrypt properly before rebooting into recovery. Bug: 62324707 Test: Recreated and fixed the "block.map" missing failure on fugu. Change-Id: I110653cd64dbbdc71e89ead2197bf023a7c054e8 --- .../java/com/android/server/power/ShutdownThread.java | 8 +++++--- services/java/com/android/server/SystemServer.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java index 864e83ef1f86e..28ffc94911609 100644 --- a/services/core/java/com/android/server/power/ShutdownThread.java +++ b/services/core/java/com/android/server/power/ShutdownThread.java @@ -256,7 +256,7 @@ public final class ShutdownThread extends Thread { ProgressDialog pd = new ProgressDialog(context); // Path 1: Reboot to recovery for update - // Condition: mReason == REBOOT_RECOVERY_UPDATE + // Condition: mReason startswith REBOOT_RECOVERY_UPDATE // // Path 1a: uncrypt needed // Condition: if /cache/recovery/uncrypt_file exists but @@ -276,7 +276,9 @@ public final class ShutdownThread extends Thread { // Path 3: Regular reboot / shutdown // Condition: Otherwise // UI: spinning circle only (no progress bar) - if (PowerManager.REBOOT_RECOVERY_UPDATE.equals(mReason)) { + + // mReason could be "recovery-update" or "recovery-update,quiescent". + if (mReason != null && mReason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) { // We need the progress bar if uncrypt will be invoked during the // reboot, which might be time-consuming. mRebootHasProgressBar = RecoverySystem.UNCRYPT_PACKAGE_FILE.exists() @@ -295,7 +297,7 @@ public final class ShutdownThread extends Thread { pd.setMessage(context.getText( com.android.internal.R.string.reboot_to_update_reboot)); } - } else if (PowerManager.REBOOT_RECOVERY.equals(mReason)) { + } else if (mReason != null && mReason.equals(PowerManager.REBOOT_RECOVERY)) { // Factory reset path. Set the dialog message accordingly. pd.setTitle(context.getText(com.android.internal.R.string.reboot_to_reset_title)); pd.setMessage(context.getText( diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 6f53099a8627e..cc392712124b0 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -449,7 +449,7 @@ public final class SystemServer { // If '/cache/recovery/block.map' hasn't been created, stop the // reboot which will fail for sure, and get a chance to capture a // bugreport when that's still feasible. (Bug: 26444951) - if (PowerManager.REBOOT_RECOVERY_UPDATE.equals(reason)) { + if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) { File packageFile = new File(UNCRYPT_PACKAGE_FILE); if (packageFile.exists()) { String filename = null;