Merge changes If35518c0,I04bede0b
am: bda0a3e637
Change-Id: I9561d358eb5e43b68011758009ae9bfcc19f5624
diff --git a/bootstat/boot_reason_test.sh b/bootstat/boot_reason_test.sh
index 603d04f..86e8789 100755
--- a/bootstat/boot_reason_test.sh
+++ b/bootstat/boot_reason_test.sh
@@ -429,6 +429,8 @@
*thermal* ) var="shutdown,thermal" ;;
*s3_wakeup* ) var="warm,s3_wakeup" ;;
*hw_reset* ) var="hard,hw_reset" ;;
+ *usb* ) var="cold,charger" ;;
+ *rtc* ) var="cold,rtc" ;;
*bootloader* ) var="bootloader" ;;
* ) var="reboot" ;;
esac
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 5ca3bd4..cfea6ee 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -289,6 +289,8 @@
{"oem_sdi_err_fatal", 145},
{"pmic_watchdog", 146},
{"software_master", 147},
+ {"cold,charger", 148},
+ {"cold,rtc", 149},
};
// Converts a string value representing the reason the system booted to an
@@ -582,7 +584,9 @@
// first member is the output
// second member is an unanchored regex for an alias
//
- // We match a needle on output. This helps keep the scale of the
+ // If output has a prefix of <bang> '!', we do not use it as a
+ // match needle (and drop the <bang> prefix when landing in output),
+ // otherwise look for it as well. This helps keep the scale of the
// following table smaller.
static const std::vector<std::pair<const std::string, const std::string>> aliasReasons = {
{"watchdog", "wdog"},
@@ -591,17 +595,20 @@
{"shutdown,thermal", "thermal"},
{"warm,s3_wakeup", "s3_wakeup"},
{"hard,hw_reset", "hw_reset"},
+ {"cold,charger", "usb"},
+ {"cold,rtc", "rtc"},
{"reboot,2sec", "2sec_reboot"},
{"bootloader", ""},
};
for (auto& s : aliasReasons) {
- if (reason.find(s.first) != std::string::npos) {
+ size_t firstHasNot = s.first[0] == '!';
+ if (!firstHasNot && (reason.find(s.first) != std::string::npos)) {
ret = s.first;
break;
}
if (s.second.size() && std::regex_search(reason, std::regex(s.second))) {
- ret = s.first;
+ ret = s.first.substr(firstHasNot);
break;
}
}