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 1/4] 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 From 9c1397703f4ff10d112036ea33a0ffa8ed27e0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8B=A4=E4=BA=AE?= Date: Thu, 4 Sep 2025 20:56:41 +0800 Subject: [PATCH 2/4] change commit log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘勤亮 --- interfaces/kits/updaterkits/updaterkits.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index 2e0d8daa..5e4dc05b 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -147,7 +147,7 @@ static bool WriteToMiscAndResultFileRebootToUpdater(const struct UpdateMessage & std::string writeMiscAfter = "0x80000008"; WriteUpdaterResultFile(pkgPath, writeMiscAfter); if (rebootFunc != nullptr && rebootFunc() != 0) { - LOG(ERROR) << "reboot Func Failed"; + LOG(ERROR) << "reboot callback Failed"; return false; } else if (rebootFunc == nullptr) { DoReboot("updater:reboot to updater to trigger update"); -- Gitee From 8ef5a16a42f6405cf8d409a42c77fb9d112552fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8B=A4=E4=BA=AE?= Date: Thu, 4 Sep 2025 21:04:09 +0800 Subject: [PATCH 3/4] call back commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘勤亮 --- interfaces/kits/updaterkits/updaterkits.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index 5e4dc05b..c9c05201 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -147,7 +147,7 @@ static bool WriteToMiscAndResultFileRebootToUpdater(const struct UpdateMessage & std::string writeMiscAfter = "0x80000008"; WriteUpdaterResultFile(pkgPath, writeMiscAfter); if (rebootFunc != nullptr && rebootFunc() != 0) { - LOG(ERROR) << "reboot callback Failed"; + LOG(ERROR) << "Reboot Callback Failed"; return false; } else if (rebootFunc == nullptr) { DoReboot("updater:reboot to updater to trigger update"); -- Gitee From aa54800646857009dc719a340dc9505392502667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8B=A4=E4=BA=AE?= Date: Thu, 4 Sep 2025 21:06:28 +0800 Subject: [PATCH 4/4] add reboot func commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘勤亮 --- interfaces/kits/updaterkits/updaterkits.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index c9c05201..3f7b8c38 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -147,7 +147,7 @@ static bool WriteToMiscAndResultFileRebootToUpdater(const struct UpdateMessage & std::string writeMiscAfter = "0x80000008"; WriteUpdaterResultFile(pkgPath, writeMiscAfter); if (rebootFunc != nullptr && rebootFunc() != 0) { - LOG(ERROR) << "Reboot Callback Failed"; + LOG(ERROR) << "reboot func Failed"; return false; } else if (rebootFunc == nullptr) { DoReboot("updater:reboot to updater to trigger update"); -- Gitee