From 747b773d0f62723908afd3b13800340b0bf8ba97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8B=A4=E4=BA=AE?= Date: Wed, 3 Sep 2025 21:19:31 +0800 Subject: [PATCH] add callback function return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘勤亮 --- interfaces/kits/include/updaterkits/updaterkits.h | 2 +- interfaces/kits/updaterkits/updaterkits.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/include/updaterkits/updaterkits.h b/interfaces/kits/include/updaterkits/updaterkits.h index 5d523c2d..254f7e23 100755 --- a/interfaces/kits/include/updaterkits/updaterkits.h +++ b/interfaces/kits/include/updaterkits/updaterkits.h @@ -17,7 +17,7 @@ #include #include -using RebootFunType = std::function; +using RebootFunType = std::function; constexpr const char *UPGRADE_TYPE_OTA = "ota"; constexpr const char *UPGRADE_TYPE_SD = "sdcard"; constexpr const char *UPGRADE_TYPE_OTA_INTRAL = "ota_intral"; diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index a83e99ca..2e0d8daa 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -146,10 +146,11 @@ static bool WriteToMiscAndResultFileRebootToUpdater(const struct UpdateMessage & // Flag after the misc in written std::string writeMiscAfter = "0x80000008"; WriteUpdaterResultFile(pkgPath, writeMiscAfter); - if (rebootFunc == nullptr) { + if (rebootFunc != nullptr && rebootFunc() != 0) { + LOG(ERROR) << "reboot Func Failed"; + return false; + } else if (rebootFunc == nullptr) { DoReboot("updater:reboot to updater to trigger update"); - } else { - rebootFunc(); } while (true) { pause(); @@ -271,7 +272,9 @@ int RebootAndInstallUpgradePackage(const std::string &miscFile, const std::vecto } if (upgradeType == UPGRADE_TYPE_OTA || upgradeType == UPGRADE_TYPE_OTA_INTRAL || upgradeType == UPGRADE_TYPE_SUBPKG_UPDATE) { - WriteToMiscAndResultFileRebootToUpdater(updateMsg, upgradeType, rebootFunc); + if (!WriteToMiscAndResultFileRebootToUpdater(updateMsg, upgradeType, rebootFunc)) { + return 6; // 6 : Reboot failed + } } else { WriteToMiscAndRebootToUpdater(updateMsg); } -- Gitee