diff --git a/services/flow_update/update_bin/bin_process.cpp b/services/flow_update/update_bin/bin_process.cpp index 4aa1330c79b128553883e345fece163ac04b78f0..9f565357b4e22f11d8d2658994dd0ef885a17d00 100644 --- a/services/flow_update/update_bin/bin_process.cpp +++ b/services/flow_update/update_bin/bin_process.cpp @@ -26,6 +26,7 @@ #include "threadpool/thread_pool.h" #include "scope_guard.h" #include "securec.h" +#include "updater/updater_const.h" using namespace std; using namespace Hpackage; @@ -85,6 +86,7 @@ int32_t UScriptInstructionBinFlowWrite::Execute(Uscript::UScriptEnv &env, Uscrip producer.join(); if (isStopRun_) { LOG(ERROR) << "Error to Execute bin file update"; + env.PostMessage(UPDATER_RETRY_TAG, PROCESS_BIN_FAIL_RETRY); return USCRIPT_ERROR_EXECUTE; } return USCRIPT_SUCCESS; diff --git a/services/hwfault_retry/hwfault_retry.cpp b/services/hwfault_retry/hwfault_retry.cpp index 2b67adbc77b5a562881caa6f34a7f617e8ba46f3..7cd53d080a0ffea915f64c9fca2d3ba7f09ab345 100644 --- a/services/hwfault_retry/hwfault_retry.cpp +++ b/services/hwfault_retry/hwfault_retry.cpp @@ -38,6 +38,7 @@ HwFaultRetry::HwFaultRetry() RegisterFunc(VERIFY_FAILED_REBOOT, rebootFunc); RegisterFunc(IO_FAILED_REBOOT, rebootFunc); RegisterFunc(BLOCK_UPDATE_FAILED_REBOOT, rebootFunc); + RegisterFunc(PROCESS_BIN_FAIL_RETRY, rebootFunc); } void HwFaultRetry::RegisterFunc(const std::string &faultInfo, RetryFunc func) @@ -72,6 +73,16 @@ void HwFaultRetry::SetEffectiveValue(bool value) effective_ = value; } +void HwFaultRetry::SetRebootCmd(const std::string &rebootCmd) +{ + rebootCmd_ = rebootCmd; +} + +bool HwFaultRetry::IsRetry(void) +{ + return isRetry_; +} + void HwFaultRetry::RebootRetry() { if (!effective_) { @@ -82,14 +93,19 @@ void HwFaultRetry::RebootRetry() LOG(INFO) << "retry more than 3 times, no need retry"; return; } - + LOG(INFO) << "enter into reboot retry"; Utils::AddUpdateInfoToMisc("retry_count", retryCount_ + 1); Utils::SetFaultInfoToMisc(faultInfo_); + isRetry_ = true; PostUpdater(false); sync(); #ifndef UPDATER_UT - DoReboot("updater:Updater fault retry"); + if (rebootCmd_.empty()) { + DoReboot("updater:Updater fault retry"); + } else { + DoReboot(rebootCmd_.c_str()); + } while (true) { pause(); } diff --git a/services/include/updater/hwfault_retry.h b/services/include/updater/hwfault_retry.h index b0711dda4cd4293b153bdb0ce94d0f0e22c7c684..6d593475e6a9e666d1afa5e518db28500a7c23a0 100644 --- a/services/include/updater/hwfault_retry.h +++ b/services/include/updater/hwfault_retry.h @@ -34,14 +34,18 @@ public: void SetFaultInfo(const std::string &faultInfo); void SetRetryCount(const uint32_t count); void SetEffectiveValue(bool value); + void SetRebootCmd(const std::string &rebootCmd); + bool IsRetry(void); private: void RebootRetry(); - std::unordered_map retryMap_; - std::string faultInfo_; + std::unordered_map retryMap_ {}; + std::string faultInfo_ {}; + std::string rebootCmd_ {}; uint32_t retryCount_ {}; bool effective_ = true; + bool isRetry_ = false; }; } // Updater #endif // UPDATER_HWFAULT_RETRY_H diff --git a/services/include/updater/updater_const.h b/services/include/updater/updater_const.h index 2496e4bc8c9d2bd9d9fbf50fb7eaaaad2bf04d17..7378ab572db7ec48f3b5c087c66716fae1715574 100644 --- a/services/include/updater/updater_const.h +++ b/services/include/updater/updater_const.h @@ -83,6 +83,7 @@ constexpr const char *UPDATER_RETRY_TAG = "retry_update"; constexpr const char *VERIFY_FAILED_REBOOT = "reboot_verify_failed"; constexpr const char *IO_FAILED_REBOOT = "reboot_IO_failed"; constexpr const char *BLOCK_UPDATE_FAILED_REBOOT = "reboot_block_update_failed"; +constexpr const char *PROCESS_BIN_FAIL_RETRY = "process_bin_failed"; constexpr int MAX_RETRY_COUNT = 3; constexpr int MINIMAL_ARGC_LIMIT = 2;