From dafced93a56352b79c74b016eba437b28bbbe11e Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 20 Sep 2017 08:37:46 -0700 Subject: [PATCH] bootstat: Do not allow unknown boot reasons to land in first field. If we sniff an unknown boot reason from last kmsg, make sure it has a "reboot," prefix. Test: system/core/bootstat/boot_reason_test.sh Bug: 63736262 Change-Id: Ia1c401b8899d1f0c56bd4f5d8d2d19b7fc889a30 --- bootstat/bootstat.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index da1e9d82f..07d410c91 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -477,8 +477,10 @@ std::string BootReasonStrToReason(const std::string& boot_reason) { if (subReason != "") { // Will not land "reboot" as that is too blunt. if (isKernelRebootReason(subReason)) { ret = "reboot," + subReason; // User space can't talk kernel reasons. - } else { + } else if (isKnownRebootReason(subReason)) { ret = subReason; + } else { + ret = "reboot," + subReason; // legitimize unknown reasons } } }