diff --git a/frameworks/js/napi/update/src/local_updater.cpp b/frameworks/js/napi/update/src/local_updater.cpp index 1621450197aa29fbe655fcdfea7fd85d0962ae7c..b52c026b27c664d1a4473ef7dd2b2b651754c7b2 100644 --- a/frameworks/js/napi/update/src/local_updater.cpp +++ b/frameworks/js/napi/update/src/local_updater.cpp @@ -127,14 +127,21 @@ napi_value LocalUpdater::ApplyNewVersion(napi_env env, napi_callback_info info) return StartParamErrorSession(env, info, CALLBACK_POSITION_TWO); } + std::vector packageNames; + for (const UpgradeFile &upgradeFile : upgradeFiles) { + packageNames.emplace_back(upgradeFile.filePath); + } + SessionParams sessionParams(SessionType::SESSION_APPLY_NEW_VERSION, CALLBACK_POSITION_TWO, true); napi_value retValue = StartSession(env, info, sessionParams, - [upgradeFiles](void *context) -> int { - ENGINE_LOGI("ApplyNewVersion %s", upgradeFiles[0].filePath.c_str()); + [packageNames](void *context) -> int { + for (const std::string &packageName : packageNames) { + ENGINE_LOGI("ApplyNewVersion %{public}s", packageName.c_str()); + } BusinessError *businessError = reinterpret_cast(context); UpgradeInfo upgradeInfo; upgradeInfo.upgradeApp = LOCAL_UPGRADE_INFO; - return UpdateServiceKits::GetInstance().ApplyNewVersion(upgradeInfo, MISC_FILE, upgradeFiles[0].filePath, + return UpdateServiceKits::GetInstance().ApplyNewVersion(upgradeInfo, MISC_FILE, packageNames, *businessError); }); PARAM_CHECK(retValue != nullptr, return nullptr, "Failed to ApplyNewVersion"); diff --git a/interfaces/inner_api/engine/include/update_service_kits_impl.h b/interfaces/inner_api/engine/include/update_service_kits_impl.h index 9640797732a16696fc5a95b79b8c1cadfa3ae499..2409f2d014786ba3d7516581e9e7dfca29807189 100644 --- a/interfaces/inner_api/engine/include/update_service_kits_impl.h +++ b/interfaces/inner_api/engine/include/update_service_kits_impl.h @@ -80,8 +80,8 @@ public: int32_t FactoryReset(BusinessError &businessError) final; - int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, const std::string &packageName, - BusinessError &businessError) final; + int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, + const std::vector &packageNames, BusinessError &businessError) final; int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) final; diff --git a/interfaces/inner_api/engine/include/update_service_proxy.h b/interfaces/inner_api/engine/include/update_service_proxy.h index f77464e8cd2f4407654fcc9ddf1839e44643d4ed..a0655af844c6aed1aa46d7b5a5c0d3f32ac79f99 100644 --- a/interfaces/inner_api/engine/include/update_service_proxy.h +++ b/interfaces/inner_api/engine/include/update_service_proxy.h @@ -72,8 +72,8 @@ public: int32_t FactoryReset(BusinessError &businessError) override; - int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, const std::string &packageName, - BusinessError &businessError) override; + int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, + const std::vector &packageNames, BusinessError &businessError) override; int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) override; diff --git a/interfaces/inner_api/engine/src/update_service_kits_impl.cpp b/interfaces/inner_api/engine/src/update_service_kits_impl.cpp index dc9cce5d9f5bf257b77321838887a85a9cdaa1ef..ada4fe92b9db027f854829e0e3d87b43567cf66e 100644 --- a/interfaces/inner_api/engine/src/update_service_kits_impl.cpp +++ b/interfaces/inner_api/engine/src/update_service_kits_impl.cpp @@ -242,12 +242,12 @@ int32_t UpdateServiceKitsImpl::FactoryReset(BusinessError &businessError) } int32_t UpdateServiceKitsImpl::ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) + const std::vector &packageNames, BusinessError &businessError) { ENGINE_LOGI("UpdateServiceKitsImpl::ApplyNewVersion"); auto updateService = GetService(); RETURN_FAIL_WHEN_SERVICE_NULL(updateService); - int32_t ret = updateService->ApplyNewVersion(info, miscFile, packageName, businessError); + int32_t ret = updateService->ApplyNewVersion(info, miscFile, packageNames, businessError); ENGINE_CHECK((ret) == INT_CALL_SUCCESS, ResetRemoteService(), "ApplyNewVersion ipc error"); return ret; } diff --git a/interfaces/inner_api/engine/src/update_service_proxy.cpp b/interfaces/inner_api/engine/src/update_service_proxy.cpp index 4a0442388e7b3b35f7cdcab1e0ca0ad948ca7c0e..cc2f65f9f62bcaad6f7a658b4f394a1bbf0b805c 100644 --- a/interfaces/inner_api/engine/src/update_service_proxy.cpp +++ b/interfaces/inner_api/engine/src/update_service_proxy.cpp @@ -471,7 +471,7 @@ int32_t UpdateServiceProxy::FactoryReset(BusinessError &businessError) } int32_t UpdateServiceProxy::ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) + const std::vector &packageNames, BusinessError &businessError) { ENGINE_LOGI("UpdateServiceProxy::ApplyNewVersion"); auto remote = Remote(); @@ -481,7 +481,10 @@ int32_t UpdateServiceProxy::ApplyNewVersion(const UpgradeInfo &info, const std:: RETURN_WHEN_TOKEN_WRITE_FAIL(data); MessageParcelHelper::WriteUpgradeInfo(data, info); data.WriteString16(Str8ToStr16(miscFile)); - data.WriteString16(Str8ToStr16(packageName)); + data.WriteInt32(static_cast(packageNames.size())); + for (size_t i = 0; i < packageNames.size(); i++) { + data.WriteString16(Str8ToStr16(packageNames[i])); + } MessageParcel reply; MessageOption option; diff --git a/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h b/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h index 1d98f6861c13f3bf1c7e8f9697a987995d1c13c1..ed2b03c77332989c80edf29b8afd9d6146c5056e 100644 --- a/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h +++ b/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h @@ -27,7 +27,7 @@ public: virtual ~IServiceLocalUpdater() = default; virtual int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) = 0; + const std::vector &packageNames, BusinessError &businessError) = 0; virtual int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) = 0; diff --git a/interfaces/inner_api/include/update_service_kits.h b/interfaces/inner_api/include/update_service_kits.h index f3c8122ae019fe050be4938687e0f8fb77e5f148..39d38b01d55671df7e2d08f0292cf2b1f3cf9b88 100644 --- a/interfaces/inner_api/include/update_service_kits.h +++ b/interfaces/inner_api/include/update_service_kits.h @@ -99,7 +99,7 @@ public: virtual int32_t FactoryReset(BusinessError &businessError) = 0; virtual int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) = 0; + const std::vector &packageNames, BusinessError &businessError) = 0; virtual int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) = 0; diff --git a/interfaces/inner_api/modulemgr/src/module_manager.cpp b/interfaces/inner_api/modulemgr/src/module_manager.cpp index 985f079cfc84baf61778af123776bcf898b52cab..ad4736b07f4b1cf649a49eb444a1744bb1cfa3e8 100644 --- a/interfaces/inner_api/modulemgr/src/module_manager.cpp +++ b/interfaces/inner_api/modulemgr/src/module_manager.cpp @@ -94,7 +94,7 @@ int32_t ModuleManager::HandleFunc(uint32_t code, MessageParcel &data, MessagePar if (!IsMapFuncExist(code)) { UTILS_LOGI("code %{public}d not exist", code); } else { - UTILS_LOGI("code %{public}d already exist", code); + UTILS_LOGI("code %{public}d called", code); return ((RequestFuncType)onRemoteRequestFuncMap_[code])(code, data, reply, option); } return 0; diff --git a/services/engine/include/update_service.h b/services/engine/include/update_service.h index 92d70bd6c38c19775ac877ab20d7677cec0f5633..a123318f0677f1f1381dd6e6aaa6f28fb2d8bed6 100644 --- a/services/engine/include/update_service.h +++ b/services/engine/include/update_service.h @@ -83,8 +83,8 @@ public: int32_t FactoryReset(BusinessError &businessError) override; - int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, const std::string &packageName, - BusinessError &businessError) override; + int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, + const std::vector &packageNames, BusinessError &businessError) override; int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) override; diff --git a/services/engine/include/update_service_local_updater.h b/services/engine/include/update_service_local_updater.h index 8e8f5e908270f7652cccba9d56f9cca36e01de68..84e102598f3e8afbba85020c1d476e1ceeaa8a5a 100644 --- a/services/engine/include/update_service_local_updater.h +++ b/services/engine/include/update_service_local_updater.h @@ -30,8 +30,8 @@ public: DISALLOW_COPY_AND_MOVE(UpdateServiceLocalUpdater); - int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, const std::string &packageName, - BusinessError &businessError) final; + int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, + const std::vector &packageNames, BusinessError &businessError) final; int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, BusinessError &businessError) final; diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 8989779eb21bc737f414cb5f4cc5a711eae6a657..b31582aa5235f221542f43d00b27788120252bcd 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -323,14 +323,14 @@ int32_t UpdateService::FactoryReset(BusinessError &businessError) } int32_t UpdateService::ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) + const std::vector &packageNames, BusinessError &businessError) { sptr localUpdater = new UpdateServiceLocalUpdater(); if (localUpdater == nullptr) { ENGINE_LOGI("FactoryReset localUpdater null"); return INT_CALL_FAIL; } - return localUpdater->ApplyNewVersion(info, miscFile, packageName, businessError); + return localUpdater->ApplyNewVersion(info, miscFile, packageNames, businessError); } int32_t UpdateService::VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, diff --git a/services/engine/src/update_service_local_updater.cpp b/services/engine/src/update_service_local_updater.cpp index 7f290737b30c417dbac78d76af79ace59f2eb569..1197b87226025a7aa108517b44f1877fd83e6d82 100644 --- a/services/engine/src/update_service_local_updater.cpp +++ b/services/engine/src/update_service_local_updater.cpp @@ -25,13 +25,11 @@ namespace OHOS { namespace UpdateEngine { int32_t UpdateServiceLocalUpdater::ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, - const std::string &packageName, BusinessError &businessError) + const std::vector &packageNames, BusinessError &businessError) { #ifndef UPDATER_UT SYS_EVENT_SYSTEM_UPGRADE(0, UpdateSystemEvent::UPGRADE_START); businessError.errorNum = CallResult::SUCCESS; - std::vector packageNames; - packageNames.push_back(packageName); int32_t ret = RebootAndInstallSdcardPackage(miscFile, packageNames) ? INT_CALL_SUCCESS : INT_CALL_FAIL; ENGINE_LOGI("ApplyNewVersion result : %{public}d", ret); SYS_EVENT_SYSTEM_UPGRADE( diff --git a/services/engine/src/update_service_stub.cpp b/services/engine/src/update_service_stub.cpp index 904837b6b0cfecf59b3c912b0e5b05b83d483106..4e1966af5b3dc5cd7a875f14ebfad6010343e839 100644 --- a/services/engine/src/update_service_stub.cpp +++ b/services/engine/src/update_service_stub.cpp @@ -34,6 +34,7 @@ namespace OHOS { namespace UpdateEngine { constexpr const pid_t ROOT_UID = 0; constexpr const pid_t EDM_UID = 3057; +static constexpr int32_t MAX_VECTOR_SIZE = 128; #define CALL_RESULT_TO_IPC_RESULT(callResult) ((callResult) + CALL_RESULT_OFFSET) @@ -356,9 +357,18 @@ int32_t UpdateServiceStub::ApplyNewVersionStub(UpdateServiceStubPtr service, UpgradeInfo upgradeInfo; MessageParcelHelper::ReadUpgradeInfo(data, upgradeInfo); string miscFile = Str16ToStr8(data.ReadString16()); - string packageName = Str16ToStr8(data.ReadString16()); + + vector packageNames; + int32_t size = data.ReadInt32(); + if (size > MAX_VECTOR_SIZE) { + ENGINE_LOGE("ReadComponentDescriptions size is over, size=%{public}d", size); + return INT_CALL_FAIL; + } + for (size_t i = 0; i < static_cast(size); i++) { + packageNames.emplace_back(Str16ToStr8(data.ReadString16())); + } BusinessError businessError; - int32_t ret = service->ApplyNewVersion(upgradeInfo, miscFile, packageName, businessError); + int32_t ret = service->ApplyNewVersion(upgradeInfo, miscFile, packageNames, businessError); ENGINE_CHECK(ret == INT_CALL_SUCCESS, return ret, "Failed to ApplyNewVersion"); MessageParcelHelper::WriteBusinessError(reply, businessError); return INT_CALL_SUCCESS;