OSDN Git Service

Fix reboot dialog messages
authorMichael Bestas <mikeioannina@gmail.com>
Sat, 7 Nov 2015 21:52:26 +0000 (23:52 +0200)
committerMichael Bestas <mikeioannina@gmail.com>
Thu, 5 Jan 2017 11:30:12 +0000 (13:30 +0200)
* Fix mismerge
* Fix wrong messages being displayed when rebooting to recovery

Change-Id: I09a04cc82d48539e8086fd55c30d6160c292bc08

services/core/java/com/android/server/power/ShutdownThread.java

index df39ab3..7f09b56 100644 (file)
@@ -94,7 +94,11 @@ public final class ShutdownThread extends Thread {
     private static Object sIsStartedGuard = new Object();
     private static boolean sIsStarted = false;
 
+    // recovery command
+    private static File RECOVERY_COMMAND_FILE = new File("/cache/recovery/command");
+
     private static boolean mReboot;
+    private static boolean mRebootWipe = false;
     private static boolean mRebootSafeMode;
     private static boolean mRebootHasProgressBar;
     private static String mReason;
@@ -363,6 +367,13 @@ public final class ShutdownThread extends Thread {
         //   Condition: Otherwise
         //   UI: spinning circle only (no progress bar)
         if (PowerManager.REBOOT_RECOVERY_UPDATE.equals(mReason)) {
+            if (RECOVERY_COMMAND_FILE.exists()) {
+                try {
+                    mRebootWipe = new String(FileUtils.readTextFile(
+                            RECOVERY_COMMAND_FILE, 0, null)).contains("wipe");
+                    } catch (IOException e) {
+                }
+            }
             // We need the progress bar if uncrypt will be invoked during the
             // reboot, which might be time-consuming.
             mRebootHasProgressBar = RecoverySystem.UNCRYPT_PACKAGE_FILE.exists()
@@ -381,7 +392,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 (PowerManager.REBOOT_RECOVERY.equals(mReason) && mRebootWipe) {
             // 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(
@@ -396,8 +407,6 @@ public final class ShutdownThread extends Thread {
                 pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
             }
 
-            pd.setTitle(context.getText(com.android.internal.R.string.power_off));
-            pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
             pd.setIndeterminate(true);
         }
         pd.setCancelable(false);