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
This commit is contained in:
Mark Salyzyn 2017-09-20 08:37:46 -07:00
parent 88d692c09e
commit dafced93a5
1 changed files with 3 additions and 1 deletions

View File

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