From 35ec8174795bd73036c8a19efd31e2646311d17d Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Wed, 15 May 2024 16:05:53 +0800 Subject: [PATCH] Install app update cloud_info Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 15 +++++++++++++++ .../service/cloud/cloud_service_impl.h | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index cc164614d..6ba676e34 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -648,6 +648,16 @@ std::pair CloudServiceImpl::GetCloudInfoFromServer(int32_t u return { SUCCESS, cloudInfo }; } +int32_t CloudServiceImpl::UpdateCloudInfoFromServer(int32_t user) +{ + auto [status, cloudInfo] = GetCloudInfoFromServer(user); + if (status != SUCCESS || !cloudInfo.IsValid()) { + ZLOGE("userId:%{public}d, status:%{public}d", user, status); + return E_ERROR; + } + return MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true) ? E_OK : E_ERROR; +} + bool CloudServiceImpl::UpdateCloudInfo(int32_t user) { auto [status, cloudInfo] = GetCloudInfoFromServer(user); @@ -818,6 +828,11 @@ int32_t CloudServiceImpl::CloudStatic::OnAppUninstall(const std::string &bundleN return E_OK; } +int32_t CloudServiceImpl::CloudStatic::OnAppInstall(const std::string &bundleName, int32_t user, int32_t index) +{ + return UpdateCloudInfoFromServer(user); +} + void CloudServiceImpl::GetSchema(const Event &event) { auto &rdbEvent = static_cast(event); diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index 537c655d4..3e2fab7b7 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -76,6 +76,7 @@ private: public: ~CloudStatic() override {}; int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; + int32_t OnAppInstall(const std::string &bundleName, int32_t user, int32_t index) override; }; class Factory { public: @@ -123,9 +124,10 @@ private: bool DoCloudSync(int32_t user); bool StopCloudSync(int32_t user); - std::pair GetCloudInfo(int32_t userId); - std::pair GetCloudInfoFromMeta(int32_t userId); - std::pair GetCloudInfoFromServer(int32_t userId); + static std::pair GetCloudInfo(int32_t userId); + static std::pair GetCloudInfoFromMeta(int32_t userId); + static std::pair GetCloudInfoFromServer(int32_t userId); + static int32_t UpdateCloudInfoFromServer(int32_t user); std::pair GetSchemaMeta(int32_t userId, const std::string &bundleName, int32_t instanceId); std::pair GetAppSchemaFromServer(int32_t user, const std::string &bundleName); -- Gitee