diff --git a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp index 6c69a44933a754cc10b9a26ee4d73c192d7d6242..94b0e5f963a025e6ef4376c8530632f242837acf 100644 --- a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp +++ b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp @@ -31,6 +31,19 @@ using namespace OHOS::NetManagerStandard; using KvStoreUtils = OHOS::DistributedKv::KvStoreUtils; constexpr int32_t DM_OK = 0; constexpr const char *PKG_NAME = "ohos.distributeddata.service"; +static DeviceManagerAdapter::NetworkType Convert(NetManagerStandard::NetBearType bearType) +{ + switch (bearType) { + case NetManagerStandard::BEARER_WIFI: + return DeviceManagerAdapter::WIFI; + case NetManagerStandard::BEARER_CELLULAR: + return DeviceManagerAdapter::CELLULAR; + case NetManagerStandard::BEARER_ETHERNET: + return DeviceManagerAdapter::ETHERNET; + default: + return DeviceManagerAdapter::OTHER; + } +} class DataMgrDmStateCall final : public DistributedHardware::DeviceStateCallback { public: explicit DataMgrDmStateCall(DeviceManagerAdapter &dmAdapter) : dmAdapter_(dmAdapter) {} @@ -98,44 +111,49 @@ private: int32_t NetConnCallbackObserver::NetAvailable(sptr &netHandle) { ZLOGI("OnNetworkAvailable"); - dmAdapter_.SetNetAvailable(true); - dmAdapter_.Online(dmAdapter_.cloudDmInfo); return DistributedKv::SUCCESS; } int32_t NetConnCallbackObserver::NetUnavailable() { ZLOGI("OnNetworkUnavailable"); - dmAdapter_.SetNetAvailable(false); - return DistributedKv::SUCCESS; + dmAdapter_.SetNet(DeviceManagerAdapter::NONE); + return 0; } int32_t NetConnCallbackObserver::NetCapabilitiesChange(sptr &netHandle, const sptr &netAllCap) { ZLOGI("OnNetCapabilitiesChange"); - return DistributedKv::SUCCESS; + if (netHandle == nullptr || netAllCap == nullptr) { + return 0; + } + if (netAllCap->netCaps_.count(NetManagerStandard::NET_CAPABILITY_VALIDATED) && !netAllCap->bearerTypes_.empty()) { + dmAdapter_.SetNet(Convert(*netAllCap->bearerTypes_.begin())); + } else { + dmAdapter_.SetNet(DeviceManagerAdapter::NONE); + } + return 0; } int32_t NetConnCallbackObserver::NetConnectionPropertiesChange(sptr &netHandle, const sptr &info) { ZLOGI("OnNetConnectionPropertiesChange"); - return DistributedKv::SUCCESS; + return 0; } int32_t NetConnCallbackObserver::NetLost(sptr &netHandle) { ZLOGI("OnNetLost"); - dmAdapter_.SetNetAvailable(false); - dmAdapter_.Offline(dmAdapter_.cloudDmInfo); - return DistributedKv::SUCCESS; + dmAdapter_.SetNet(DeviceManagerAdapter::NONE); + return 0; } int32_t NetConnCallbackObserver::NetBlockStatusChange(sptr &netHandle, bool blocked) { ZLOGI("OnNetBlockStatusChange"); - return DistributedKv::SUCCESS; + return 0; } DeviceManagerAdapter::DeviceManagerAdapter() @@ -619,22 +637,52 @@ bool DeviceManagerAdapter::RegOnNetworkChange() bool DeviceManagerAdapter::IsNetworkAvailable() { - { - std::shared_lock lock(mutex_); - if (isNetAvailable_ || expireTime_ > std::chrono::steady_clock::now()) { - return isNetAvailable_; - } + if (defaultNetwork_ != NONE || expireTime_ > GetTimeStamp()) { + return defaultNetwork_ != NONE; } - NetHandle handle; - auto status = NetConnClient::GetInstance().GetDefaultNet(handle); - return SetNetAvailable(status == 0 && handle.GetNetId() != 0); + return RefreshNet() != NONE; } -bool DeviceManagerAdapter::SetNetAvailable(bool isNetAvailable) +DeviceManagerAdapter::NetworkType DeviceManagerAdapter::SetNet(NetworkType netWorkType) { - std::unique_lock lock(mutex_); - isNetAvailable_ = isNetAvailable; - expireTime_ = std::chrono::steady_clock::now() + std::chrono::milliseconds(EFFECTIVE_DURATION); - return isNetAvailable_; + auto oldNet = defaultNetwork_; + bool ready = oldNet == NONE && netWorkType != NONE && (GetTimeStamp() - netLostTime_) > NET_LOST_DURATION; + bool offline = oldNet != NONE && netWorkType == NONE; + if (offline) { + netLostTime_ = GetTimeStamp(); + } + defaultNetwork_ = netWorkType; + expireTime_ = GetTimeStamp() + EFFECTIVE_DURATION; + if (ready) { + OnReady(cloudDmInfo); + } + if (offline) { + Offline(cloudDmInfo); + } + return netWorkType; +} + +DeviceManagerAdapter::NetworkType DeviceManagerAdapter::GetNetworkType(bool retrieve) +{ + if (!retrieve) { + return defaultNetwork_; + } + return RefreshNet(); +} + +DeviceManagerAdapter::NetworkType DeviceManagerAdapter::RefreshNet() +{ + NetHandle handle; + auto status = NetConnClient::GetInstance().GetDefaultNet(handle); + if (status != 0 || handle.GetNetId() == 0) { + return SetNet(NONE); + } + NetAllCapabilities capabilities; + status = NetConnClient::GetInstance().GetNetCapabilities(handle, capabilities); + if (status != 0 || !capabilities.netCaps_.count(NetManagerStandard::NET_CAPABILITY_VALIDATED) || + capabilities.bearerTypes_.empty()) { + return SetNet(NONE); + } + return SetNet(Convert(*capabilities.bearerTypes_.begin())); } } // namespace OHOS::DistributedData diff --git a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h index 295033a5c585165d93ec2f90e3c5d51f644e23e8..30a9b393e163b9dd12a1d11530a200e1034bc3e5 100644 --- a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h +++ b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h @@ -37,6 +37,13 @@ public: DEVICE_ONREADY, DEVICE_BUTT }; + enum NetworkType { + NONE, + CELLULAR, + WIFI, + ETHERNET, + OTHER + }; using DmDeviceInfo = OHOS::DistributedHardware::DmDeviceInfo; using DeviceInfo = OHOS::AppDistributedKv::DeviceInfo; using PipeInfo = OHOS::AppDistributedKv::PipeInfo; @@ -66,6 +73,7 @@ public: std::string ToNetworkID(const std::string &id); void NotifyReadyEvent(const std::string &uuid); bool IsNetworkAvailable(); + NetworkType GetNetworkType(bool retrieve = false); friend class DataMgrDmStateCall; friend class NetConnCallbackObserver; @@ -74,7 +82,8 @@ private: ~DeviceManagerAdapter(); std::function RegDevCallback(); bool RegOnNetworkChange(); - bool SetNetAvailable(bool isNetAvailable); + NetworkType SetNet(NetworkType netWorkType); + NetworkType RefreshNet(); bool GetDeviceInfo(const DmDeviceInfo &dmInfo, DeviceInfo &dvInfo); void SaveDeviceInfo(const DeviceInfo &deviceInfo, const AppDistributedKv::DeviceChangeType &type); void InitDeviceInfo(bool onlyCache = true); @@ -86,6 +95,12 @@ private: void OnReady(const DmDeviceInfo &info); void TimeOut(const std::string uuid); std::vector GetObservers(); + static inline uint64_t GetTimeStamp() + { + return std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()) + .count(); + } std::mutex devInfoMutex_ {}; DeviceInfo localInfo_ {}; @@ -96,10 +111,11 @@ private: static constexpr int32_t SYNC_TIMEOUT = 60 * 1000; // ms ConcurrentMap syncTask_ {}; std::shared_ptr executors_; - mutable std::shared_mutex mutex_; static constexpr int32_t EFFECTIVE_DURATION = 30 * 1000; // ms - Time expireTime_ = std::chrono::steady_clock::now(); - bool isNetAvailable_ = false; + static constexpr int32_t NET_LOST_DURATION = 10 * 1000; // ms + uint64_t expireTime_ = GetTimeStamp(); + uint64_t netLostTime_ = GetTimeStamp(); + NetworkType defaultNetwork_ = NONE; ConcurrentMap> readyDevices_; }; } // namespace DistributedData diff --git a/services/distributeddataservice/framework/cloud/cloud_event.cpp b/services/distributeddataservice/framework/cloud/cloud_event.cpp index 8146446d3a983f1a9a38632879a71367e5c4b185..bfaf3c9eb16bf519dc41416ba55176eede336adc 100644 --- a/services/distributeddataservice/framework/cloud/cloud_event.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_event.cpp @@ -16,12 +16,12 @@ #include "cloud/cloud_event.h" namespace OHOS::DistributedData { -CloudEvent::CloudEvent(int32_t evtId, CloudEvent::StoreInfo storeInfo) +CloudEvent::CloudEvent(int32_t evtId, StoreInfo storeInfo) : Event(evtId), storeInfo_(std::move(storeInfo)) { } -const CloudEvent::StoreInfo& CloudEvent::GetStoreInfo() const +const StoreInfo& CloudEvent::GetStoreInfo() const { return storeInfo_; } diff --git a/services/distributeddataservice/framework/cloud/make_query_event.cpp b/services/distributeddataservice/framework/cloud/make_query_event.cpp index 1c1ee97ec6d0bef80a7f5b7c95c9c88a5fc190b8..0ed24b9c816f664fe7abd6ef75a764ea9e896490 100644 --- a/services/distributeddataservice/framework/cloud/make_query_event.cpp +++ b/services/distributeddataservice/framework/cloud/make_query_event.cpp @@ -16,7 +16,7 @@ #include "cloud/make_query_event.h" namespace OHOS::DistributedData { -MakeQueryEvent::MakeQueryEvent(CloudEvent::StoreInfo storeInfo, +MakeQueryEvent::MakeQueryEvent(StoreInfo storeInfo, std::shared_ptr predicates, const std::vector& columns, Callback callback) : CloudEvent(MAKE_QUERY, std::move(storeInfo)), predicates_(std::move(predicates)), columns_(columns), diff --git a/services/distributeddataservice/framework/include/cloud/cloud_event.h b/services/distributeddataservice/framework/include/cloud/cloud_event.h index 9ce38785cb00df0d1ba45e27f960e889b2c477f1..19837945dea7a0438f1295cbf9df31902f7fcc0b 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_event.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_event.h @@ -18,6 +18,7 @@ #include #include "eventcenter/event.h" +#include "store/store_info.h" namespace OHOS::DistributedData { class API_EXPORT CloudEvent : public Event { @@ -33,15 +34,6 @@ public: CLOUD_BUTT }; - struct StoreInfo { - uint32_t tokenId = 0; - std::string bundleName; - std::string storeName; - int32_t instanceId = 0; - int32_t user = 0; - std::string deviceId; - }; - CloudEvent(int32_t evtId, StoreInfo storeInfo); ~CloudEvent() = default; const StoreInfo& GetStoreInfo() const; diff --git a/services/distributeddataservice/framework/include/snapshot/machine_status.h b/services/distributeddataservice/framework/include/snapshot/machine_status.h index 8d4aa0bf9a0c0bd8ac5b27edcd9ba1625fb98f0b..e7c83aff8d76457639eec964ff3e7eedcbcb3eb4 100644 --- a/services/distributeddataservice/framework/include/snapshot/machine_status.h +++ b/services/distributeddataservice/framework/include/snapshot/machine_status.h @@ -50,14 +50,6 @@ struct AssetBindInfo { std::string field; std::string assetName; }; - -struct StoreInfo { - uint32_t tokenId = 0; - int32_t instanceId = 0; - int32_t user; - std::string bundleName; - std::string storeName; -}; } // namespace DistributedData } // namespace OHOS #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_SNAPSHOT_MACHINE_STATUS_H diff --git a/services/distributeddataservice/framework/include/snapshot/snapshot.h b/services/distributeddataservice/framework/include/snapshot/snapshot.h index 6cfbbfcf926a93457c3768064c13f57dd6658049..8a9fa7eef25338ffde134d0fa883dc2ffe32d085 100644 --- a/services/distributeddataservice/framework/include/snapshot/snapshot.h +++ b/services/distributeddataservice/framework/include/snapshot/snapshot.h @@ -17,6 +17,7 @@ #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_SNAPSHOT_SNAPSHOT_H #include "machine_status.h" #include "store/general_value.h" +#include "store/store_info.h" #include "visibility.h" namespace OHOS { namespace DistributedData { diff --git a/services/distributeddataservice/framework/include/store/store_info.h b/services/distributeddataservice/framework/include/store/store_info.h new file mode 100644 index 0000000000000000000000000000000000000000..8138955aaabd97e38a5bc4c431a8499c5c63c398 --- /dev/null +++ b/services/distributeddataservice/framework/include/store/store_info.h @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_STORE_STORE_INFO_H +#define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_STORE_STORE_INFO_H + +#include + +namespace OHOS::DistributedData { +struct StoreInfo { + uint32_t tokenId = 0; + std::string bundleName; + std::string storeName; + int32_t instanceId = 0; + int32_t user = 0; + std::string deviceId; +}; +} // namespace OHOS::DistributedData +#endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_STORE_STORE_INFO_H diff --git a/services/distributeddataservice/framework/store/auto_cache.cpp b/services/distributeddataservice/framework/store/auto_cache.cpp index b4f8647c6096bfd3a86f16641f27f4759ce9e436..b7a5b7d1daa74e6458073422de5844316890c0cb 100644 --- a/services/distributeddataservice/framework/store/auto_cache.cpp +++ b/services/distributeddataservice/framework/store/auto_cache.cpp @@ -227,11 +227,11 @@ bool AutoCache::Delegate::Close() { std::unique_lock lock(mutex_); if (store_ != nullptr) { - store_->Unwatch(Origin::ORIGIN_ALL, *this); auto status = store_->Close(); if (status == Error::E_BUSY) { return false; } + store_->Unwatch(Origin::ORIGIN_ALL, *this); } return true; } diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 3e4eb147f69526913cdf0c5bef10ca77d8ea9d5c..98549b23e8786d8367a2ff6d9e176f095bf9d2ce 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -375,10 +375,9 @@ int32_t CloudServiceImpl::OnUserChange(uint32_t code, const std::string &user, c return E_OK; } -int32_t CloudServiceImpl::Online(const std::string &device) +int32_t CloudServiceImpl::OnReady(const std::string& device) { if (device != DeviceManagerAdapter::CLOUD_DEVICE_UUID) { - ZLOGI("Not network online"); return SUCCESS; } std::vector users; @@ -622,7 +621,7 @@ void CloudServiceImpl::CloudShare(const Event &event) } std::pair> CloudServiceImpl::PreShare( - const CloudEvent::StoreInfo& storeInfo, GenQuery& query) + const StoreInfo& storeInfo, GenQuery& query) { StoreMetaData meta; meta.bundleName = storeInfo.bundleName; @@ -777,7 +776,7 @@ std::pair> CloudServiceImpl::Alloc return { E_INVALID_ARGS, {} }; } auto memo = std::make_shared(predicates); - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.bundleName = hapInfo.bundleName; storeInfo.tokenId = tokenId; storeInfo.user = hapInfo.user; diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index 10c446d04cab21824b0da53502bdf15d2c38b887..3bd1101c1b6de2350b33679200431f4a4611c2bd 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -32,6 +32,7 @@ namespace OHOS::CloudData { class CloudServiceImpl : public CloudServiceStub { public: using StoreMetaData = DistributedData::StoreMetaData; + using StoreInfo = DistributedData::StoreInfo; CloudServiceImpl(); ~CloudServiceImpl() = default; int32_t EnableCloud(const std::string &id, const std::map &switches) override; @@ -43,7 +44,7 @@ public: int32_t OnInitialize() override; int32_t OnBind(const BindInfo &info) override; int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override; - int32_t Online(const std::string &device) override; + int32_t OnReady(const std::string &device) override; int32_t Offline(const std::string &device) override; std::pair> AllocResourceAndShare(const std::string& storeId, @@ -129,7 +130,7 @@ private: void Execute(Task task); void CleanSubscription(Subscription &sub); int32_t DoClean(CloudInfo &cloudInfo, const std::map &actions); - std::pair> PreShare(const CloudEvent::StoreInfo& storeInfo, + std::pair> PreShare(const StoreInfo& storeInfo, DistributedData::GenQuery& query); std::vector ConvertCursor(std::shared_ptr cursor) const; int32_t CheckNotifyConditions(const std::string &id, const std::string &bundleName, CloudInfo &cloudInfo); diff --git a/services/distributeddataservice/service/cloud/sync_manager.cpp b/services/distributeddataservice/service/cloud/sync_manager.cpp index d739aae727b8ac318b44c394ff0302ba241e0f9e..7b8f5e71dd593af2cd31e201e8ef5c7d8694de1b 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -225,7 +225,7 @@ ExecutorPool::Task SyncManager::GetSyncTask(int32_t times, bool retry, RefCount if (!info.Contains(database.name)) { continue; } - CloudEvent::StoreInfo storeInfo = { 0, schema.bundleName, database.name, + StoreInfo storeInfo = { 0, schema.bundleName, database.name, cloud.apps[schema.bundleName].instanceId, cloud.user }; auto query = info.GenerateQuery(database.name, database.GetTableNames()); auto evt = std::make_unique(std::move(storeInfo), @@ -347,7 +347,7 @@ int32_t SyncManager::Compare(uint64_t syncId, int32_t user) void SyncManager::UpdateSchema(const SyncManager::SyncInfo &syncInfo) { - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.user = syncInfo.user_; storeInfo.bundleName = syncInfo.bundleName_; EventCenter::GetInstance().PostEvent(std::make_unique(CloudEvent::GET_SCHEMA, storeInfo)); diff --git a/services/distributeddataservice/service/cloud/sync_manager.h b/services/distributeddataservice/service/cloud/sync_manager.h index d68e7b57d9430beb5a69ce9b35e1ed206ae4677b..18b21c5ebc3ce7f193581d18e746819031328822 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.h +++ b/services/distributeddataservice/service/cloud/sync_manager.h @@ -76,6 +76,7 @@ private: using Duration = ExecutorPool::Duration; using Retryer = std::function; using CloudInfo = DistributedData::CloudInfo; + using StoreInfo = DistributedData::StoreInfo; static constexpr ExecutorPool::Duration RETRY_INTERVAL = std::chrono::seconds(10); // second static constexpr ExecutorPool::Duration LOCKED_INTERVAL = std::chrono::seconds(30); // second diff --git a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp index 6f17ca9ea600c812db69747c74ce7655a069e143..7d2be643d84a7a60efce43602fdc6fa9319b6cab 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp @@ -540,6 +540,9 @@ int32_t KVDBServiceImpl::OnUserChange(uint32_t code, const std::string &user, co int32_t KVDBServiceImpl::OnReady(const std::string &device) { + if (device == DeviceManagerAdapter::CLOUD_DEVICE_UUID) { + return SUCCESS; + } std::vector metaData; auto prefix = StoreMetaData::GetPrefix({ DMAdapter::GetInstance().GetLocalDevice().uuid }); if (!MetaDataManager::GetInstance().LoadMeta(prefix, metaData)) { diff --git a/services/distributeddataservice/service/object/object_asset_machine.h b/services/distributeddataservice/service/object/object_asset_machine.h index fef1ccee2c86913058c35ec2c4339f7f7ee999cc..14283191bd486b62b1e6e8db591ec5c5c2e23428 100644 --- a/services/distributeddataservice/service/object/object_asset_machine.h +++ b/services/distributeddataservice/service/object/object_asset_machine.h @@ -18,6 +18,7 @@ #define DISTRIBUTEDDATAMGR_OBJECT_ASSET_MACHINE_H #include "snapshot/machine_status.h" +#include "store/store_info.h" namespace OHOS { namespace DistributedObject { diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 1ba52d4c739ff855d4a0015f981a06c24cc1f28e..a26d1e21ab0b7cc3cfadc53b40c2814925f8ef53 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -428,7 +428,7 @@ int RdbServiceImpl::DoSync(const RdbSyncerParam ¶m, const RdbService::Option void RdbServiceImpl::DoCompensateSync(const BindEvent& event) { auto bindInfo = event.GetBindInfo(); - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.bundleName = bindInfo.bundleName; storeInfo.tokenId = bindInfo.tokenId; storeInfo.user = bindInfo.user; @@ -454,7 +454,7 @@ void RdbServiceImpl::DoCompensateSync(const BindEvent& event) void RdbServiceImpl::DoCloudSync(const RdbSyncerParam ¶m, const RdbService::Option &option, const PredicatesMemo &predicates, const AsyncDetail &async) { - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.bundleName = param.bundleName_; storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); storeInfo.user = AccountDelegate::GetInstance()->GetUserByToken(storeInfo.tokenId); @@ -628,7 +628,7 @@ std::pair> RdbServiceImpl::Query auto rdbQuery = std::make_shared(); rdbQuery->MakeQuery(predicates); rdbQuery->SetColumns(columns); - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.bundleName = param.bundleName_; storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); storeInfo.user = AccountDelegate::GetInstance()->GetUserByToken(storeInfo.tokenId); @@ -642,7 +642,7 @@ std::pair> RdbServiceImpl::Query return { RDB_OK, std::make_shared(cursor) }; } -std::pair> RdbServiceImpl::AllocResource(CloudEvent::StoreInfo& storeInfo, +std::pair> RdbServiceImpl::AllocResource(StoreInfo& storeInfo, std::shared_ptr rdbQuery) { std::pair> result; @@ -668,7 +668,7 @@ int32_t RdbServiceImpl::GetSchema(const RdbSyncerParam ¶m) } if (executors_ != nullptr) { - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); storeInfo.bundleName = param.bundleName_; storeInfo.storeName = RemoveSuffix(param.storeName_); @@ -959,7 +959,7 @@ int32_t RdbServiceImpl::NotifyDataChange(const RdbSyncerParam ¶m, const RdbC Anonymous::Change(param.storeName_).c_str()); return RDB_ERROR; } - CloudEvent::StoreInfo storeInfo; + StoreInfo storeInfo; storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); storeInfo.bundleName = param.bundleName_; storeInfo.storeName = RemoveSuffix(param.storeName_); diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 5c21e6f7b9b9665725039f3f69be75de07bb7657..309bf4707a40e229a74a567c1f8e3eead4da0515 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -43,7 +43,7 @@ public: using SecretKeyMetaData = DistributedData::SecretKeyMetaData; using DetailAsync = DistributedData::GeneralStore::DetailAsync; using Handler = std::function> &)>; - using StoreInfo = DistributedData::CloudEvent::StoreInfo; + using StoreInfo = DistributedData::StoreInfo; RdbServiceImpl(); virtual ~RdbServiceImpl(); diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 6b8c965a22942e3e438f8edc4a28d028cae79972..09f631376efab915dc06ac99e9d02d1d05b1d374 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -28,6 +28,7 @@ #include "metadata/store_meta_data.h" #include "metadata/store_meta_data_local.h" #include "mock/db_store_mock.h" +#include "store/store_info.h" #include "rdb_types.h" using namespace testing::ext; using namespace OHOS::DistributedData; @@ -188,7 +189,7 @@ HWTEST_F(CloudDataTest, GetSchema, TestSize.Level0) SchemaMeta schemaMeta; ASSERT_FALSE( MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetSchemaKey(TEST_CLOUD_BUNDLE), schemaMeta, true)); - CloudEvent::StoreInfo storeInfo { OHOS::IPCSkeleton::GetCallingTokenID(), TEST_CLOUD_BUNDLE, TEST_CLOUD_STORE, 0 }; + StoreInfo storeInfo { OHOS::IPCSkeleton::GetCallingTokenID(), TEST_CLOUD_BUNDLE, TEST_CLOUD_STORE, 0 }; auto event = std::make_unique(CloudEvent::GET_SCHEMA, storeInfo); EventCenter::GetInstance().PostEvent(std::move(event)); ASSERT_FALSE( diff --git a/services/distributeddataservice/service/test/cloud_test.cpp b/services/distributeddataservice/service/test/cloud_test.cpp index fd87a48e51bd9eaa827898a0d3c6787d2db8edee..b1edd4951141a0701d41eeb29ade5f16f18a448c 100644 --- a/services/distributeddataservice/service/test/cloud_test.cpp +++ b/services/distributeddataservice/service/test/cloud_test.cpp @@ -55,7 +55,7 @@ HWTEST_F(CloudTest, EventInfo, TestSize.Level1) SyncEvent::EventInfo eventInfo1(mode, wait, retry, query, async); SyncEvent::EventInfo eventInfo2(std::move(eventInfo1)); SyncEvent::EventInfo eventInfo3 = std::move(eventInfo2); - CloudEvent::StoreInfo storeInfo{ IPCSkeleton::GetCallingTokenID(), testCloudBundle, testCloudStore, 0 }; + StoreInfo storeInfo{ IPCSkeleton::GetCallingTokenID(), testCloudBundle, testCloudStore, 0 }; SyncEvent evt(storeInfo, eventInfo3); EXPECT_EQ(evt.GetMode(), mode); EXPECT_EQ(evt.GetWait(), wait);