diff --git a/services/include/updater/updater.h b/services/include/updater/updater.h index 798afa60396769eb310ada38e787634d311c1fcb..16215bb57f608615c2d042dbee3bb5ceef47bfc4 100644 --- a/services/include/updater/updater.h +++ b/services/include/updater/updater.h @@ -46,7 +46,12 @@ enum NotifyAction { SET_INSTALL_STATUS, GET_INSTALL_STATUS, SET_UPDATE_STATUS, - GET_UPDATE_STATUS + GET_UPDATE_STATUS, + SEND_LOG, + RECEIVE_LOG, + TRIGGER_SDUPDATE, + TRIGGER_FACTORYRST, + TRIGGER_EUPDATER }; struct UpdaterParams { diff --git a/services/main.cpp b/services/main.cpp index 055a30982b9ad2657ea8d69b2390a39fd24cd1ed..054c3515c88a97a0a143291930b2206ef79b7d67 100644 --- a/services/main.cpp +++ b/services/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) // execute mode initialization bootMode.InitMode(); - LOG(INFO) << "################################"; + LOG(INFO) << "##########################################################"; // mode entry return bootMode.entryFunc(argc, argv); } diff --git a/services/updater_main.cpp b/services/updater_main.cpp index b736a883291ec51e9f81f2cf1ea7a460977d01ef..307fdf19206e14f6af3d111309facd0400d42c0a 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -168,8 +168,8 @@ __attribute__((weak)) void UpdaterVerifyFailEntry(bool verifyret) return; } -__attribute__((weak)) UpdaterStatus NotifyActionResult(UpdaterParams &upParams, - UpdaterStatus &status, const std::vector ¬ifyActionVec) +__attribute__((weak)) UpdaterStatus NotifyActionResult(UpdaterStatus &status, + const std::vector ¬ifyActionVec, UpdaterParams &upParams) { return UPDATE_SUCCESS; } @@ -393,7 +393,7 @@ static int CheckMountData() static UpdaterStatus CheckVerifyPackages(UpdaterParams &upParams) { UpdaterStatus status = UPDATE_SUCCESS; - if (NotifyActionResult(upParams, status, {PROCESS_PACKAGE, SET_INSTALL_STATUS, GET_INSTALL_STATUS}) != + if (NotifyActionResult(status, {PROCESS_PACKAGE, SET_INSTALL_STATUS, GET_INSTALL_STATUS}, upParams) != UPDATE_SUCCESS) { LOG(ERROR) << "notify action fail"; return UPDATE_CORRUPT; @@ -523,7 +523,7 @@ UpdaterStatus DoUpdatePackages(UpdaterParams &upParams) UPDATER_UI_INSTANCE.GetCurrentPercent() : (updateStartPosition * FULL_PERCENT_PROGRESS); upParams.callbackProgress(value); status = DoInstallPackages(upParams, pkgStartPosition); - if (NotifyActionResult(upParams, status, {SET_UPDATE_STATUS}) != UPDATE_SUCCESS) { + if (NotifyActionResult(status, {SET_UPDATE_STATUS}, upParams) != UPDATE_SUCCESS) { LOG(ERROR) << "set status fail"; return UPDATE_CORRUPT; } @@ -534,7 +534,7 @@ UpdaterStatus DoUpdatePackages(UpdaterParams &upParams) if (upParams.forceUpdate) { UPDATER_UI_INSTANCE.ShowLogRes(TR(LABEL_UPD_OK_SHUTDOWN)); } - if (NotifyActionResult(upParams, status, {GET_UPDATE_STATUS}) != UPDATE_SUCCESS) { + if (NotifyActionResult(status, {GET_UPDATE_STATUS}, upParams) != UPDATE_SUCCESS) { LOG(ERROR) << "get status fail"; return UPDATE_CORRUPT; } @@ -888,6 +888,11 @@ __attribute__((weak)) bool NotifySdUpdateReboot(const UpdaterParams &upParams) return false; } +__attribute__((weak)) void NotifyShutdown(const std::string &shutdownReason) +{ + Utils::DoShutdown(shutdownReason); +} + void RebootAfterUpdateSuccess(const UpdaterParams &upParams) { if (IsNeedWipe()) { @@ -898,7 +903,7 @@ void RebootAfterUpdateSuccess(const UpdaterParams &upParams) LOG(INFO) << "sd update and wipe data"; return; } - upParams.forceUpdate ? Utils::DoShutdown("Updater update success go shut down") : + upParams.forceUpdate ? NotifyShutdown("Updater update success go shut down") : NotifyReboot("", "Updater update success"); } @@ -917,6 +922,8 @@ int UpdaterMain(int argc, char **argv) UpdaterInit::GetInstance().InvokeEvent(UPDATER_INIT_EVENT); PackageUpdateMode mode = UNKNOWN_UPDATE; status = StartUpdater(args, argv, mode, upParams); + UpdaterStatus updaterStatus = UPDATE_SUCCESS; + NotifyActionResult(updaterStatus, {SEND_LOG, RECEIVE_LOG}, upParams); #if !defined(UPDATER_UT) && defined(UPDATER_UI_SUPPORT) UPDATER_UI_INSTANCE.Sleep(UI_SHOW_DURATION); if (status != UPDATE_SUCCESS && status != UPDATE_SKIP) { diff --git a/services/updater_main.h b/services/updater_main.h index e367a2e7e8973c04271ca66da341363ca6b01e00..717141249f546024bde4bad4f444abf774a9e9b9 100644 --- a/services/updater_main.h +++ b/services/updater_main.h @@ -72,8 +72,9 @@ bool IsSpareBoardBoot(void); bool IsNeedWipe(); bool NotifySdUpdateReboot(const UpdaterParams &upParams); void NotifyReboot(const std::string& rebootTarget, const std::string &rebootReason, const std::string &extData = ""); -UpdaterStatus NotifyActionResult(UpdaterParams &upParams, - UpdaterStatus &status, const std::vector ¬ifyActionVec); +void NotifyShutdown(const std::string &shutdownReason); +UpdaterStatus NotifyActionResult(UpdaterStatus &status, + const std::vector ¬ifyActionVec, const UpdaterParams &upParams = {}); #ifdef __cplusplus #if __cplusplus } diff --git a/services/updater_ui.cpp b/services/updater_ui.cpp index ce20ea0e26b31437d84fcfde15412d4635f130fb..d6086d5f38a4b505df8df1e8e05d5ab7d8e29a43 100644 --- a/services/updater_ui.cpp +++ b/services/updater_ui.cpp @@ -110,6 +110,11 @@ DEFINE_ASYN_CALLBACK(OnLabelSDCardNoDelayEvt) if (!GetFacade().SetMode(UPDATERMODE_SDCARD)) { return; } + UpdaterStatus status = UPDATE_SUCCESS; + if (NotifyAction(status, {TRIGGER_SDUPDATE}) != UPDATE_SUCCESS) { + LOG(ERROR) << "trigger sd update fail"; + return; + } Utils::UsSleep(CALLBACK_DELAY); UpdaterParams upParams; upParams.updateMode = SDCARD_UPDATE; @@ -217,7 +222,7 @@ DEFINE_ASYN_CALLBACK(OnMenuShutdownEvt) { LOG(DEBUG) << "shutdown"; GraphicEngine::GetInstance().StopEngine(); - Utils::DoShutdown("Updater shutdown btn event"); + NotifyShutdown("Updater shutdown btn event"); } DEFINE_ASYN_CALLBACK(OnMenuClearCacheEvt)