diff --git a/services/distributeddataservice/service/object/include/object_manager.h b/services/distributeddataservice/service/object/include/object_manager.h index 158b5c50a01490a53088d2e1f63dc64cc64e144c..c87f1196a38ce52ad09aae8655197174e781144a 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 859de7085d019a26f19bc35140329b36d32a3760..958470f18cce7a13ca498683ee70ae92ac86761d 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 71f6195e7a2c4182f769693e996f633a94bc5875..5df3363c770e7da4ee9908f7d845c8cc698372f5 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; } }