BootReceiver: add ro.boot.bootreason property to SYSTEM_LAST_KMSG
Instead of requiring the kernel to join last_kmsg and the reboot
reason together, allow both to be passed to userspace and have
userspace combine them the way the log parsers want them.
Existing devices with no ro.boot.bootreason property and kernel
support for putting the reason in last_kmsg will continue to
use the kernel's formatting.
Bug: 13813279
Change-Id: I079b0107feb1533c6a54044ca6a114741127dfbc
(cherry picked from commit 431614cb6b)
This commit is contained in:
committed by
Simon Wilson
parent
5119f6e6db
commit
aa943d1b2d
@@ -106,22 +106,33 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
.append("Kernel: ")
|
||||
.append(FileUtils.readTextFile(new File("/proc/version"), 1024, "...\n"))
|
||||
.append("\n").toString();
|
||||
final String bootReason = SystemProperties.get("ro.boot.bootreason", null);
|
||||
|
||||
String recovery = RecoverySystem.handleAftermath();
|
||||
if (recovery != null && db != null) {
|
||||
db.addText("SYSTEM_RECOVERY_LOG", headers + recovery);
|
||||
}
|
||||
|
||||
String lastKmsgFooter = "";
|
||||
if (bootReason != null) {
|
||||
lastKmsgFooter = new StringBuilder(512)
|
||||
.append("\n")
|
||||
.append("Boot info:\n")
|
||||
.append("Last boot reason: ").append(bootReason).append("\n")
|
||||
.toString();
|
||||
}
|
||||
|
||||
if (SystemProperties.getLong("ro.runtime.firstboot", 0) == 0) {
|
||||
String now = Long.toString(System.currentTimeMillis());
|
||||
SystemProperties.set("ro.runtime.firstboot", now);
|
||||
if (db != null) db.addText("SYSTEM_BOOT", headers);
|
||||
|
||||
// Negative sizes mean to take the *tail* of the file (see FileUtils.readTextFile())
|
||||
addFileToDropBox(db, prefs, headers, "/proc/last_kmsg",
|
||||
-LOG_SIZE, "SYSTEM_LAST_KMSG");
|
||||
addFileToDropBox(db, prefs, headers, "/sys/fs/pstore/console-ramoops",
|
||||
-LOG_SIZE, "SYSTEM_LAST_KMSG");
|
||||
addFileWithFootersToDropBox(db, prefs, headers, lastKmsgFooter,
|
||||
"/proc/last_kmsg", -LOG_SIZE, "SYSTEM_LAST_KMSG");
|
||||
addFileWithFootersToDropBox(db, prefs, headers, lastKmsgFooter,
|
||||
"/sys/fs/pstore/console-ramoops", -LOG_SIZE,
|
||||
"SYSTEM_LAST_KMSG");
|
||||
addFileToDropBox(db, prefs, headers, "/cache/recovery/log",
|
||||
-LOG_SIZE, "SYSTEM_RECOVERY_LOG");
|
||||
addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_console",
|
||||
@@ -161,6 +172,14 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
private static void addFileToDropBox(
|
||||
DropBoxManager db, SharedPreferences prefs,
|
||||
String headers, String filename, int maxSize, String tag) throws IOException {
|
||||
addFileWithFootersToDropBox(db, prefs, headers, "", filename, maxSize,
|
||||
tag);
|
||||
}
|
||||
|
||||
private static void addFileWithFootersToDropBox(
|
||||
DropBoxManager db, SharedPreferences prefs,
|
||||
String headers, String footers, String filename, int maxSize,
|
||||
String tag) throws IOException {
|
||||
if (db == null || !db.isTagEnabled(tag)) return; // Logging disabled
|
||||
|
||||
File file = new File(filename);
|
||||
@@ -176,7 +195,7 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
|
||||
db.addText(tag, headers + FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n"));
|
||||
db.addText(tag, headers + FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n") + footers);
|
||||
}
|
||||
|
||||
private static void addAuditErrorsToDropBox(DropBoxManager db, SharedPreferences prefs,
|
||||
|
||||
Reference in New Issue
Block a user