Skip to content

Commit

Permalink
Improve logging in bootstat.
Browse files Browse the repository at this point in the history
This should help in debugging issues related to the mismatch between
actual last reboot reason property and the expected one (see attached
bug).

Test: adb reboot
Test: adb logcat | grep bootstat
Bug: 152900920
Change-Id: I085cf1fb80a30389fd3ba821d40b6111a3294d95
Merged-In: I085cf1fb80a30389fd3ba821d40b6111a3294d95
(cherry picked from commit 49062f3b726cc71b10916d715881156ec6b94ef3)

Former-commit-id: 1a17a365461bd77c80d2c9f656c7df84cff5fc2d
  • Loading branch information
nioffe committed Apr 2, 2020
1 parent 57cb3f5 commit 1788c2a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bootstat/bootstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,16 +1238,26 @@ void SetSystemBootReason() {
// Shift last_reboot_reason_property to last_last_reboot_reason_property
std::string last_boot_reason;
if (!android::base::ReadFileToString(last_reboot_reason_file, &last_boot_reason)) {
PLOG(ERROR) << "Failed to read " << last_reboot_reason_file;
last_boot_reason = android::base::GetProperty(last_reboot_reason_property, "");
LOG(INFO) << "Value of " << last_reboot_reason_property << " : " << last_boot_reason;
} else {
LOG(INFO) << "Last reboot reason read from " << last_reboot_reason_file << " : "
<< last_boot_reason << ". Last reboot reason read from "
<< last_reboot_reason_property << " : "
<< android::base::GetProperty(last_reboot_reason_property, "");
}
if (last_boot_reason.empty() || isKernelRebootReason(system_boot_reason)) {
last_boot_reason = system_boot_reason;
} else {
transformReason(last_boot_reason);
}
LOG(INFO) << "Normalized last reboot reason : " << last_boot_reason;
android::base::SetProperty(last_last_reboot_reason_property, last_boot_reason);
android::base::SetProperty(last_reboot_reason_property, "");
unlink(last_reboot_reason_file);
if (unlink(last_reboot_reason_file) != 0) {
PLOG(ERROR) << "Failed to unlink " << last_reboot_reason_file;
}
}

// Gets the boot time offset. This is useful when Android is running in a
Expand Down

0 comments on commit 1788c2a

Please sign in to comment.