From 036d08638e6a5f849847a32d794ad34d7dec1368 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Sat, 24 Sep 2016 15:39:56 -0700 Subject: [PATCH] Log the error when uncrypt timeouts Log the error code to uncrypt_status if uncrypt gets killed because of timeout. Test: We log the error code correctly in uncrypt_status when uncrypt timeouts. Bug: 31603820 Change-Id: Ia623c333714295e68f4269257fbb4297a867e42b --- core/java/android/os/RecoverySystem.java | 8 ++++++++ .../java/com/android/server/power/ShutdownThread.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 028e30ab93f02..2d5a144bdfc14 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -93,6 +93,14 @@ public class RecoverySystem { */ 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 5b9d139a3e0e6..f7f79f324ecca 100644 --- a/services/core/java/com/android/server/power/ShutdownThread.java +++ b/services/core/java/com/android/server/power/ShutdownThread.java @@ -716,6 +716,14 @@ public final class ShutdownThread extends Thread { } 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); + } } } }