diff options
author | guangkui.ren <guangkui.ren@sunmi.corp-partner.google.com> | 2024-04-07 15:10:45 +0800 |
---|---|---|
committer | guangkui ren <guangkui.ren@sunmi.corp-partner.google.com> | 2024-04-26 06:08:57 +0000 |
commit | aef46f3edd85bc55d0f2a92dbad49d03f5c12568 (patch) | |
tree | 7ec44364cc0375be7051bf901d0cce7087212c31 | |
parent | cd6618b619b1b614991550b46be9f23e6fa5f350 (diff) | |
download | recovery-aef46f3edd85bc55d0f2a92dbad49d03f5c12568.tar.gz |
Pause recovery when it ends with Shutdown
In the current design, when recovery ends with Shutdown, it will
continue to execute commands repeatedly in the loop body, after it sets
a "Shutdown" property. That may lead to some competition between the
shutdown process and recovery command work, and then cause some
problems.
So, pause recovery when it ends with Shutdown, like it ending with
Reboot.
Change-Id: I57dfef70e7b8d600af3a3f2c0199f14d5a0e9916
-rw-r--r-- | otautil/include/otautil/sysutil.h | 2 | ||||
-rw-r--r-- | otautil/sysutil.cpp | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h index d0d2e67d..5c64cff1 100644 --- a/otautil/include/otautil/sysutil.h +++ b/otautil/include/otautil/sysutil.h @@ -106,7 +106,7 @@ class MemMapping { [[noreturn]] void Reboot(std::string_view target); // Triggers a shutdown. -bool Shutdown(std::string_view target); +[[noreturn]] void Shutdown(std::string_view target); // Returns a null-terminated char* array, where the elements point to the C-strings in the given // vector, plus an additional nullptr at the end. This is a helper function that facilitates diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp index b3ead973..2c7752e9 100644 --- a/otautil/sysutil.cpp +++ b/otautil/sysutil.cpp @@ -233,9 +233,13 @@ void Reboot(std::string_view target) { while (true) pause(); } -bool Shutdown(std::string_view target) { +void Shutdown(std::string_view target) { std::string cmd = "shutdown," + std::string(target); - return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd); + if (!android::base::SetProperty(ANDROID_RB_PROPERTY, cmd)) { + LOG(FATAL) << "Shutdown failed"; + } + + while (true) pause(); } std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) { |