bootstat: reboot cold, warm and hard tests failed
If the bootloader insists on reporting reboot for cold, warm and
hard, we need to reconstruct canonical reason from the
persist.sys.boot.reason property.
Some log lines contained bootstate, letting their noise through
during testing, changed regex to look for bootstat[^e].
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I3788c6cf8aca7fc73dd01bf95acb596d18ed7ee4
diff --git a/bootstat/boot_reason_test.sh b/bootstat/boot_reason_test.sh
index d789808..52411d8 100755
--- a/bootstat/boot_reason_test.sh
+++ b/bootstat/boot_reason_test.sh
@@ -162,7 +162,7 @@
fi
done
adb logcat -b all -d |
- grep bootstat |
+ grep bootstat[^e] |
grep -v -F "bootstat: Service started: /system/bin/bootstat --record_boot_complete${match}
bootstat: Failed to read /data/misc/bootstat/post_decrypt_time_elapsed: No such file or directory
bootstat: Failed to parse boot time record: /data/misc/bootstat/post_decrypt_time_elapsed
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 3b8b707..e7f9c11 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -494,7 +494,8 @@
// String is either "reboot,<reason>" or "shutdown,<reason>".
// We will set if default reasons, only override with detail if thermal.
- if (!isBluntRebootReason(content)) {
+ if ((android::base::StartsWith(content, ret.c_str()) && (content[ret.length()] == ',')) ||
+ !isBluntRebootReason(content)) {
// Ok, we want it, let's squash it if secondReason is known.
pos = content.find(',');
if (pos != std::string::npos) {