From 5f181bc503c27164bfa3fcf52fd26b0b68c3a580 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 27 Aug 2019 16:35:35 -0700 Subject: [PATCH] init: boot into thermal shutdown target on supported devices Bug: 137982557 Test: thermal shutdown Change-Id: I4c7c4647e340be6be7a37a3dde6324b4d7903007 (cherry picked from commit 271014e8325f17ac1fcf83dede7ce987c293fb2c) --- init/reboot_utils.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/init/reboot_utils.cpp b/init/reboot_utils.cpp index d1a712f2e..de085cc9b 100644 --- a/init/reboot_utils.cpp +++ b/init/reboot_utils.cpp @@ -21,11 +21,12 @@ #include -#include "android-base/file.h" -#include "android-base/logging.h" -#include "android-base/strings.h" -#include "backtrace/Backtrace.h" -#include "cutils/android_reboot.h" +#include +#include +#include +#include +#include +#include #include "capabilities.h" @@ -93,7 +94,14 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& break; case ANDROID_RB_THERMOFF: - reboot(RB_POWER_OFF); + if (android::base::GetBoolProperty("ro.thermal_warmreset", false)) { + 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); + } else { + reboot(RB_POWER_OFF); + } break; } // In normal case, reboot should not return.