Loading bootstat/bootstat.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -870,6 +870,7 @@ bool addKernelPanicSubReason(const std::string& content, std::string& ret) { const char system_reboot_reason_property[] = "sys.boot.reason"; const char last_reboot_reason_property[] = LAST_REBOOT_REASON_PROPERTY; const char last_reboot_reason_file[] = LAST_REBOOT_REASON_FILE; const char last_last_reboot_reason_property[] = "sys.boot.reason.last"; constexpr size_t history_reboot_reason_size = 4; const char history_reboot_reason_property[] = LAST_REBOOT_REASON_PROPERTY ".history"; Loading Loading @@ -1059,7 +1060,9 @@ std::string BootReasonStrToReason(const std::string& boot_reason) { if (isBluntRebootReason(ret)) { // Content buffer no longer will have console data. Beware if more // checks added below, that depend on parsing console content. if (!android::base::ReadFileToString(last_reboot_reason_file, &content)) { content = android::base::GetProperty(last_reboot_reason_property, ""); } transformReason(content); // Anything in last is better than 'super-blunt' reboot or shutdown. Loading Loading @@ -1233,7 +1236,10 @@ void SetSystemBootReason() { // Record the scrubbed system_boot_reason to the property BootReasonAddToHistory(system_boot_reason); // Shift last_reboot_reason_property to last_last_reboot_reason_property auto last_boot_reason = android::base::GetProperty(last_reboot_reason_property, ""); std::string last_boot_reason; if (!android::base::ReadFileToString(last_reboot_reason_file, &last_boot_reason)) { last_boot_reason = android::base::GetProperty(last_reboot_reason_property, ""); } if (last_boot_reason.empty() || isKernelRebootReason(system_boot_reason)) { last_boot_reason = system_boot_reason; } else { Loading @@ -1241,6 +1247,7 @@ void SetSystemBootReason() { } android::base::SetProperty(last_last_reboot_reason_property, last_boot_reason); android::base::SetProperty(last_reboot_reason_property, ""); unlink(last_reboot_reason_file); } // Gets the boot time offset. This is useful when Android is running in a Loading init/reboot.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -548,6 +548,7 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str skip = strlen("reboot,"); } SetProperty(LAST_REBOOT_REASON_PROPERTY, reason.c_str() + skip); WriteStringToFile(reason.c_str() + skip, LAST_REBOOT_REASON_FILE); sync(); bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF; Loading libcutils/include/cutils/android_reboot.h +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ __BEGIN_DECLS /* Android reboot reason stored in this property */ #define LAST_REBOOT_REASON_PROPERTY "persist.sys.boot.reason" #define LAST_REBOOT_REASON_FILE "/metadata/bootstat/" LAST_REBOOT_REASON_PROPERTY /* Reboot or shutdown the system. * This call uses ANDROID_RB_PROPERTY to request reboot to init process. Loading rootdir/init.rc +1 −0 Original line number Diff line number Diff line Loading @@ -496,6 +496,7 @@ on post-fs mkdir /metadata/vold chmod 0700 /metadata/vold mkdir /metadata/password_slots 0771 root system mkdir /metadata/bootstat 0750 system log mkdir /metadata/ota 0700 root system mkdir /metadata/ota/snapshots 0700 root system Loading Loading
bootstat/bootstat.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -870,6 +870,7 @@ bool addKernelPanicSubReason(const std::string& content, std::string& ret) { const char system_reboot_reason_property[] = "sys.boot.reason"; const char last_reboot_reason_property[] = LAST_REBOOT_REASON_PROPERTY; const char last_reboot_reason_file[] = LAST_REBOOT_REASON_FILE; const char last_last_reboot_reason_property[] = "sys.boot.reason.last"; constexpr size_t history_reboot_reason_size = 4; const char history_reboot_reason_property[] = LAST_REBOOT_REASON_PROPERTY ".history"; Loading Loading @@ -1059,7 +1060,9 @@ std::string BootReasonStrToReason(const std::string& boot_reason) { if (isBluntRebootReason(ret)) { // Content buffer no longer will have console data. Beware if more // checks added below, that depend on parsing console content. if (!android::base::ReadFileToString(last_reboot_reason_file, &content)) { content = android::base::GetProperty(last_reboot_reason_property, ""); } transformReason(content); // Anything in last is better than 'super-blunt' reboot or shutdown. Loading Loading @@ -1233,7 +1236,10 @@ void SetSystemBootReason() { // Record the scrubbed system_boot_reason to the property BootReasonAddToHistory(system_boot_reason); // Shift last_reboot_reason_property to last_last_reboot_reason_property auto last_boot_reason = android::base::GetProperty(last_reboot_reason_property, ""); std::string last_boot_reason; if (!android::base::ReadFileToString(last_reboot_reason_file, &last_boot_reason)) { last_boot_reason = android::base::GetProperty(last_reboot_reason_property, ""); } if (last_boot_reason.empty() || isKernelRebootReason(system_boot_reason)) { last_boot_reason = system_boot_reason; } else { Loading @@ -1241,6 +1247,7 @@ void SetSystemBootReason() { } android::base::SetProperty(last_last_reboot_reason_property, last_boot_reason); android::base::SetProperty(last_reboot_reason_property, ""); unlink(last_reboot_reason_file); } // Gets the boot time offset. This is useful when Android is running in a Loading
init/reboot.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -548,6 +548,7 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str skip = strlen("reboot,"); } SetProperty(LAST_REBOOT_REASON_PROPERTY, reason.c_str() + skip); WriteStringToFile(reason.c_str() + skip, LAST_REBOOT_REASON_FILE); sync(); bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF; Loading
libcutils/include/cutils/android_reboot.h +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ __BEGIN_DECLS /* Android reboot reason stored in this property */ #define LAST_REBOOT_REASON_PROPERTY "persist.sys.boot.reason" #define LAST_REBOOT_REASON_FILE "/metadata/bootstat/" LAST_REBOOT_REASON_PROPERTY /* Reboot or shutdown the system. * This call uses ANDROID_RB_PROPERTY to request reboot to init process. Loading
rootdir/init.rc +1 −0 Original line number Diff line number Diff line Loading @@ -496,6 +496,7 @@ on post-fs mkdir /metadata/vold chmod 0700 /metadata/vold mkdir /metadata/password_slots 0771 root system mkdir /metadata/bootstat 0750 system log mkdir /metadata/ota 0700 root system mkdir /metadata/ota/snapshots 0700 root system Loading