Merge ""view recovery logs" will show /tmp/recovery.log" am: c158cf0a14 am: 4e4474c9c5

am: e254b4e9e4

Change-Id: Iedaed39a62f9756c0dc8122a40ea7db2c21f1c30
This commit is contained in:
Tianjie Xu
2016-08-17 22:13:12 +00:00
committed by android-build-merger
+36 -31
View File
@@ -1001,45 +1001,50 @@ static bool wipe_ab_device(size_t wipe_package_size) {
} }
static void choose_recovery_file(Device* device) { static void choose_recovery_file(Device* device) {
if (!has_cache) {
ui->Print("No /cache partition found.\n");
return;
}
// "Back" + KEEP_LOG_COUNT * 2 + terminating nullptr entry // "Back" + KEEP_LOG_COUNT * 2 + terminating nullptr entry
char* entries[1 + KEEP_LOG_COUNT * 2 + 1]; char* entries[1 + KEEP_LOG_COUNT * 2 + 1];
memset(entries, 0, sizeof(entries)); memset(entries, 0, sizeof(entries));
unsigned int n = 0; unsigned int n = 0;
// Add LAST_LOG_FILE + LAST_LOG_FILE.x if (has_cache) {
// Add LAST_KMSG_FILE + LAST_KMSG_FILE.x // Add LAST_LOG_FILE + LAST_LOG_FILE.x
for (int i = 0; i < KEEP_LOG_COUNT; i++) { // Add LAST_KMSG_FILE + LAST_KMSG_FILE.x
char* log_file; for (int i = 0; i < KEEP_LOG_COUNT; i++) {
int ret; char* log_file;
ret = (i == 0) ? asprintf(&log_file, "%s", LAST_LOG_FILE) : int ret;
asprintf(&log_file, "%s.%d", LAST_LOG_FILE, i); ret = (i == 0) ? asprintf(&log_file, "%s", LAST_LOG_FILE) :
if (ret == -1) { asprintf(&log_file, "%s.%d", LAST_LOG_FILE, i);
// memory allocation failure - return early. Should never happen. if (ret == -1) {
return; // memory allocation failure - return early. Should never happen.
} return;
if ((ensure_path_mounted(log_file) != 0) || (access(log_file, R_OK) == -1)) { }
free(log_file); if ((ensure_path_mounted(log_file) != 0) || (access(log_file, R_OK) == -1)) {
} else { free(log_file);
entries[n++] = log_file; } else {
} entries[n++] = log_file;
}
char* kmsg_file; char* kmsg_file;
ret = (i == 0) ? asprintf(&kmsg_file, "%s", LAST_KMSG_FILE) : ret = (i == 0) ? asprintf(&kmsg_file, "%s", LAST_KMSG_FILE) :
asprintf(&kmsg_file, "%s.%d", LAST_KMSG_FILE, i); asprintf(&kmsg_file, "%s.%d", LAST_KMSG_FILE, i);
if (ret == -1) { if (ret == -1) {
// memory allocation failure - return early. Should never happen. // memory allocation failure - return early. Should never happen.
return; return;
}
if ((ensure_path_mounted(kmsg_file) != 0) || (access(kmsg_file, R_OK) == -1)) {
free(kmsg_file);
} else {
entries[n++] = kmsg_file;
}
} }
if ((ensure_path_mounted(kmsg_file) != 0) || (access(kmsg_file, R_OK) == -1)) { } else {
free(kmsg_file); // If cache partition is not found, view /tmp/recovery.log instead.
} else { ui->Print("No /cache partition found.\n");
entries[n++] = kmsg_file; if (access(TEMPORARY_LOG_FILE, R_OK) == -1) {
return;
} else{
entries[n++] = strdup(TEMPORARY_LOG_FILE);
} }
} }