Log the error when uncrypt timeouts
am: 2a03586998
Change-Id: I9d85069026d777468cb41dcdf5e2ecd83812efb1
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index 90bd11f..0b3abaa 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -93,6 +93,14 @@
*/
public static final File UNCRYPT_PACKAGE_FILE = new File(RECOVERY_DIR, "uncrypt_file");
+ /**
+ * UNCRYPT_STATUS_FILE stores the time cost (and error code in the case of a failure)
+ * of uncrypt.
+ *
+ * @hide
+ */
+ public static final File UNCRYPT_STATUS_FILE = new File(RECOVERY_DIR, "uncrypt_status");
+
// Length limits for reading files.
private static final int LOG_FILE_MAX_LENGTH = 64 * 1024;
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index 8ce2fd9..44894ed 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -717,6 +717,14 @@
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for uncrypt.");
+ final int uncryptTimeoutError = 100;
+ String timeoutMessage = String.format("uncrypt_time: %d\n" + "uncrypt_error: %d\n",
+ MAX_UNCRYPT_WAIT_TIME / 1000, uncryptTimeoutError);
+ try {
+ FileUtils.stringToFile(RecoverySystem.UNCRYPT_STATUS_FILE, timeoutMessage);
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to write timeout message to uncrypt status", e);
+ }
}
}
}