From 72fcc3f1817e878730dcd0e37471627ce4321334 Mon Sep 17 00:00:00 2001 From: hanKF Date: Thu, 20 Feb 2025 19:01:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BA=95=E8=BD=AF=EF=BC=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=86=85=E5=A4=96OTA=E5=8D=87=E7=BA=A7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanKF --- interfaces/kits/include/updaterkits/updaterkits.h | 1 + interfaces/kits/updaterkits/updaterkits.cpp | 7 +++++-- services/include/updater/updater_const.h | 1 + services/updater_main.cpp | 9 ++++++++- services/updater_utils.cpp | 4 +++- utils/write_updater.cpp | 8 ++++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/include/updaterkits/updaterkits.h b/interfaces/kits/include/updaterkits/updaterkits.h index 6f2b6699..34b8c353 100755 --- a/interfaces/kits/include/updaterkits/updaterkits.h +++ b/interfaces/kits/include/updaterkits/updaterkits.h @@ -18,6 +18,7 @@ constexpr const char *UPGRADE_TYPE_OTA = "ota"; constexpr const char *UPGRADE_TYPE_SD = "sdcard"; +constexpr const char *UPGRADE_TYPE_OTA_INTRAL = "ota_intral"; constexpr const char *UPGRADE_TYPE_SD_INTRAL = "sdcard_intral"; // Reboot system to updater mode and trigger installing update package. diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index 673392aa..38bfe541 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -227,7 +227,7 @@ bool RebootAndInstallSdcardPackage(const std::string &miscFile, const std::vecto int RebootAndInstallUpgradePackage(const std::string &miscFile, const std::vector &packageName, const std::string &upgradeType) { - if (packageName.size() == 0 && upgradeType == UPGRADE_TYPE_OTA) { + if (packageName.size() == 0 && (upgradeType == UPGRADE_TYPE_OTA || upgradeType == UPGRADE_TYPE_OTA_INTRAL) { LOG(ERROR) << "updaterkits: invalid argument. one of arugments is empty"; return 1; // 1 : Invalid input } @@ -248,6 +248,9 @@ int RebootAndInstallUpgradePackage(const std::string &miscFile, const std::vecto } else if (upgradeType == UPGRADE_TYPE_SD_INTRAL) { ret = snprintf_s(updateMsg.update, sizeof(updateMsg.update), sizeof(updateMsg.update) - 1, "--sdcard_intral_update\n"); + } else if (upgradeType == UPGRADE_TYPE_OTA_INTRAL) { + ret = snprintf_s(updateMsg.update, sizeof(updateMsg.update), sizeof(updateMsg.update) - 1, + "--ota_intral_update\n"); } if (ret < 0) { LOG(ERROR) << "updaterkits: copy updater message failed"; @@ -257,7 +260,7 @@ int RebootAndInstallUpgradePackage(const std::string &miscFile, const std::vecto if (addRet != 0) { return addRet; } - if (upgradeType == UPGRADE_TYPE_OTA) { + if (upgradeType == UPGRADE_TYPE_OTA || upgradeType == UPGRADE_TYPE_OTA_INTRAL) { WriteToMiscAndResultFileRebootToUpdater(updateMsg, upgradeType); } else { WriteToMiscAndRebootToUpdater(updateMsg); diff --git a/services/include/updater/updater_const.h b/services/include/updater/updater_const.h index 7378ab57..95413cde 100644 --- a/services/include/updater/updater_const.h +++ b/services/include/updater/updater_const.h @@ -51,6 +51,7 @@ constexpr const char *UPLOAD_LOG_TIME_FILE = "upload_time"; constexpr const char *SDCARD_MODE = "sdcard_update"; constexpr const char *OTA_MODE = "update_package"; constexpr const char *USB_MODE = "usb_update"; +constexpr const char *OTA_INTRAL_MODE = "ota_intral_update"; constexpr const char *SDCARD_INTRAL_MODE = "sdcard_intral_update"; constexpr const char *UPDATRE_SCRIPT_ZIP = "/etc/updater_script.zip"; constexpr const char *FACTORY_INTERNAL_MODE = "factory_internal_update"; diff --git a/services/updater_main.cpp b/services/updater_main.cpp index b736a883..00d32a36 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -75,6 +75,7 @@ constexpr struct option OPTIONS[] = { { "UPDATE:SD", no_argument, nullptr, 0 }, { "UPDATE:SDFROMDEV", no_argument, nullptr, 0 }, { "sdcard_intral_update", optional_argument, nullptr, 0}, + { "ota_intral_update", optional_argument, nullptr, 0}, { "shrink_info", required_argument, nullptr, 0 }, { "virtual_shrink_info", required_argument, nullptr, 0 }, {"wipe_data_factory_lowlevel", no_argument, nullptr, 0}, @@ -268,7 +269,7 @@ bool IsBatteryCapacitySufficient() return true; } if (IsSpareBoardBoot()) { - LOG(INFO) << "this is spare board boot, no need to determine the battery"; + LOG(INFO) << "spare board boot", no need to determine the battery"; return true; } static constexpr auto levelIdx = "lowBatteryLevel"; @@ -802,6 +803,12 @@ std::unordered_map> InitOptionsFuncTab(char* { upParams.updateMode = SDCARD_UPDATE; }}, + {"ota_intral_update", [&]() -> void + { + upParams.updatePackage.push_back(optarg); + (void)UPDATER_UI_INSTANCE.SetMode(UPDATERMODE_OTA); + mode = HOTA_UPDATE; + }}, {"shrink_info", [&]() -> void { upParams.shrinkInfo = std::string(optarg); diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 6c7c0983..d3058d41 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -187,9 +187,11 @@ bool IsMountDataAndSaveLogs(void) bool isSdCardMode = CheckUpdateMode(SDCARD_MODE); bool isUsbMode = CheckUpdateMode(USB_MODE); bool isSdCardIntralMode = CheckUpdateMode(SDCARD_INTRAL_MODE); + bool isOtaIntralMode = CheckUpdateMode(OTA_INTRAL_MODE); bool isLogMounted = GetMountStatusForMountPoint("/log") == MountStatus::MOUNT_MOUNTED; bool isDataAlreadyMounted = GetMountStatusForMountPoint("/data") == MountStatus::MOUNT_MOUNTED; - return (!(isSdCardMode || isUsbMode) && (isDataAlreadyMounted || !isLogMounted)) || isSdCardIntralMode; + return (!(isSdCardMode || isUsbMode) && (isDataAlreadyMounted || !isLogMounted)) || + isSdCardIntralMode || isOtaIntralMode; } static void DeleteUpdaterTmpFiles() diff --git a/utils/write_updater.cpp b/utils/write_updater.cpp index 444d66d7..2d0ca5ae 100644 --- a/utils/write_updater.cpp +++ b/utils/write_updater.cpp @@ -124,6 +124,14 @@ int main(int argc, char **argv) cout << "strncpy_s failed!" << endl; return -1; } + } else if (strcmp(argv[1], "ota_intral_update") == 0) { + if (ExceptionUpdater(argc, argv, boot) == -1) { + return -1; + } + if (strncpy_s(boot.update, sizeof(boot.update), "--ota_intral_update", sizeof(boot.update) - 1) != 0) { + cout << "strncpy_s failed!" << endl; + return -1; + } } else if (strcmp(argv[1], "updater_para") == 0) { if (WriteUpdaterPara(argc, para) != 0) { return -1; -- Gitee From cd0b12687af48bfd3f7ca2de5b3882016d1e6482 Mon Sep 17 00:00:00 2001 From: hanKF Date: Thu, 20 Feb 2025 19:41:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=93=9D=E5=8C=BA?= =?UTF-8?q?=E6=8A=84=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanKF --- 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 38bfe541..7b1bf0f7 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -227,7 +227,7 @@ bool RebootAndInstallSdcardPackage(const std::string &miscFile, const std::vecto int RebootAndInstallUpgradePackage(const std::string &miscFile, const std::vector &packageName, const std::string &upgradeType) { - if (packageName.size() == 0 && (upgradeType == UPGRADE_TYPE_OTA || upgradeType == UPGRADE_TYPE_OTA_INTRAL) { + if (packageName.size() == 0 && (upgradeType == UPGRADE_TYPE_OTA || upgradeType == UPGRADE_TYPE_OTA_INTRAL)) { LOG(ERROR) << "updaterkits: invalid argument. one of arugments is empty"; return 1; // 1 : Invalid input } -- Gitee From 70767f83d0bd77ca69b48c0b821081395b286be1 Mon Sep 17 00:00:00 2001 From: hanKF Date: Thu, 20 Feb 2025 20:10:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=93=9D=E5=8C=BA?= =?UTF-8?q?=E6=8A=84=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanKF --- services/updater_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/updater_main.cpp b/services/updater_main.cpp index 00d32a36..4efb5a05 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -269,7 +269,7 @@ bool IsBatteryCapacitySufficient() return true; } if (IsSpareBoardBoot()) { - LOG(INFO) << "spare board boot", no need to determine the battery"; + LOG(INFO) << "this is spare board boot, no need to determine the battery"; return true; } static constexpr auto levelIdx = "lowBatteryLevel"; -- Gitee