diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 54f6dcba97b8bb800c0e8225db04221528bb2580..abb4f6947c0ee5b7fdde842447b3d87534ad7acf 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -171,9 +171,9 @@ std::string RdbServiceImpl::ObtainDistributedTableName(const std::string &device return DistributedDB::RelationalStoreManager::GetDistributedTableName(uuid, table); } -int32_t RdbServiceImpl::InitNotifier(const std::string& bundleName, const std::string& storeName,const sptr notifier) +int32_t RdbServiceImpl::InitNotifier(const std::string &bundleName, const sptr notifier) { - if (!CheckAccess(bundleName, storeName)) { + if (!CheckAccess(bundleName, "")) { ZLOGE("permission error"); return RDB_ERROR; } @@ -182,7 +182,7 @@ int32_t RdbServiceImpl::InitNotifier(const std::string& bundleName, const std::s return RDB_ERROR; } pid_t pid = IPCSkeleton::GetCallingPid(); - auto recipient = new(std::nothrow) DeathRecipientImpl([this, pid] { + auto recipient = new (std::nothrow) DeathRecipientImpl([this, pid] { OnClientDied(pid); }); if (recipient == nullptr) { @@ -471,7 +471,7 @@ int32_t RdbServiceImpl::OnInitialize() int32_t RdbServiceImpl::OpenStore(const CloudParam &cloudParam) { - if (!CheckAccess(cloudParam.bundleName)) { + if (!CheckAccess(cloudParam.bundleName, cloudParam.storeName)) { ZLOGE("permission error"); return RDB_ERROR; } diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.h b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.h index de9a76dcdb4b6b13c28609aa041cd7feb5d53261..17e129685cd9e863c55937fde3c30221c7c93e74 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -41,9 +41,7 @@ public: /* IPC interface */ std::string ObtainDistributedTableName(const std::string& device, const std::string& table) override; - int32_t InitNotifier(const std::string& bundleName, const std::string& storeName, const sptr notifier) override; - - int32_t OpenStore(const CloudParam &cloudParam) override; + int32_t InitNotifier(const std::string& bundleName, const sptr notifier) override; int32_t SetDistributedTables(const RdbSyncerParam& param, const std::vector& tables) override; @@ -60,6 +58,8 @@ public: int32_t OnInitialize() override; + int32_t OpenStore(const CloudParam &cloudParam) override; + protected: int32_t DoSync(const RdbSyncerParam& param, const SyncOption& option, const RdbPredicates& predicates, SyncResult& result) override; diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index 6438028b3072b6c0a060122a55ed9d27f15a0e45..83d11cdbfe81cd8fc4f62245b3601d7064473dea 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -56,14 +56,14 @@ int32_t RdbServiceStub::OnOpenStore(MessageParcel &data, MessageParcel &reply) { int32_t RdbServiceStub::OnRemoteInitNotifier(MessageParcel &data, MessageParcel &reply) { - RdbSyncerParam param; + std::string bundleName; sptr notifier; - if (!ITypesUtil::Unmarshal(data, param, notifier) || notifier == nullptr) { - ZLOGE("Unmarshal bundleName_:%{public}s storeName_:%{public}s", param.bundleName_.c_str(), - param.storeName_.c_str()); + if (!ITypesUtil::Unmarshal(data, bundleName, notifier) || bundleName.empty() || notifier == nullptr) { + ZLOGE("Unmarshal bundleName:%{public}s notifier is nullptr:%{public}d", bundleName.c_str(), + notifier == nullptr); return IPC_STUB_INVALID_DATA_ERR; } - auto status = InitNotifier(param.bundleName_, notifier); + auto status = InitNotifier(bundleName, notifier); if (!ITypesUtil::Marshal(reply, status)) { ZLOGE("Marshal status:0x%{public}x", status); return IPC_STUB_WRITE_PARCEL_ERR; diff --git a/relational_store/frameworks/native/rdb/include/rdb_manager_impl.h b/relational_store/frameworks/native/rdb/include/rdb_manager_impl.h index 197f439d5cd83d9dbcde5febcc1e214bace0b0ac..80689b3d069672ad8d2378a33319289bea43f688 100644 --- a/relational_store/frameworks/native/rdb/include/rdb_manager_impl.h +++ b/relational_store/frameworks/native/rdb/include/rdb_manager_impl.h @@ -39,7 +39,7 @@ public: static RdbManagerImpl &GetInstance(); - int GetRdbService(const std::string& bundleName, std::shared_ptr &service); + int GetRdbService(const std::string& bundleName, const std::string& storeName, std::shared_ptr &service); void OnRemoteDied(); diff --git a/relational_store/frameworks/native/rdb/include/rdb_service_proxy.h b/relational_store/frameworks/native/rdb/include/rdb_service_proxy.h index 8fda347edd5ebf33d6a9d29e65afc3a633f3566c..43099c5aab8c56b818f60fa4c6b1f9f233cd8f12 100644 --- a/relational_store/frameworks/native/rdb/include/rdb_service_proxy.h +++ b/relational_store/frameworks/native/rdb/include/rdb_service_proxy.h @@ -33,7 +33,6 @@ public: std::string ObtainDistributedTableName(const std::string& device, const std::string& table) override; - int32_t OpenStore(const CloudParam &cloudParam) override; int32_t InitNotifier(const std::string& bundleName); int32_t InitNotifier(const std::string& bundleName, const sptr notifier) override; @@ -57,6 +56,8 @@ public: void ImportObservers(ObserverMap& observers); + /*CLoudData*/ + int32_t OpenStore(const CloudParam &cloudParam) override; protected: int32_t DoSync(const RdbSyncerParam& param, const SyncOption& option, const RdbPredicates& predicates, SyncResult& result) override; diff --git a/relational_store/frameworks/native/rdb/src/rdb_manager.cpp b/relational_store/frameworks/native/rdb/src/rdb_manager.cpp index a9b52b27157fc868ea82b3b2031d589d55bae900..6dc545b8f65c8c7c54b4ea34dc887b44160576f9 100644 --- a/relational_store/frameworks/native/rdb/src/rdb_manager.cpp +++ b/relational_store/frameworks/native/rdb/src/rdb_manager.cpp @@ -17,8 +17,8 @@ #include "rdb_manager_impl.h" namespace OHOS::DistributedRdb { -int RdbManager::GetRdbService(const RdbSyncerParam& param, std::shared_ptr &service) +int RdbManager::GetRdbService(const RdbSyncerParam ¶m, std::shared_ptr &service) { - return RdbManagerImpl::GetInstance().GetRdbService(param.bundleName_, service); + return RdbManagerImpl::GetInstance().GetRdbService(param.bundleName_, param.storeName_, service); } } // namespace OHOS::DistributedRdb diff --git a/relational_store/frameworks/native/rdb/src/rdb_manager_impl.cpp b/relational_store/frameworks/native/rdb/src/rdb_manager_impl.cpp index cfc07cc5221146b75cd09934a6af0e776e1febdc..3fc093ddcc9b39bdbf60bbb2276f6de84f3bbc4b 100644 --- a/relational_store/frameworks/native/rdb/src/rdb_manager_impl.cpp +++ b/relational_store/frameworks/native/rdb/src/rdb_manager_impl.cpp @@ -80,7 +80,7 @@ RdbManagerImpl& RdbManagerImpl::GetInstance() return manager; } -int RdbManagerImpl::GetRdbService(const std::string& bundleName, std::shared_ptr &service) +int RdbManagerImpl::GetRdbService(const std::string& bundleName, const std::string& storeName, std::shared_ptr &service) { std::lock_guard lock(mutex_); if (rdbService_ != nullptr) { @@ -101,7 +101,7 @@ int RdbManagerImpl::GetRdbService(const std::string& bundleName, std::shared_ptr return E_NOT_SUPPORTED; } sptr serviceProxy = iface_cast(remote); - if (serviceProxy->InitNotifier(bundleName) != RDB_OK) { + if (serviceProxy->InitNotifier(bundleName, storeName) != RDB_OK) { ZLOGE("init notifier failed"); return E_ERROR; } @@ -131,7 +131,7 @@ void RdbManagerImpl::OnRemoteDied() RdbSyncerParam param; param.bundleName_ = bundleName_; std::shared_ptr service = nullptr; - int errCode = GetRdbService(bundleName_, service); + int errCode = GetRdbService(bundleName_, "", service); if (errCode != E_OK) { return; } diff --git a/relational_store/frameworks/native/rdb/src/rdb_service_proxy.cpp b/relational_store/frameworks/native/rdb/src/rdb_service_proxy.cpp index 5c0b93dcd35d68fd61fb6adb7c87704e4b4380ff..043882595ce3905dd038ce80a6a9e52b671abd2b 100644 --- a/relational_store/frameworks/native/rdb/src/rdb_service_proxy.cpp +++ b/relational_store/frameworks/native/rdb/src/rdb_service_proxy.cpp @@ -83,16 +83,13 @@ std::string RdbServiceProxy::ObtainDistributedTableName(const std::string &devic return reply.ReadString(); } -int32_t RdbServiceProxy::InitNotifier(const std::string& bundleName) +int32_t RdbServiceProxy::InitNotifier(const std::string &bundleName) { - notifier_ = new (std::nothrow) RdbNotifierStub( - [this] (uint32_t seqNum, const SyncResult& result) { - OnSyncComplete(seqNum, result); - }, - [this] (const std::string& storeName, const std::vector& devices) { - OnDataChange(storeName, devices); - } - ); + notifier_ = new (std::nothrow) + RdbNotifierStub([this](uint32_t seqNum, const SyncResult &result) { OnSyncComplete(seqNum, result); }, + [this](const std::string &storeName, const std::vector &devices) { + OnDataChange(storeName, devices); + }); if (notifier_ == nullptr) { ZLOGE("create notifier failed"); return RDB_ERROR; diff --git a/relational_store/interfaces/inner_api/rdb/include/rdb_service.h b/relational_store/interfaces/inner_api/rdb/include/rdb_service.h index d549cb3aa97b3a5a21117319bf2abefb9912f09c..9e1699be36c05031fd6f9ed1cc72ba520c143d5c 100644 --- a/relational_store/interfaces/inner_api/rdb/include/rdb_service.h +++ b/relational_store/interfaces/inner_api/rdb/include/rdb_service.h @@ -60,8 +60,9 @@ public: virtual int32_t DestroyRDBTable(const RdbSyncerParam ¶m) = 0; - virtual int32_t InitNotifier(const std::string& bundleName, const std::string& storeName, const sptr notifier) = 0; + virtual int32_t InitNotifier(const std::string& bundleName, const sptr notifier) = 0; + /*Cloud Data*/ virtual int32_t OpenStore(const CloudParam &cloudParam) = 0; protected: