Merge "bootstat: Special case logging for empty boot reason." am: b93357bdb2
am: 79afacdd61
Change-Id: I9200df2994145b581616353990a98e4924b2a79b
This commit is contained in:
commit
1d617f8325
1 changed files with 16 additions and 2 deletions
|
@ -129,6 +129,7 @@ void SetProperty(const char* key, const char* val) {
|
|||
property_set(key, val);
|
||||
}
|
||||
|
||||
constexpr int32_t kEmptyBootReason = 0;
|
||||
constexpr int32_t kUnknownBootReason = 1;
|
||||
|
||||
// A mapping from boot reason string, as read from the ro.boot.bootreason
|
||||
|
@ -136,6 +137,7 @@ constexpr int32_t kUnknownBootReason = 1;
|
|||
// the boot_reason metric may refer to this mapping to discern the histogram
|
||||
// values.
|
||||
const std::map<std::string, int32_t> kBootReasonMap = {
|
||||
{"empty", kEmptyBootReason},
|
||||
{"unknown", kUnknownBootReason},
|
||||
{"normal", 2},
|
||||
{"recovery", 3},
|
||||
|
@ -216,6 +218,10 @@ int32_t BootReasonStrToEnum(const std::string& boot_reason) {
|
|||
return mapping->second;
|
||||
}
|
||||
|
||||
if (boot_reason.empty()) {
|
||||
return kEmptyBootReason;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Unknown boot reason: " << boot_reason;
|
||||
return kUnknownBootReason;
|
||||
}
|
||||
|
@ -747,8 +753,16 @@ void RecordBootComplete() {
|
|||
// property.
|
||||
void RecordBootReason() {
|
||||
const std::string reason(GetProperty(bootloader_reboot_reason_property));
|
||||
android::metricslogger::LogMultiAction(android::metricslogger::ACTION_BOOT,
|
||||
android::metricslogger::FIELD_PLATFORM_REASON, reason);
|
||||
|
||||
if (reason.empty()) {
|
||||
// Log an empty boot reason value as '<EMPTY>' to ensure the value is intentional
|
||||
// (and not corruption anywhere else in the reporting pipeline).
|
||||
android::metricslogger::LogMultiAction(android::metricslogger::ACTION_BOOT,
|
||||
android::metricslogger::FIELD_PLATFORM_REASON, "<EMPTY>");
|
||||
} else {
|
||||
android::metricslogger::LogMultiAction(android::metricslogger::ACTION_BOOT,
|
||||
android::metricslogger::FIELD_PLATFORM_REASON, reason);
|
||||
}
|
||||
|
||||
// Log the raw bootloader_boot_reason property value.
|
||||
int32_t boot_reason = BootReasonStrToEnum(reason);
|
||||
|
|
Loading…
Reference in a new issue