From 5dfcf6892e711f550616e79d65642c372207b1dc Mon Sep 17 00:00:00 2001 From: lvchao Date: Thu, 29 May 2025 20:54:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:open=E3=80=81close=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=8F=98=E6=88=90=E7=A7=81=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lvchao --- .../service/object/include/object_manager.h | 5 +++-- .../service/object/src/object_manager.cpp | 12 ++++++++++++ .../service/object/src/object_service_impl.cpp | 5 +---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/services/distributeddataservice/service/object/include/object_manager.h b/services/distributeddataservice/service/object/include/object_manager.h index 158b5c50a..c87f1196a 100644 --- a/services/distributeddataservice/service/object/include/object_manager.h +++ b/services/distributeddataservice/service/object/include/object_manager.h @@ -100,8 +100,6 @@ public: void NotifyAssetsReady(const std::string& objectKey, const std::string& bundleName, const std::string& srcNetworkId = ""); void NotifyAssetsStart(const std::string& objectKey, const std::string& srcNetworkId = ""); - void CloseAfterMinute(); - int32_t Open(); void SetThreadPool(std::shared_ptr executors); UriToSnapshot GetSnapShots(const std::string &bundleName, const std::string &storeName); int32_t BindAsset(const uint32_t tokenId, const std::string& appId, const std::string& sessionId, @@ -109,6 +107,7 @@ public: int32_t OnAssetChanged(const uint32_t tokenId, const std::string& appId, const std::string& sessionId, const std::string& deviceId, const ObjectStore::Asset& asset); void DeleteSnapshot(const std::string &bundleName, const std::string &sessionId); + int32_t AutoLaunchStore(); private: constexpr static const char *SEPERATOR = "_"; constexpr static const char *TIME_REGEX = "_\\d{10}_p_"; @@ -183,6 +182,8 @@ private: void PullAssets(const std::map& data, const SaveInfo& saveInfo); std::map GetObjectData(const ObjectRecord& changedData, SaveInfo& saveInfo, bool& hasAsset); + void CloseAfterMinute(); + int32_t Open(); inline std::string GetPropertyPrefix(const std::string &appId, const std::string &sessionId) { return appId + SEPERATOR + sessionId + SEPERATOR + DmAdaper::GetInstance().GetLocalDevice().udid + SEPERATOR; diff --git a/services/distributeddataservice/service/object/src/object_manager.cpp b/services/distributeddataservice/service/object/src/object_manager.cpp index 859de7085..958470f18 100644 --- a/services/distributeddataservice/service/object/src/object_manager.cpp +++ b/services/distributeddataservice/service/object/src/object_manager.cpp @@ -1312,5 +1312,17 @@ void ObjectStoreManager::DeleteSnapshot(const std::string& bundleName, const std }); snapshots_.Erase(snapshotKey); } + +int32_t ObjectStoreManager::AutoLaunchStore() +{ + int32_t status = Open(); + if (status != OBJECT_SUCCESS) { + ZLOGE("Open fail %{public}d", status); + return status; + } + CloseAfterMinute(); + ZLOGI("Auto launch, close after a minute"); + return OBJECT_SUCCESS; +} } // namespace DistributedObject } // namespace OHOS diff --git a/services/distributeddataservice/service/object/src/object_service_impl.cpp b/services/distributeddataservice/service/object/src/object_service_impl.cpp index 71f6195e7..5df3363c7 100644 --- a/services/distributeddataservice/service/object/src/object_service_impl.cpp +++ b/services/distributeddataservice/service/object/src/object_service_impl.cpp @@ -324,13 +324,10 @@ int32_t ObjectServiceImpl::ResolveAutoLaunch(const std::string &identifier, Dist continue; } if (storeMeta.bundleName == DistributedData::Bootstrap::GetInstance().GetProcessLabel()) { - int32_t status = DistributedObject::ObjectStoreManager::GetInstance()->Open(); + int32_t status = DistributedObject::ObjectStoreManager::GetInstance()->AutoLaunchStore(); if (status != OBJECT_SUCCESS) { - ZLOGE("Open fail %{public}d", status); continue; } - DistributedObject::ObjectStoreManager::GetInstance()->CloseAfterMinute(); - ZLOGI("Auto launch, close after a minute"); return OBJECT_SUCCESS; } } -- Gitee