From 3694b657f26ae25cc4870319170af82681475843 Mon Sep 17 00:00:00 2001 From: Sayanna Chandula Date: Tue, 4 Oct 2022 15:06:05 -0700 Subject: init: Support reboot reason with thermal warmreset Thermal shutdown could be due to tskin temperature or battery temperature. Pass reason while rebooting the system to reflect properly in boot.reason Bug: 238464124 Test: Build and boot on device. Check reboot reason for thermal shutdown and battery thermal shutdown with thermal warmreset enabled. Ignore-AOSP-First: AOSP already contains the change Change-Id: I192562fed48ae7da7843e383362cd22a76ce479f Merged-In: I192562fed48ae7da7843e383362cd22a76ce479f --- init/reboot_utils.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'init/reboot_utils.cpp') 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); } -- cgit v1.2.3