From 4537ae59cd91ee4001ea83fa00001781554aeefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=98=E7=BD=97=E5=AE=87?= Date: Mon, 9 Jun 2025 15:14:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:1.=E5=9B=9E=E9=80=80slot=5Finfo=20ipc?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3;2.=E8=A7=A3=E5=86=B3static=5Flink=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E9=97=AE=E9=A2=98;3.=E6=B5=81=E5=BC=8F=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8D=87=E7=BA=A7=E6=8E=A5=E5=8F=A3=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 甘罗宇 --- bundle.json | 2 +- interfaces/kits/slot_info/BUILD.gn | 2 +- interfaces/kits/slot_info/slot_info.cpp | 36 ++++-------- services/BUILD.gn | 2 + services/applypatch/command_process.cpp | 2 +- .../update_bin/component_processor.cpp | 3 +- services/include/updater/updater.h | 4 ++ services/stream_update/bin_chunk_update.cpp | 14 ++--- services/updater.cpp | 24 +++++++- services/updater_binary/BUILD.gn | 1 - .../updater_binary/update_image_block.cpp | 9 +-- .../updater_binary/update_image_patch.cpp | 6 +- services/updater_binary/update_processor.cpp | 3 +- services/updater_main.cpp | 12 ++++ updater_default_cfg.gni | 2 +- utils/include/utils.h | 3 + utils/utils.cpp | 55 ++++++++++++++++++- 17 files changed, 123 insertions(+), 57 deletions(-) diff --git a/bundle.json b/bundle.json index 68550561..b6cf4ece 100644 --- a/bundle.json +++ b/bundle.json @@ -50,7 +50,7 @@ "init", "hdc", "drivers_interface_input", - "drivers_interface_partitionslot", + "drivers_peripheral_partitionslot", "c_utils", "hilog", "selinux_adapter", diff --git a/interfaces/kits/slot_info/BUILD.gn b/interfaces/kits/slot_info/BUILD.gn index 98db2059..3aff7f72 100644 --- a/interfaces/kits/slot_info/BUILD.gn +++ b/interfaces/kits/slot_info/BUILD.gn @@ -29,7 +29,7 @@ ohos_static_library("libslotinfo") { defines = [ "UPDATER_AB_SUPPORT" ] external_deps = [ "c_utils:utils", - "drivers_interface_partitionslot:libpartitionslot_proxy_1.0", + "drivers_peripheral_partitionslot:libpartition_slot_manager", "hilog:libhilog_base", "init:libbegetutil_static", ] diff --git a/interfaces/kits/slot_info/slot_info.cpp b/interfaces/kits/slot_info/slot_info.cpp index 0948b5f5..e6f2787d 100644 --- a/interfaces/kits/slot_info/slot_info.cpp +++ b/interfaces/kits/slot_info/slot_info.cpp @@ -17,8 +17,7 @@ #include "log/log.h" #ifdef UPDATER_AB_SUPPORT -#include "v1_0/ipartition_slot.h" -using namespace OHOS::HDI::Partitionslot::V1_0; +#include "partitionslot_manager.h" #endif namespace Updater { @@ -37,15 +36,10 @@ void SetActiveSlot() #else void GetPartitionSuffix(std::string &suffix) { - sptr partitionslot = - OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); - if (partitionslot == nullptr) { - LOG(ERROR) << "partitionslot ptr is nullptr"; - return; - } + OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num suffix = ""; @@ -53,7 +47,7 @@ void GetPartitionSuffix(std::string &suffix) } int32_t updateSlot = curSlot == 1 ? 2 : 1; - ret = partitionslot->GetSlotSuffix(updateSlot, suffix); + ret = psMgr.GetSlotSuffix(updateSlot, suffix); if (ret != 0) { LOG(ERROR) << "Get slot suffix error, partitionPath: " << suffix; suffix = ""; @@ -62,22 +56,17 @@ void GetPartitionSuffix(std::string &suffix) void GetActivePartitionSuffix(std::string &suffix) { - sptr partitionslot = - OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); - if (partitionslot == nullptr) { - LOG(ERROR) << "partitionslot ptr is nullptr"; - return; - } + OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num suffix = ""; return; } - ret = partitionslot->GetSlotSuffix(curSlot, suffix); + ret = psMgr.GetSlotSuffix(curSlot, suffix); if (ret != 0) { LOG(ERROR) << "Get slot suffix error, partitionPath: " << suffix; suffix = ""; @@ -86,22 +75,17 @@ void GetActivePartitionSuffix(std::string &suffix) void SetActiveSlot() { - sptr partitionslot = - OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); - if (partitionslot == nullptr) { - LOG(ERROR) << "partitionslot ptr is nullptr"; - return; - } + OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num return; } int32_t activeSlot = curSlot == 1 ? 2 : 1; - ret = partitionslot->SetActiveSlot(activeSlot); + ret = psMgr.SetActiveSlot(activeSlot); if (ret != 0) { LOG(ERROR) << "Set active slot error, slot: " << activeSlot; } diff --git a/services/BUILD.gn b/services/BUILD.gn index f1c260f5..694a757c 100755 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -99,6 +99,7 @@ ohos_static_library("libupdater_static") { "openssl:libcrypto_shared", "openssl:libssl_shared", "zlib:libz", + "drivers_peripheral_partitionslot:libpartition_slot_manager", ] if (updater_ui_support) { external_deps += [ "drivers_interface_input:libinput_proxy_1.0" ] @@ -177,6 +178,7 @@ ohos_static_library("libupdater") { "openssl:libcrypto_shared", "openssl:libssl_shared", "zlib:libz", + "drivers_peripheral_partitionslot:libpartition_slot_manager", ] # add updater custom library diff --git a/services/applypatch/command_process.cpp b/services/applypatch/command_process.cpp index dba56dfb..2ebf2af4 100644 --- a/services/applypatch/command_process.cpp +++ b/services/applypatch/command_process.cpp @@ -247,7 +247,7 @@ CommandResult DiffAndMoveCommandFn::Execute(const Command ¶ms) offset = Utils::String2Int(params.GetArgumentByPos(pos++), Utils::N_DEC); } size_t patchLength = Utils::String2Int(params.GetArgumentByPos(pos++), Utils::N_DEC); - if (params.GetTransferParams()->isUpdaterMode) { + if (Utils::IsUpdaterMode()) { uint8_t *patchBuffer = params.GetTransferParams()->dataBuffer + offset; ret = WriteDiffToBlock(params, buffer, patchBuffer, patchLength, targetBlock); } else { diff --git a/services/flow_update/update_bin/component_processor.cpp b/services/flow_update/update_bin/component_processor.cpp index f2cfccc1..2794d04e 100644 --- a/services/flow_update/update_bin/component_processor.cpp +++ b/services/flow_update/update_bin/component_processor.cpp @@ -259,8 +259,7 @@ int RawImgProcessor::GetWritePathAndOffset(const std::string &partitionName, std #ifndef UPDATER_UT if (partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); writePath += suffix; } LOG(INFO) << "write partition path: " << writePath; diff --git a/services/include/updater/updater.h b/services/include/updater/updater.h index bcdf5f37..ab6f212c 100644 --- a/services/include/updater/updater.h +++ b/services/include/updater/updater.h @@ -97,8 +97,12 @@ void ProgressSmoothHandler(int beginProgress, int endProgress, UpdaterStatus SetUpdateSlotParam(UpdaterParams &upParams, bool isUpdateCurrSlot); +UpdaterStatus SetUpdateSuffixParam(); + UpdaterStatus ClearUpdateSlotParam(); +UpdaterStatus ClearUpdateSuffixParam(); + UpdaterStatus DoInstallUpdaterPackage(Hpackage::PkgManager::PkgManagerPtr pkgManager, UpdaterParams &upParams, PackageUpdateMode updateMode); diff --git a/services/stream_update/bin_chunk_update.cpp b/services/stream_update/bin_chunk_update.cpp index a9140fd9..23a5faa2 100755 --- a/services/stream_update/bin_chunk_update.cpp +++ b/services/stream_update/bin_chunk_update.cpp @@ -214,15 +214,11 @@ UpdateResultCode BinChunkUpdate::UpdateBinHash(uint8_t *data, uint32_t &len) return STREAM_UPDATE_FAILURE; } - //切换ab分区 - #ifndef UPDATER_UT - SetActiveSlot(); - #else int result = remove("/data/updater/test.txt"); if (result != 0) { LOG(ERROR) << "Failed to remove /data/updater/test.txt, error: " << strerror(errno); } - #endif + LOG(DEBUG) << "BinChunkUpdate::UpdateBinHash exit"; return STREAM_UPDATE_COMPLETE; } @@ -518,10 +514,9 @@ bool BinChunkUpdate::OpenDevPath() targetPath = devPath; if (updateInfo_.curPartition != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); targetPath += suffix; - GetActivePartitionSuffix(suffix); + suffix = Utils::GetUpdateActiveSuffix(); srcPath += suffix; } @@ -761,8 +756,7 @@ std::string BinChunkUpdate::ComputeFileHash(const std::string &partitionName, #ifndef UPDATER_UT std::string devPath = GetBlockDeviceByMountPoint(partitionName); if (partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); devPath += suffix; } #else diff --git a/services/updater.cpp b/services/updater.cpp index f0fba539..948ffe54 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -52,6 +52,7 @@ #include "updater_ui_stub.h" #include "utils.h" #include "write_state/write_state.h" +#include "slot_info/slot_info.h" namespace Updater { using Updater::Utils::SplitString; @@ -323,7 +324,18 @@ UpdaterStatus SetUpdateSlotParam(UpdaterParams &upParams, bool isUpdateCurrSlot) } return UPDATE_SUCCESS; } - + +UpdaterStatus SetUpdateSuffixParam() +{ + std::string updateSuffix = ""; + GetPartitionSuffix(updateSuffix); + if (!Utils::SetUpdateSuffix(updateSuffix)) { + LOG(ERROR) << "set update.part.suffix fail"; + return UPDATE_ERROR; + } + return UPDATE_SUCCESS; +} + UpdaterStatus ClearUpdateSlotParam() { if (!Utils::IsVabDevice()) { @@ -337,6 +349,16 @@ UpdaterStatus ClearUpdateSlotParam() return UPDATE_SUCCESS; } +UpdaterStatus ClearUpdateSuffixParam() +{ + std::string updateSuffix = ""; + if (!Utils::SetUpdateSuffix(updateSuffix)) { + LOG(ERROR) << "clear update.part.suffix fail"; + return UPDATE_ERROR; + } + return UPDATE_SUCCESS; +} + UpdaterStatus DoInstallUpdaterBinfile(PkgManager::PkgManagerPtr pkgManager, UpdaterParams &upParams, PackageUpdateMode updateMode) { diff --git a/services/updater_binary/BUILD.gn b/services/updater_binary/BUILD.gn index e196cd23..afbb7c39 100644 --- a/services/updater_binary/BUILD.gn +++ b/services/updater_binary/BUILD.gn @@ -58,7 +58,6 @@ ohos_static_library("libupdater_binary") { deps = [ "${updater_path}/interfaces/kits/misc_info:libmiscinfo", - "${updater_path}/interfaces/kits/slot_info:libslotinfo", "${updater_path}/services/applypatch:libapplypatch", "${updater_path}/services/diffpatch/patch:libpatch", "${updater_path}/services/flow_update/update_bin:libBinFlowUpdate", diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index 95a6048f..a37187bf 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -181,8 +181,7 @@ static int32_t GetUpdateBlockInfo(struct UpdateBlockInfo &infos, Uscript::UScrip infos.devPath = GetBlockDeviceByMountPoint(infos.partitionName); #ifndef UPDATER_UT if (infos.partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); infos.devPath += suffix; } #else @@ -498,8 +497,7 @@ int32_t UScriptInstructionBlockCheck::Execute(Uscript::UScriptEnv &env, Uscript: auto devPath = GetBlockDeviceByMountPoint(partitionName); #ifndef UPDATER_UT if (partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); devPath += suffix; } #else @@ -767,8 +765,7 @@ int32_t UScriptInstructionShaCheck::Execute(Uscript::UScriptEnv &env, Uscript::U } #ifndef UPDATER_UT if (partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); devPath += suffix; } LOG(INFO) << "write partition path: " << devPath; diff --git a/services/updater_binary/update_image_patch.cpp b/services/updater_binary/update_image_patch.cpp index ec3b3c58..8e74f466 100644 --- a/services/updater_binary/update_image_patch.cpp +++ b/services/updater_binary/update_image_patch.cpp @@ -73,8 +73,7 @@ int32_t USInstrImagePatch::GetParam(Uscript::UScriptContext &context, ImagePatch para.devPath = GetBlockDeviceByMountPoint(para.partName); #ifndef UPDATER_UT if (para.partName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); para.devPath += suffix; } #else @@ -264,8 +263,7 @@ int32_t USInstrImageShaCheck::GetParam(Uscript::UScriptContext &context, CheckPa para.devPath = GetBlockDeviceByMountPoint(para.partName); #ifndef UPDATER_UT if (para.partName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); para.devPath += suffix; } #else diff --git a/services/updater_binary/update_processor.cpp b/services/updater_binary/update_processor.cpp index 78a17325..e38ee4ab 100644 --- a/services/updater_binary/update_processor.cpp +++ b/services/updater_binary/update_processor.cpp @@ -460,8 +460,7 @@ int UScriptInstructionRawImageWrite::GetWritePathAndOffset(const std::string &pa #ifndef UPDATER_UT if (partitionName != "/userdata") { - std::string suffix = ""; - GetPartitionSuffix(suffix); + std::string suffix = Utils::GetUpdateSuffix(); writePath += suffix; } LOG(INFO) << "write partition path: " << writePath; diff --git a/services/updater_main.cpp b/services/updater_main.cpp index d30ad727..56489829 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -689,6 +689,11 @@ static UpdaterStatus PreUpdatePackages(UpdaterParams &upParams) LOG(ERROR) << "SetUpdateSlotParam failed"; return UPDATE_ERROR; } + // set update slot suffix + if(SetUpdateSuffixParam() != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateSuffixParam failed"; + return UPDATE_ERROR; + } // verify package first if (VerifyCommonFiles(upParams) != UPDATE_SUCCESS) { return UPDATE_CORRUPT; // verify package failed must return UPDATE_CORRUPT, ux need it !!! @@ -918,6 +923,7 @@ static void PostUpdate(UpdaterParams &upParams, UpdaterStatus &status, status = CheckAndSetSlot(upParams); } ClearUpdateSlotParam(); + ClearUpdateSuffixParam(); ShowSuccessUi(upParams, status); bool updateResult = (status == UPDATE_SUCCESS); @@ -980,6 +986,11 @@ static UpdaterStatus PreSdcardUpdatePackages(UpdaterParams &upParams) LOG(ERROR) << "SetUpdateSlotParam failed"; return UPDATE_ERROR; } + // set update slot suffix + if (SetUpdateSuffixParam() != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateSuffixParam failed"; + return UPDATE_ERROR; + } UpdaterStatus status = VerifyPackages(upParams); if (status != UPDATE_SUCCESS) { return UPDATE_CORRUPT; // verify package failed must return UPDATE_CORRUPT, ux need it !!! @@ -996,6 +1007,7 @@ static UpdaterStatus PreSdcardUpdatePackages(UpdaterParams &upParams) static void PostSdcardUpdatePackages(UpdaterParams &upParams, UpdaterStatus &status) { ClearUpdateSlotParam(); + ClearUpdateSuffixParam(); if (Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE)) { PostUpdatePackages(upParams, status); } else if (status == UPDATE_SUCCESS) { diff --git a/updater_default_cfg.gni b/updater_default_cfg.gni index 7c87383b..130b14a9 100644 --- a/updater_default_cfg.gni +++ b/updater_default_cfg.gni @@ -13,7 +13,7 @@ import("//build/ohos.gni") -init_feature_ab_partition = false +init_feature_ab_partition = true declare_args() { updater_cfg_file = "" updater_ui_support = true diff --git a/utils/include/utils.h b/utils/include/utils.h index 7cefae4d..c8f93d68 100644 --- a/utils/include/utils.h +++ b/utils/include/utils.h @@ -117,7 +117,10 @@ bool ConvertToDouble(const std::string &str, double &value); bool ConvertToFloat(const std::string &str, float &value); bool IsVabDevice(); bool SetUpdateSlot(int updateSlot); +bool SetUpdateSuffix(std::string stringsuffix); int GetUpdateSlot(); +std::string GetUpdateSuffix(); +std::string GetUpdateActiveSuffix(); #ifndef __WIN32 void SetFileAttributes(const std::string& file, uid_t owner, gid_t group, mode_t mode); #endif diff --git a/utils/utils.cpp b/utils/utils.cpp index 4c81481c..069c83ed 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -1111,7 +1111,30 @@ bool SetUpdateSlot(int setSlot) } return false; } - + +bool SetUpdateSuffix(std::string stringsuffix) +{ + if (stringsuffix.empty()) { + LOG(ERROR) << "suffix is empty"; + return false; + } + int tryNum = 3; + while (tryNum-- > 0) { + if (SetParameter("update.part.suffix", stringsuffix.c_str()) != 0) { + LOG(ERROR) << "set update.part.suffix fail"; + continue; + } + if (strcmp(GetUpdateSuffix().c_str(), stringsuffix.c_str()) == 0) { + LOG(INFO) << "set update.part.suffix is " << stringsuffix; + return true; + } + if (tryNum != 0) { + sleep(1); + } + } + return false; +} + int GetUpdateSlot() { if (!IsVabDevice()) { @@ -1130,6 +1153,36 @@ int GetUpdateSlot() return updateSlot; } +std::string GetUpdateSuffix() +{ + char paramValue[PARAM_SIZE + 1] = {0}; + if (GetParameter("update.part.suffix", "", paramValue, sizeof(paramValue) - 1) <= 0) { + LOG(ERROR) << "get update.part.suffix failed"; + return std::string(paramValue); + } + LOG(INFO) << "GetUpdateSuffix = " << paramValue; + return std::string(paramValue); +} + +std::string GetUpdateActiveSuffix() +{ + char paramValue[PARAM_SIZE + 1] = {0}; + if (GetParameter("update.part.suffix", "", paramValue, sizeof(paramValue) - 1) <= 0) { + LOG(ERROR) << "get update.part.suffix failed"; + return std::string(paramValue); + } + if (strcmp(paramValue, "_a") == 0) { + strncpy_s(paramValue, sizeof(paramValue), "_b", sizeof("_b")); + } else if (strcmp(paramValue, "_b") == 0) { + strncpy_s(paramValue, sizeof(paramValue), "_a", sizeof("_a")); + } else { + LOG(ERROR) << "Unexpected suffix value: " << paramValue; + return std::string(paramValue); + } + LOG(INFO) << "GetUpdateActiveSuffix = " << paramValue; + return std::string(paramValue); +} + #ifndef __WIN32 void SetFileAttributes(const std::string& file, uid_t owner, gid_t group, mode_t mode) { -- Gitee From 24f8e3242eb29efe5b14b424f7689b13b9807f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=98=E7=BD=97=E5=AE=87?= Date: Mon, 9 Jun 2025 16:10:39 +0800 Subject: [PATCH 2/3] fix code format check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 甘罗宇 --- services/updater.cpp | 2 +- services/updater_main.cpp | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/services/updater.cpp b/services/updater.cpp index 948ffe54..48500398 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -351,7 +351,7 @@ UpdaterStatus ClearUpdateSlotParam() UpdaterStatus ClearUpdateSuffixParam() { - std::string updateSuffix = ""; + std::string updateSuffix = " "; if (!Utils::SetUpdateSuffix(updateSuffix)) { LOG(ERROR) << "clear update.part.suffix fail"; return UPDATE_ERROR; diff --git a/services/updater_main.cpp b/services/updater_main.cpp index 56489829..168ba172 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -662,6 +662,21 @@ static UpdaterStatus VerifyCommonFiles(UpdaterParams &upParams) return UPDATE_SUCCESS; } +static UpdaterStatus SetUpdateParam(UpdaterParams &upParams, bool isUpdateCurrSlot) +{ + // set update slot + if (SetUpdateSlotParam(upParams, false) != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateSlotParam failed"; + return UPDATE_ERROR; + } + // set update suffix + if (SetUpdateSuffixParam() != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateSuffixParam failed"; + return UPDATE_ERROR; + } + return UPDATE_SUCCESS; +} + static UpdaterStatus PreUpdatePackages(UpdaterParams &upParams) { UPDATER_INIT_RECORD; @@ -685,13 +700,8 @@ static UpdaterStatus PreUpdatePackages(UpdaterParams &upParams) (void)DeleteFile(resultPath); LOG(INFO) << "delete last upgrade file"; } - if (SetUpdateSlotParam(upParams, false) != UPDATE_SUCCESS) { - LOG(ERROR) << "SetUpdateSlotParam failed"; - return UPDATE_ERROR; - } - // set update slot suffix - if(SetUpdateSuffixParam() != UPDATE_SUCCESS) { - LOG(ERROR) << "SetUpdateSuffixParam failed"; + if (SetUpdateParam(upParams, false) != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateParam failed"; return UPDATE_ERROR; } // verify package first @@ -982,13 +992,8 @@ static UpdaterStatus PreSdcardUpdatePackages(UpdaterParams &upParams) LOG(ERROR) << "Battery is not sufficient for install package."; return UPDATE_SKIP; } - if (SetUpdateSlotParam(upParams, true) != UPDATE_SUCCESS) { - LOG(ERROR) << "SetUpdateSlotParam failed"; - return UPDATE_ERROR; - } - // set update slot suffix - if (SetUpdateSuffixParam() != UPDATE_SUCCESS) { - LOG(ERROR) << "SetUpdateSuffixParam failed"; + if (SetUpdateParam(upParams, true) != UPDATE_SUCCESS) { + LOG(ERROR) << "SetUpdateParam failed"; return UPDATE_ERROR; } UpdaterStatus status = VerifyPackages(upParams); -- Gitee From 6f72458b40ec3cfa92c5d580288435cde93c9f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=98=E7=BD=97=E5=AE=87?= Date: Mon, 9 Jun 2025 17:12:08 +0800 Subject: [PATCH 3/3] fix tdd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 甘罗宇 --- test/unittest/service_test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/service_test/BUILD.gn b/test/unittest/service_test/BUILD.gn index cdbdf00f..d3588b1a 100644 --- a/test/unittest/service_test/BUILD.gn +++ b/test/unittest/service_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("updater_service_unittest") { deps = [ "${updater_path}/interfaces/kits/misc_info:libmiscinfo", + "${updater_path}/interfaces/kits/slot_info:libslotinfo", "${updater_path}/interfaces/kits/packages:libpackageExt", "${updater_path}/services/applypatch:libapplypatch", "${updater_path}/services/diffpatch/patch:libpatch", -- Gitee