diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-13 22:34:12 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-13 22:34:12 +0000 |
commit | e66d5f92e040e7ea4f6d51dd7c91202b9d194727 (patch) | |
tree | 92a053fe4b6d022d8336955238f63d22b4f52159 | |
parent | 6afeedc9215ace39386e821fcee70cc51a72f591 (diff) | |
parent | 3694b657f26ae25cc4870319170af82681475843 (diff) | |
download | core-e66d5f92e040e7ea4f6d51dd7c91202b9d194727.tar.gz |
Snap for 9286970 from 3694b657f26ae25cc4870319170af82681475843 to tm-qpr2-release
Change-Id: Ie8170866f1c86248176b91e7e94bc21ab77c35be
-rw-r--r-- | init/reboot.cpp | 6 | ||||
-rw-r--r-- | init/reboot_utils.cpp | 9 | ||||
-rw-r--r-- | init/reboot_utils.h | 3 |
3 files changed, 11 insertions, 7 deletions
diff --git a/init/reboot.cpp b/init/reboot.cpp index 41cf748d8..423dad81d 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -608,7 +608,7 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str if (sem_init(&reboot_semaphore, false, 0) == -1) { // These should never fail, but if they do, skip the graceful reboot and reboot immediately. LOG(ERROR) << "sem_init() fail and RebootSystem() return!"; - RebootSystem(cmd, reboot_target); + RebootSystem(cmd, reboot_target, reason); } // Start a thread to monitor init shutdown process @@ -636,7 +636,7 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str // worry about unmounting it. if (!IsDataMounted("*")) { sync(); - RebootSystem(cmd, reboot_target); + RebootSystem(cmd, reboot_target, reason); abort(); } @@ -769,7 +769,7 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str LOG(INFO) << "Shutdown /data"; } } - RebootSystem(cmd, reboot_target); + RebootSystem(cmd, reboot_target, reason); abort(); } diff --git a/init/reboot_utils.cpp b/init/reboot_utils.cpp index b3fa9fd3b..1f411636c 100644 --- a/init/reboot_utils.cpp +++ b/init/reboot_utils.cpp @@ -106,7 +106,8 @@ bool IsRebootCapable() { return value == CAP_SET; } -void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& rebootTarget) { +void __attribute__((noreturn)) +RebootSystem(unsigned int cmd, const std::string& rebootTarget, const std::string& reboot_reason) { LOG(INFO) << "Reboot ending, jumping to kernel"; if (!IsRebootCapable()) { @@ -127,10 +128,12 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& case ANDROID_RB_THERMOFF: if (android::base::GetBoolProperty("ro.thermal_warmreset", false)) { + std::string reason = "shutdown,thermal"; + if (!reboot_reason.empty()) reason = reboot_reason; + LOG(INFO) << "Try to trigger a warm reset for thermal shutdown"; - static constexpr const char kThermalShutdownTarget[] = "shutdown,thermal"; syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, - LINUX_REBOOT_CMD_RESTART2, kThermalShutdownTarget); + LINUX_REBOOT_CMD_RESTART2, reason.c_str()); } else { reboot(RB_POWER_OFF); } diff --git a/init/reboot_utils.h b/init/reboot_utils.h index a0023b9bb..09e87ef67 100644 --- a/init/reboot_utils.h +++ b/init/reboot_utils.h @@ -29,7 +29,8 @@ void SetFatalRebootTarget(const std::optional<std::string>& reboot_target = std: // so if any of the attempts to determine this fail, it will still return true. bool IsRebootCapable(); // This is a wrapper around the actual reboot calls. -void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& reboot_target); +void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& reboot_target, + const std::string& reboot_reason = ""); void __attribute__((noreturn)) InitFatalReboot(int signal_number); void InstallRebootSignalHandlers(); |