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
(cherry picked from commit 036d08638e)
This commit is contained in:
Tianjie Xu
2016-09-24 15:39:56 -07:00
parent 0f53f6ffa2
commit 2a03586998
2 changed files with 16 additions and 0 deletions

View File

@@ -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;

View File

@@ -717,6 +717,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);
}
}
}
}