From ecb1be59f48653718436090c7041ada732a42143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 4 Sep 2024 07:28:25 +0000 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A55.0-Release=20=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E9=BB=84=E5=8C=BA=E5=88=86=E6=94=AF=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- .../sa_loader/include/base_service_kits_impl.h | 2 +- .../engine/include/update_service_kits_impl.h | 2 ++ .../engine/src/update_service_kits_impl.cpp | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/foundations/ability/sa_loader/include/base_service_kits_impl.h b/foundations/ability/sa_loader/include/base_service_kits_impl.h index c3e5ae02..5fc14df1 100644 --- a/foundations/ability/sa_loader/include/base_service_kits_impl.h +++ b/foundations/ability/sa_loader/include/base_service_kits_impl.h @@ -41,6 +41,7 @@ protected: sptr GetService(); void ResetRemoteService(); virtual void RegisterCallback(){}; + virtual void ResetService(const wptr &remote); protected: std::recursive_mutex remoteServerLock_; @@ -50,7 +51,6 @@ protected: private: void AddDeathRecipient(const sptr &object); - void ResetService(const wptr &remote); private: bool isNeedAddDeathRecipient_ = true; 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 2409f2d0..f04b1105 100644 --- a/interfaces/inner_api/engine/include/update_service_kits_impl.h +++ b/interfaces/inner_api/engine/include/update_service_kits_impl.h @@ -88,12 +88,14 @@ public: protected: void RegisterCallback() override; + void ResetService(const wptr &remote) override; #ifndef UPDATER_UT private: #endif std::map> remoteUpdateCallbackMap_; UpgradeInfo upgradeInfo_{}; + int32_t retryTimes_ = 0; }; } // namespace OHOS::UpdateEngine #endif // UPDATE_SERVICE_KITS_IMPL_H 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 ada4fe92..060b2888 100644 --- a/interfaces/inner_api/engine/src/update_service_kits_impl.cpp +++ b/interfaces/inner_api/engine/src/update_service_kits_impl.cpp @@ -270,4 +270,18 @@ void UpdateServiceKitsImpl::RegisterCallback() remoteServer_->RegisterUpdateCallback(iter.first, iter.second); } } + +void UpdateServiceKitsImpl::ResetService(const wptr &remote) +{ + BaseServiceKitsImpl::ResetService(remote); + constexpr int32_t retryMaxTimes = 3; + ENGINE_LOGI("ResetService, remoteUpdateCallbackMap_: %{public}zu, retryTimes_: %{public}d", + remoteUpdateCallbackMap_.size(), retryTimes_); + if (!remoteUpdateCallbackMap_.empty() && retryTimes_ < retryMaxTimes) { + ENGINE_LOGI("ResetService, need resume register callback"); + auto updateService = GetService(); // 重新连接注册回调 + retryTimes_++; + ENGINE_LOGI("ResetService, reconnect service %{public}s", (updateService != nullptr) ? "success" : "fail"); + } +} } // namespace OHOS::UpdateEngine -- Gitee