From d639b6722f167b89445cdbb122d074ee00bb85dc Mon Sep 17 00:00:00 2001 From: renjiecui Date: Fri, 25 Aug 2023 17:32:13 +0800 Subject: [PATCH 1/4] add clear data Signed-off-by: renjiecui --- services/distributeddataservice/app/BUILD.gn | 1 + .../app/src/feature_stub_impl.cpp | 8 +++ .../app/src/feature_stub_impl.h | 2 + .../app/src/flowctrl_manager/BUILD.gn | 1 + .../app/src/kvstore_data_service.cpp | 55 +++++++++++++++++++ .../app/src/kvstore_data_service.h | 10 ++++ .../app/src/uninstaller/BUILD.gn | 1 + .../distributeddataservice/app/test/BUILD.gn | 1 + .../fuzztest/dataservicestub_fuzzer/BUILD.gn | 1 + .../framework/feature/feature_system.cpp | 5 ++ .../include/feature/feature_system.h | 3 + .../distributeddataservice/service/BUILD.gn | 1 + .../service/rdb/rdb_service_impl.cpp | 8 +++ .../service/rdb/rdb_service_impl.h | 4 +- .../fuzztest/cloudservicestub_fuzzer/BUILD.gn | 1 + .../fuzztest/kvdbservicestub_fuzzer/BUILD.gn | 1 + .../objectservicestub_fuzzer/BUILD.gn | 1 + .../fuzztest/rdbresultsetstub_fuzzer/BUILD.gn | 1 + .../fuzztest/rdbservicestub_fuzzer/BUILD.gn | 1 + 19 files changed, 105 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn index ccb08f5ba..44bd1927b 100644 --- a/services/distributeddataservice/app/BUILD.gn +++ b/services/distributeddataservice/app/BUILD.gn @@ -39,6 +39,7 @@ config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/bootstrap/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/config/include", diff --git a/services/distributeddataservice/app/src/feature_stub_impl.cpp b/services/distributeddataservice/app/src/feature_stub_impl.cpp index 4ac875dfc..61dad4841 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.cpp +++ b/services/distributeddataservice/app/src/feature_stub_impl.cpp @@ -108,4 +108,12 @@ int32_t FeatureStubImpl::OnReady(const std::string &device) } return featureImpl_->OnReady(device); } + +std::pair FeatureStubImpl::GetCleaner() +{ + if (featureImpl_ == nullptr) { + return { "", nullptr }; + } + return featureImpl_->GetCleaner(); +} } diff --git a/services/distributeddataservice/app/src/feature_stub_impl.h b/services/distributeddataservice/app/src/feature_stub_impl.h index b9714b95c..943eaa18c 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.h +++ b/services/distributeddataservice/app/src/feature_stub_impl.h @@ -26,6 +26,7 @@ public: class FeatureStubImpl final : public IRemoteStub { public: + using Cleaner = FeatureSystem::Cleaner; explicit FeatureStubImpl(std::shared_ptr feature); ~FeatureStubImpl(); int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, @@ -39,6 +40,7 @@ public: int32_t Online(const std::string &device); int32_t Offline(const std::string &device); int32_t OnReady(const std::string &device); + std::pair GetCleaner(); private: std::shared_ptr featureImpl_; }; diff --git a/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn b/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn index eae2ee833..d4d44bd53 100755 --- a/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn +++ b/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn @@ -20,6 +20,7 @@ ohos_static_library("distributeddata_flowctrl_static") { include_dirs = [ "../../../adapter/include/account", "../../src", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/interfaces/innerkits/distributeddata/include", "//third_party/json/single_include", diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 9eb32d479..da6cf9adf 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -155,6 +155,7 @@ sptr KvStoreDataService::GetFeatureInterface(const std::string &n }); if (isFirstCreate) { feature->OnInitialize(executors_); + RegisterCleaner(feature); } return feature != nullptr ? feature->AsObject() : nullptr; } @@ -702,4 +703,58 @@ int32_t KvStoreDataService::OnUpdate(const std::string &bundleName, int32_t user }); return 0; } + +int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t userId, int32_t appIndex) +{ + std::vector metaData; + std::string prefix = StoreMetaData::GetPrefix( + { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(userId), "default", bundleName }); + if (!MetaDataManager::GetInstance().LoadMeta(prefix, metaData)) { + ZLOGE("Clear data load meta failed, bundleName:%{public}s, user:%{public}d, appIndex:%{public}d", + bundleName.c_str(), userId, appIndex); + return ERROR; + } + for (auto &meta : metaData) { + if (meta.instanceId == appIndex && !meta.appId.empty() && !meta.storeId.empty()) { + ZLOGI("data cleared bundleName:%{public}s, stordId:%{public}s, appIndex:%{public}d", bundleName.c_str(), + Anonymous::Change(meta.storeId).c_str(), appIndex); + auto cleaner = cleaners_[GetStore(meta)]; + if (!cleaner) { + cleaner(meta.tokenId, meta.storeId); + } + MetaDataManager::GetInstance().DelMeta(meta.GetKey()); + MetaDataManager::GetInstance().DelMeta(meta.GetSecretKey(), true); + MetaDataManager::GetInstance().DelMeta(meta.GetStrategyKey()); + MetaDataManager::GetInstance().DelMeta(meta.appId, true); + MetaDataManager::GetInstance().DelMeta(meta.GetKeyLocal(), true); + PermitDelegate::GetInstance().DelCache(meta.GetKey()); + } + } + return SUCCESS; +} + +std::string KvStoreDataService::GetStore(const StoreMetaData &metaData) const +{ + if (metaData.storeType >= StoreMetaData::StoreType::STORE_KV_BEGIN + && metaData.storeType <= StoreMetaData::StoreType::STORE_KV_END) { + return "kv_store"; + } + if (metaData.storeType >= StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN + && metaData.storeType <= StoreMetaData::StoreType::STORE_RELATIONAL_END) { + return "relational_store"; + } + if (metaData.storeType >= StoreMetaData::StoreType::STORE_OBJECT_BEGIN + && metaData.storeType <= StoreMetaData::StoreType::STORE_OBJECT_END) { + return "data_object"; + } + return "other"; +} + +void KvStoreDataService::RegisterCleaner(sptr feature) +{ + auto [name, cleaner] = feature->GetCleaner(); + if (cleaner) { + cleaners_.InsertOrAssign(name, cleaner); + } +} } // namespace OHOS::DistributedKv diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index a264d67b4..ba091d908 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -27,6 +27,8 @@ #include "ithread_pool.h" #include "kvstore_device_listener.h" #include "kvstore_meta_manager.h" +#include "kvstore_data_service_stub.h" +#include "kvstore_data_service_proxy.h" #include "metadata/store_meta_data.h" #include "reporter.h" #include "runtime_config.h" @@ -42,6 +44,9 @@ class KvStoreDataService : public SystemAbility, public KvStoreDataServiceStub { public: using StoreMetaData = DistributedData::StoreMetaData; + using Cleaner = DistributedData::FeatureSystem::Feature::Cleaner; + using FeatureStubImpl = DistributedData::FeatureStubImpl; + // record kvstore meta version for compatible, should update when modify kvstore meta structure. static constexpr uint32_t STORE_VERSION = 0x03000001; @@ -53,6 +58,8 @@ public: sptr GetFeatureInterface(const std::string &name) override; + int32_t ClearData(const std::string &bundleName, int32_t userId, int32_t appIndex) override; + void OnDump() override; int Dump(int fd, const std::vector &args) override; @@ -126,6 +133,8 @@ private: static DistributedDB::SecurityOption ConvertSecurity(int securityLevel); static Status InitNbDbOption(const Options &options, const std::vector &cipherKey, DistributedDB::KvStoreNbDelegate::Option &dbOption); + std::string GetStore(const StoreMetaData &metaData) const; + void RegisterCleaner(sptr feature); static constexpr int TEN_SEC = 10; @@ -137,6 +146,7 @@ private: ConcurrentMap> features_; std::shared_ptr deviceInnerListener_; std::shared_ptr executors_; + ConcurrentMap cleaners_; }; } #endif // KVSTORE_DATASERVICE_H diff --git a/services/distributeddataservice/app/src/uninstaller/BUILD.gn b/services/distributeddataservice/app/src/uninstaller/BUILD.gn index aa9913b80..f05af203b 100755 --- a/services/distributeddataservice/app/src/uninstaller/BUILD.gn +++ b/services/distributeddataservice/app/src/uninstaller/BUILD.gn @@ -23,6 +23,7 @@ ohos_static_library("distributeddata_uninstaller_static") { include_dirs = [ "../../../adapter/include/account", "../../src", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/interfaces/innerkits/distributeddata/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index 0b51ae59a..cdf764b53 100644 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -20,6 +20,7 @@ config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "//foundation/distributeddatamgr/kv_store/frameworks/common", + "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", diff --git a/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn index 3e594bee1..addb7be63 100644 --- a/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn @@ -21,6 +21,7 @@ ohos_fuzztest("DataServiceStubFuzzTest") { include_dirs = [ "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${data_service_path}/service/bootstrap/include", "${data_service_path}/service/config/include", diff --git a/services/distributeddataservice/framework/feature/feature_system.cpp b/services/distributeddataservice/framework/feature/feature_system.cpp index 98f67a101..12dbb716e 100644 --- a/services/distributeddataservice/framework/feature/feature_system.cpp +++ b/services/distributeddataservice/framework/feature/feature_system.cpp @@ -104,5 +104,10 @@ int32_t FeatureSystem::Feature::OnBind(const FeatureSystem::Feature::BindInfo &b { return E_OK; } + +std::pair FeatureSystem::Feature::GetCleaner() +{ + return { "", nullptr }; +} } // namespace DistributedData } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/framework/include/feature/feature_system.h b/services/distributeddataservice/framework/include/feature/feature_system.h index a94f01573..bb78ea3fc 100644 --- a/services/distributeddataservice/framework/include/feature/feature_system.h +++ b/services/distributeddataservice/framework/include/feature/feature_system.h @@ -29,6 +29,7 @@ namespace DistributedData { class API_EXPORT FeatureSystem { public: using Error = GeneralError; + inline static constexpr int32_t STUB_SUCCESS = Error::E_OK; enum BindFlag : int32_t { BIND_LAZY, @@ -36,6 +37,7 @@ public: }; class API_EXPORT Feature { public: + using Cleaner = std::function; struct BindInfo { std::string selfName; uint32_t selfTokenId; @@ -53,6 +55,7 @@ public: virtual int32_t Online(const std::string &device); virtual int32_t Offline(const std::string &device); virtual int32_t OnReady(const std::string &device); + virtual std::pair GetCleaner(); }; using Creator = std::function()>; static FeatureSystem &GetInstance(); diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index 023498d58..1913ded4e 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -42,6 +42,7 @@ config("module_public_config") { "${datashare_path}/interfaces/inner_api/common/include", "${datashare_path}/interfaces/inner_api/consumer/include", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}/include/", diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 9a2ec41be..81246b4b3 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -694,4 +694,12 @@ void RdbServiceImpl::SyncAgent::SetWatcher(std::shared_ptr watcher) } } } + +std::pair RdbServiceImpl::GetCleaner() +{ + auto cleaner = [](uint32_t &tokenId, const std::string &storeId) { + AutoCache::GetInstance().CloseStore(tokenId, storeId); + }; + return { RdbServiceImpl::SERVICE_NAME, std::move(cleaner) }; +} } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 8a8a738ab..669d8d054 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -75,6 +75,8 @@ public: int32_t OnBind(const BindInfo &bindInfo) override; + std::pair GetCleaner() override; + private: using Watchers = DistributedData::AutoCache::Watchers; struct SyncAgent { @@ -100,7 +102,7 @@ private: void DoCloudSync(const RdbSyncerParam ¶m, const Option &option, const PredicatesMemo &predicates, const AsyncDetail &async); - + int DoSync(const RdbSyncerParam ¶m, const Option &option, const PredicatesMemo &predicates, const AsyncDetail &async); diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index 45818b829..0f55bbc75 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -34,6 +34,7 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "${data_service_path}/service/permission/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", diff --git a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn index 01f380c64..a5513bcb0 100644 --- a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn @@ -32,6 +32,7 @@ ohos_fuzztest("KvdbServiceStubFuzzTest") { "${data_service_path}/service/matrix/include", "${data_service_path}/service/permission/include", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", diff --git a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn index cd27ac041..f9f66c163 100644 --- a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn @@ -29,6 +29,7 @@ ohos_fuzztest("ObjectServiceStubFuzzTest") { "${data_service_path}/service/crypto/include", "${data_service_path}/service/object", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", diff --git a/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn index c8736f9f6..efac5a958 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn @@ -25,6 +25,7 @@ ohos_fuzztest("RdbResultSetStubFuzzTest") { "${data_service_path}/framework/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", diff --git a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn index b0c3923a0..301aa8493 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { "${data_service_path}/service/permission/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", -- Gitee From adac102ee39905bd43cc4e2d3cbff2d451609c8d Mon Sep 17 00:00:00 2001 From: renjiecui Date: Sat, 26 Aug 2023 14:52:59 +0800 Subject: [PATCH 2/4] add handler Signed-off-by: renjiecui --- .../app/src/feature_stub_impl.cpp | 8 ------ .../app/src/feature_stub_impl.h | 2 -- .../app/src/kvstore_data_service.cpp | 28 ++++++------------- .../app/src/kvstore_data_service.h | 7 +---- .../distributeddataservice/app/test/BUILD.gn | 2 +- .../framework/feature/feature_system.cpp | 17 +++++++++-- .../include/feature/feature_system.h | 10 +++++-- .../service/rdb/rdb_service_impl.cpp | 9 +++--- .../service/rdb/rdb_service_impl.h | 4 ++- 9 files changed, 39 insertions(+), 48 deletions(-) diff --git a/services/distributeddataservice/app/src/feature_stub_impl.cpp b/services/distributeddataservice/app/src/feature_stub_impl.cpp index 61dad4841..4ac875dfc 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.cpp +++ b/services/distributeddataservice/app/src/feature_stub_impl.cpp @@ -108,12 +108,4 @@ int32_t FeatureStubImpl::OnReady(const std::string &device) } return featureImpl_->OnReady(device); } - -std::pair FeatureStubImpl::GetCleaner() -{ - if (featureImpl_ == nullptr) { - return { "", nullptr }; - } - return featureImpl_->GetCleaner(); -} } diff --git a/services/distributeddataservice/app/src/feature_stub_impl.h b/services/distributeddataservice/app/src/feature_stub_impl.h index 943eaa18c..b9714b95c 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.h +++ b/services/distributeddataservice/app/src/feature_stub_impl.h @@ -26,7 +26,6 @@ public: class FeatureStubImpl final : public IRemoteStub { public: - using Cleaner = FeatureSystem::Cleaner; explicit FeatureStubImpl(std::shared_ptr feature); ~FeatureStubImpl(); int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, @@ -40,7 +39,6 @@ public: int32_t Online(const std::string &device); int32_t Offline(const std::string &device); int32_t OnReady(const std::string &device); - std::pair GetCleaner(); private: std::shared_ptr featureImpl_; }; diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index da6cf9adf..17d6db73f 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -155,7 +155,6 @@ sptr KvStoreDataService::GetFeatureInterface(const std::string &n }); if (isFirstCreate) { feature->OnInitialize(executors_); - RegisterCleaner(feature); } return feature != nullptr ? feature->AsObject() : nullptr; } @@ -718,10 +717,7 @@ int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t use if (meta.instanceId == appIndex && !meta.appId.empty() && !meta.storeId.empty()) { ZLOGI("data cleared bundleName:%{public}s, stordId:%{public}s, appIndex:%{public}d", bundleName.c_str(), Anonymous::Change(meta.storeId).c_str(), appIndex); - auto cleaner = cleaners_[GetStore(meta)]; - if (!cleaner) { - cleaner(meta.tokenId, meta.storeId); - } + FeatureSystem::GetInstance().GetHandler(GetStore(meta.storeType)).ClearData(meta.tokenId, meta.storeId); MetaDataManager::GetInstance().DelMeta(meta.GetKey()); MetaDataManager::GetInstance().DelMeta(meta.GetSecretKey(), true); MetaDataManager::GetInstance().DelMeta(meta.GetStrategyKey()); @@ -733,28 +729,20 @@ int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t use return SUCCESS; } -std::string KvStoreDataService::GetStore(const StoreMetaData &metaData) const +std::string KvStoreDataService::GetStore(const int32_t &storeType) const { - if (metaData.storeType >= StoreMetaData::StoreType::STORE_KV_BEGIN - && metaData.storeType <= StoreMetaData::StoreType::STORE_KV_END) { + if (storeType >= StoreMetaData::StoreType::STORE_KV_BEGIN + && storeType <= StoreMetaData::StoreType::STORE_KV_END) { return "kv_store"; } - if (metaData.storeType >= StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN - && metaData.storeType <= StoreMetaData::StoreType::STORE_RELATIONAL_END) { + if (storeType >= StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN + && storeType <= StoreMetaData::StoreType::STORE_RELATIONAL_END) { return "relational_store"; } - if (metaData.storeType >= StoreMetaData::StoreType::STORE_OBJECT_BEGIN - && metaData.storeType <= StoreMetaData::StoreType::STORE_OBJECT_END) { + if (storeType >= StoreMetaData::StoreType::STORE_OBJECT_BEGIN + && storeType <= StoreMetaData::StoreType::STORE_OBJECT_END) { return "data_object"; } return "other"; } - -void KvStoreDataService::RegisterCleaner(sptr feature) -{ - auto [name, cleaner] = feature->GetCleaner(); - if (cleaner) { - cleaners_.InsertOrAssign(name, cleaner); - } -} } // namespace OHOS::DistributedKv diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index ba091d908..2a6a7527e 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -44,9 +44,6 @@ class KvStoreDataService : public SystemAbility, public KvStoreDataServiceStub { public: using StoreMetaData = DistributedData::StoreMetaData; - using Cleaner = DistributedData::FeatureSystem::Feature::Cleaner; - using FeatureStubImpl = DistributedData::FeatureStubImpl; - // record kvstore meta version for compatible, should update when modify kvstore meta structure. static constexpr uint32_t STORE_VERSION = 0x03000001; @@ -133,8 +130,7 @@ private: static DistributedDB::SecurityOption ConvertSecurity(int securityLevel); static Status InitNbDbOption(const Options &options, const std::vector &cipherKey, DistributedDB::KvStoreNbDelegate::Option &dbOption); - std::string GetStore(const StoreMetaData &metaData) const; - void RegisterCleaner(sptr feature); + std::string GetStore(const int32_t &storeType) const; static constexpr int TEN_SEC = 10; @@ -146,7 +142,6 @@ private: ConcurrentMap> features_; std::shared_ptr deviceInnerListener_; std::shared_ptr executors_; - ConcurrentMap cleaners_; }; } #endif // KVSTORE_DATASERVICE_H diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index cdf764b53..2a15f1687 100644 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -20,7 +20,7 @@ config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "//foundation/distributeddatamgr/kv_store/frameworks/common", - "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", diff --git a/services/distributeddataservice/framework/feature/feature_system.cpp b/services/distributeddataservice/framework/feature/feature_system.cpp index 12dbb716e..f9122fe48 100644 --- a/services/distributeddataservice/framework/feature/feature_system.cpp +++ b/services/distributeddataservice/framework/feature/feature_system.cpp @@ -16,6 +16,7 @@ #include "feature/feature_system.h" namespace OHOS { namespace DistributedData { +ConcurrentMap FeatureSystem::handlers_; FeatureSystem &FeatureSystem::GetInstance() { static FeatureSystem instance; @@ -28,6 +29,12 @@ int32_t FeatureSystem::RegisterCreator(const std::string &name, Creator creator, return E_OK; } +int32_t FeatureSystem::RegisterHandler(const std::string &name, Feature::Handler handler) +{ + handlers_.InsertOrAssign(name, std::move(handler)); + return E_OK; +} + FeatureSystem::Creator FeatureSystem::GetCreator(const std::string &name) { auto [success, pair] = creators_.Find(name); @@ -51,6 +58,12 @@ std::vector FeatureSystem::GetFeatureName(int32_t flag) return features; } +FeatureSystem::Feature::Handler FeatureSystem::GetHandler(const std::string &name) +{ + auto [isHandlerFound, handler] = handlers_.Find(name); + return isHandlerFound ? handler : Feature::Handler(); +} + FeatureSystem::Feature::~Feature() { } @@ -105,9 +118,9 @@ int32_t FeatureSystem::Feature::OnBind(const FeatureSystem::Feature::BindInfo &b return E_OK; } -std::pair FeatureSystem::Feature::GetCleaner() +int32_t FeatureSystem::Feature::Handler::ClearData(uint32_t &tokenId, std::string &storeId) { - return { "", nullptr }; + return E_OK; } } // namespace DistributedData } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/framework/include/feature/feature_system.h b/services/distributeddataservice/framework/include/feature/feature_system.h index bb78ea3fc..933420256 100644 --- a/services/distributeddataservice/framework/include/feature/feature_system.h +++ b/services/distributeddataservice/framework/include/feature/feature_system.h @@ -29,7 +29,6 @@ namespace DistributedData { class API_EXPORT FeatureSystem { public: using Error = GeneralError; - inline static constexpr int32_t STUB_SUCCESS = Error::E_OK; enum BindFlag : int32_t { BIND_LAZY, @@ -37,12 +36,15 @@ public: }; class API_EXPORT Feature { public: - using Cleaner = std::function; struct BindInfo { std::string selfName; uint32_t selfTokenId; std::shared_ptr executors; }; + class Handler { + public: + virtual int32_t ClearData(uint32_t &tokenId, std::string &storeId); + }; virtual ~Feature(); virtual int OnRemoteRequest(uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply) = 0; virtual int32_t OnInitialize(); @@ -55,12 +57,13 @@ public: virtual int32_t Online(const std::string &device); virtual int32_t Offline(const std::string &device); virtual int32_t OnReady(const std::string &device); - virtual std::pair GetCleaner(); }; using Creator = std::function()>; static FeatureSystem &GetInstance(); int32_t RegisterCreator(const std::string &name, Creator creator, int32_t flag = BIND_LAZY); + int32_t RegisterHandler(const std::string &name, Feature::Handler handler); Creator GetCreator(const std::string &name); + Feature::Handler GetHandler(const std::string &name); std::vector GetFeatureName(int32_t flag); private: @@ -71,6 +74,7 @@ private: FeatureSystem &operator=(FeatureSystem &&) = delete; ConcurrentMap> creators_; + static ConcurrentMap handlers_; }; } // namespace DistributedData } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 81246b4b3..5e9fbcfc5 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -64,6 +64,7 @@ RdbServiceImpl::Factory::Factory() AutoCache::GetInstance().RegCreator(RDB_DEVICE_COLLABORATION, [](const StoreMetaData &metaData) -> GeneralStore* { return new (std::nothrow) RdbGeneralStore(metaData); }); + FeatureSystem::GetInstance().RegisterHandler(RdbServiceImpl::SERVICE_NAME, std::move(RdbHandler())); } RdbServiceImpl::Factory::~Factory() @@ -695,11 +696,9 @@ void RdbServiceImpl::SyncAgent::SetWatcher(std::shared_ptr watcher) } } -std::pair RdbServiceImpl::GetCleaner() +int32_t RdbServiceImpl::RdbHandler::ClearData(uint32_t &tokenId, std::string &storeId) { - auto cleaner = [](uint32_t &tokenId, const std::string &storeId) { - AutoCache::GetInstance().CloseStore(tokenId, storeId); - }; - return { RdbServiceImpl::SERVICE_NAME, std::move(cleaner) }; + AutoCache::GetInstance().CloseStore(tokenId, storeId); + return RDB_OK; } } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 669d8d054..9505c9f0a 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -75,7 +75,9 @@ public: int32_t OnBind(const BindInfo &bindInfo) override; - std::pair GetCleaner() override; + class RdbHandler : public Feature::Handler { + int32_t ClearData(uint32_t &tokenId, std::string &storeId) override; + }; private: using Watchers = DistributedData::AutoCache::Watchers; -- Gitee From b4fd9ede68d5e3c7a2b955b8229ce0a7f803cad9 Mon Sep 17 00:00:00 2001 From: renjiecui Date: Mon, 28 Aug 2023 16:22:50 +0800 Subject: [PATCH 3/4] add static acts Signed-off-by: renjiecui --- .../app/src/feature_stub_impl.cpp | 16 ------ .../app/src/feature_stub_impl.h | 2 - .../app/src/kvstore_data_service.cpp | 51 +++++++----------- .../app/src/kvstore_data_service.h | 3 +- .../distributeddataservice/framework/BUILD.gn | 1 + .../framework/feature/feature_system.cpp | 39 ++++---------- .../framework/feature/static_acts.cpp | 35 ++++++++++++ .../include/feature/feature_system.h | 13 ++--- .../framework/include/feature/static_acts.h | 31 +++++++++++ .../service/cloud/cloud_service_impl.cpp | 5 +- .../service/cloud/cloud_service_impl.h | 9 +++- .../data_share/data_share_service_impl.cpp | 6 ++- .../data_share/data_share_service_impl.h | 10 +++- .../service/object/object_service_impl.cpp | 4 +- .../service/object/object_service_impl.h | 10 +++- .../service/rdb/rdb_service_impl.cpp | 53 ++++++++++--------- .../service/rdb/rdb_service_impl.h | 26 +++++---- 17 files changed, 182 insertions(+), 132 deletions(-) create mode 100644 services/distributeddataservice/framework/feature/static_acts.cpp create mode 100644 services/distributeddataservice/framework/include/feature/static_acts.h diff --git a/services/distributeddataservice/app/src/feature_stub_impl.cpp b/services/distributeddataservice/app/src/feature_stub_impl.cpp index 4ac875dfc..010dc03fc 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.cpp +++ b/services/distributeddataservice/app/src/feature_stub_impl.cpp @@ -53,22 +53,6 @@ int32_t FeatureStubImpl::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const return featureImpl_->OnAppExit(uid, pid, tokenId, bundleName); } -int32_t FeatureStubImpl::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) -{ - if (featureImpl_ == nullptr) { - return -1; - } - return featureImpl_->OnAppUninstall(bundleName, user, index); -} - -int32_t FeatureStubImpl::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) -{ - if (featureImpl_ == nullptr) { - return -1; - } - return featureImpl_->OnAppUpdate(bundleName, user, index); -} - int32_t FeatureStubImpl::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) { if (featureImpl_ == nullptr) { diff --git a/services/distributeddataservice/app/src/feature_stub_impl.h b/services/distributeddataservice/app/src/feature_stub_impl.h index b9714b95c..28f47182c 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.h +++ b/services/distributeddataservice/app/src/feature_stub_impl.h @@ -32,8 +32,6 @@ public: MessageOption &option) override; int32_t OnInitialize(std::shared_ptr executor); int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName); - int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); - int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m); int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account); int32_t Online(const std::string &device); diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 17d6db73f..79fc2a164 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -685,26 +685,32 @@ void KvStoreDataService::OnDeviceOnReady(const AppDistributedKv::DeviceInfo &inf int32_t KvStoreDataService::OnUninstall(const std::string &bundleName, int32_t user, int32_t index) { - features_.ForEachCopies( - [bundleName, user, index](const auto &, sptr &value) { - value->OnAppUninstall(bundleName, user, index); - return false; - }); - return 0; + auto staticActs = FeatureSystem::GetInstance().GetStaticActs(); + staticActs.ForEachCopies([bundleName, user, index](const auto &, const std::shared_ptr& acts) { + acts->OnAppUninstall(bundleName, user, index); + return false; + }); + return SUCCESS; } int32_t KvStoreDataService::OnUpdate(const std::string &bundleName, int32_t user, int32_t index) { - features_.ForEachCopies( - [bundleName, user, index](const auto &, sptr &value) { - value->OnAppUpdate(bundleName, user, index); - return false; - }); - return 0; + auto staticActs = FeatureSystem::GetInstance().GetStaticActs(); + staticActs.ForEachCopies([bundleName, user, index](const auto &, const std::shared_ptr& acts) { + acts->OnAppUpdate(bundleName, user, index); + return false; + }); + return SUCCESS; } -int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t userId, int32_t appIndex) +int32_t KvStoreDataService::ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex) { + auto staticActs = FeatureSystem::GetInstance().GetStaticActs(); + staticActs.ForEachCopies([bundleName, userId, appIndex](const auto &, const std::shared_ptr& acts) { + acts->OnClearAppStorage(bundleName, userId, appIndex); + return false; + }); + std::vector metaData; std::string prefix = StoreMetaData::GetPrefix( { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(userId), "default", bundleName }); @@ -713,11 +719,11 @@ int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t use bundleName.c_str(), userId, appIndex); return ERROR; } + for (auto &meta : metaData) { if (meta.instanceId == appIndex && !meta.appId.empty() && !meta.storeId.empty()) { ZLOGI("data cleared bundleName:%{public}s, stordId:%{public}s, appIndex:%{public}d", bundleName.c_str(), Anonymous::Change(meta.storeId).c_str(), appIndex); - FeatureSystem::GetInstance().GetHandler(GetStore(meta.storeType)).ClearData(meta.tokenId, meta.storeId); MetaDataManager::GetInstance().DelMeta(meta.GetKey()); MetaDataManager::GetInstance().DelMeta(meta.GetSecretKey(), true); MetaDataManager::GetInstance().DelMeta(meta.GetStrategyKey()); @@ -728,21 +734,4 @@ int32_t KvStoreDataService::ClearData(const std::string &bundleName, int32_t use } return SUCCESS; } - -std::string KvStoreDataService::GetStore(const int32_t &storeType) const -{ - if (storeType >= StoreMetaData::StoreType::STORE_KV_BEGIN - && storeType <= StoreMetaData::StoreType::STORE_KV_END) { - return "kv_store"; - } - if (storeType >= StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN - && storeType <= StoreMetaData::StoreType::STORE_RELATIONAL_END) { - return "relational_store"; - } - if (storeType >= StoreMetaData::StoreType::STORE_OBJECT_BEGIN - && storeType <= StoreMetaData::StoreType::STORE_OBJECT_END) { - return "data_object"; - } - return "other"; -} } // namespace OHOS::DistributedKv diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index 2a6a7527e..cd61eae8a 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -55,7 +55,7 @@ public: sptr GetFeatureInterface(const std::string &name) override; - int32_t ClearData(const std::string &bundleName, int32_t userId, int32_t appIndex) override; + int32_t ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex) override; void OnDump() override; @@ -130,7 +130,6 @@ private: static DistributedDB::SecurityOption ConvertSecurity(int securityLevel); static Status InitNbDbOption(const Options &options, const std::vector &cipherKey, DistributedDB::KvStoreNbDelegate::Option &dbOption); - std::string GetStore(const int32_t &storeType) const; static constexpr int TEN_SEC = 10; diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index b13f8c456..692ed9a80 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -56,6 +56,7 @@ ohos_shared_library("distributeddatasvcfwk") { "eventcenter/event.cpp", "eventcenter/event_center.cpp", "feature/feature_system.cpp", + "feature/static_acts.cpp", "metadata/appid_meta_data.cpp", "metadata/capability_meta_data.cpp", "metadata/capability_range.cpp", diff --git a/services/distributeddataservice/framework/feature/feature_system.cpp b/services/distributeddataservice/framework/feature/feature_system.cpp index f9122fe48..f613cb524 100644 --- a/services/distributeddataservice/framework/feature/feature_system.cpp +++ b/services/distributeddataservice/framework/feature/feature_system.cpp @@ -16,7 +16,6 @@ #include "feature/feature_system.h" namespace OHOS { namespace DistributedData { -ConcurrentMap FeatureSystem::handlers_; FeatureSystem &FeatureSystem::GetInstance() { static FeatureSystem instance; @@ -29,12 +28,6 @@ int32_t FeatureSystem::RegisterCreator(const std::string &name, Creator creator, return E_OK; } -int32_t FeatureSystem::RegisterHandler(const std::string &name, Feature::Handler handler) -{ - handlers_.InsertOrAssign(name, std::move(handler)); - return E_OK; -} - FeatureSystem::Creator FeatureSystem::GetCreator(const std::string &name) { auto [success, pair] = creators_.Find(name); @@ -45,6 +38,17 @@ FeatureSystem::Creator FeatureSystem::GetCreator(const std::string &name) return creator; } +int32_t FeatureSystem::RegisterStaticActs(const std::string &name, std::shared_ptr staticActs) +{ + staticActs_.InsertOrAssign(name, std::move(staticActs)); + return E_OK; +} + +ConcurrentMap> &FeatureSystem::GetStaticActs() +{ + return staticActs_; +} + std::vector FeatureSystem::GetFeatureName(int32_t flag) { std::vector features; @@ -58,12 +62,6 @@ std::vector FeatureSystem::GetFeatureName(int32_t flag) return features; } -FeatureSystem::Feature::Handler FeatureSystem::GetHandler(const std::string &name) -{ - auto [isHandlerFound, handler] = handlers_.Find(name); - return isHandlerFound ? handler : Feature::Handler(); -} - FeatureSystem::Feature::~Feature() { } @@ -78,16 +76,6 @@ int32_t FeatureSystem::Feature::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId return E_OK; } -int32_t FeatureSystem::Feature::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) -{ - return E_OK; -} - -int32_t FeatureSystem::Feature::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) -{ - return E_OK; -} - int32_t FeatureSystem::Feature::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) { return E_OK; @@ -117,10 +105,5 @@ int32_t FeatureSystem::Feature::OnBind(const FeatureSystem::Feature::BindInfo &b { return E_OK; } - -int32_t FeatureSystem::Feature::Handler::ClearData(uint32_t &tokenId, std::string &storeId) -{ - return E_OK; -} } // namespace DistributedData } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/framework/feature/static_acts.cpp b/services/distributeddataservice/framework/feature/static_acts.cpp new file mode 100644 index 000000000..aea467705 --- /dev/null +++ b/services/distributeddataservice/framework/feature/static_acts.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 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. + */ +#include "feature/static_acts.h" +namespace OHOS::DistributedData { +StaticActs::~StaticActs() +{ +} + +int32_t StaticActs::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +{ + return E_OK; +} + +int32_t StaticActs::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) +{ + return E_OK; +} + +int32_t StaticActs::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) +{ + return E_OK; +} +} diff --git a/services/distributeddataservice/framework/include/feature/feature_system.h b/services/distributeddataservice/framework/include/feature/feature_system.h index 933420256..b96f379d8 100644 --- a/services/distributeddataservice/framework/include/feature/feature_system.h +++ b/services/distributeddataservice/framework/include/feature/feature_system.h @@ -19,6 +19,7 @@ #include "concurrent_map.h" #include "error/general_error.h" #include "executor_pool.h" +#include "static_acts.h" #include "visibility.h" namespace DistributedDB { struct AutoLaunchParam; @@ -41,17 +42,11 @@ public: uint32_t selfTokenId; std::shared_ptr executors; }; - class Handler { - public: - virtual int32_t ClearData(uint32_t &tokenId, std::string &storeId); - }; virtual ~Feature(); virtual int OnRemoteRequest(uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply) = 0; virtual int32_t OnInitialize(); virtual int32_t OnBind(const BindInfo &bindInfo); virtual int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName); - virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); - virtual int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m); virtual int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account); virtual int32_t Online(const std::string &device); @@ -61,9 +56,9 @@ public: using Creator = std::function()>; static FeatureSystem &GetInstance(); int32_t RegisterCreator(const std::string &name, Creator creator, int32_t flag = BIND_LAZY); - int32_t RegisterHandler(const std::string &name, Feature::Handler handler); Creator GetCreator(const std::string &name); - Feature::Handler GetHandler(const std::string &name); + int32_t RegisterStaticActs(const std::string &name, std::shared_ptr staticActs); + ConcurrentMap> &GetStaticActs(); std::vector GetFeatureName(int32_t flag); private: @@ -74,7 +69,7 @@ private: FeatureSystem &operator=(FeatureSystem &&) = delete; ConcurrentMap> creators_; - static ConcurrentMap handlers_; + ConcurrentMap> staticActs_; }; } // namespace DistributedData } diff --git a/services/distributeddataservice/framework/include/feature/static_acts.h b/services/distributeddataservice/framework/include/feature/static_acts.h new file mode 100644 index 000000000..7d1517459 --- /dev/null +++ b/services/distributeddataservice/framework/include/feature/static_acts.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 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_FRAMEWORK_STATIC_ACTS_H +#define OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H +#include +#include +#include "error/general_error.h" +#include "visibility.h" +namespace OHOS::DistributedData { +class API_EXPORT StaticActs { +public: + virtual ~StaticActs(); + virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); + virtual int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); + virtual int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index); +}; +} // namespace OHOS::DistributedData +#endif //OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 972cc2124..fa4ebd562 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -50,6 +50,9 @@ CloudServiceImpl::Factory::Factory() noexcept return product_; }, FeatureSystem::BIND_NOW); + staticActs_ = std::make_shared(); + FeatureSystem::GetInstance().RegisterStaticActs(CloudServiceImpl::SERVICE_NAME, + staticActs_); } CloudServiceImpl::Factory::~Factory() {} @@ -467,7 +470,7 @@ std::pair CloudServiceImpl::GetCloudInfo(int32_t userId) return { SUCCESS, cloudInfo }; } -int32_t CloudServiceImpl::OnAppUninstall( +int32_t CloudServiceImpl::CloudStatic::OnAppUninstall( const std::string &bundleName, int32_t user, int32_t index) { MetaDataManager::GetInstance().DelMeta(Subscription::GetRelationKey(user, bundleName), true); diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index 866e48357..f1ef2e072 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -23,6 +23,7 @@ #include "cloud/schema_meta.h" #include "cloud/subscription.h" #include "cloud_service_stub.h" +#include "feature/static_acts.h" #include "sync_manager.h" namespace OHOS::CloudData { class CloudServiceImpl : public CloudServiceStub { @@ -38,17 +39,23 @@ 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 OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; int32_t Online(const std::string &device) override; int32_t Offline(const std::string &device) override; private: + using StaticActs = DistributedData::StaticActs; + class CloudStatic : public StaticActs { + public: + ~CloudStatic() override {}; + int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; + }; class Factory { public: Factory() noexcept; ~Factory(); private: std::shared_ptr product_; + std::shared_ptr staticActs_; }; static Factory factory_; diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp index ca9b7216d..973ed64e0 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp @@ -43,6 +43,8 @@ DataShareServiceImpl::Factory::Factory() FeatureSystem::GetInstance().RegisterCreator("data_share", []() { return std::make_shared(); }); + staticActs_ = std::make_shared(); + FeatureSystem::GetInstance().RegisterStaticActs("data_share", staticActs_); } DataShareServiceImpl::Factory::~Factory() {} @@ -444,8 +446,8 @@ void DataShareServiceImpl::OnConnectDone() AppConnectManager::Notify(callerBundleName); } -int32_t DataShareServiceImpl::OnAppUninstall( - const std::string &bundleName, int32_t user, int32_t index) +int32_t DataShareServiceImpl::DataShareStatic::OnAppUninstall(const std::string &bundleName, int32_t user, + int32_t index) { ZLOGI("%{public}s uninstalled", bundleName.c_str()); PublishedData::Delete(bundleName, user); diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.h b/services/distributeddataservice/service/data_share/data_share_service_impl.h index a71cc0d48..a505f9158 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.h +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.h @@ -25,6 +25,7 @@ #include "datashare_template.h" #include "db_delegate.h" #include "delete_strategy.h" +#include "feature/static_acts.h" #include "get_data_strategy.h" #include "insert_strategy.h" #include "publish_strategy.h" @@ -68,15 +69,22 @@ public: const int64_t subscriberId) override; void OnConnectDone() override; int32_t OnBind(const BindInfo &binderInfo) override; - int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName) override; void NotifyObserver(const std::string &uri) override; private: + using StaticActs = DistributedData::StaticActs; + class DataShareStatic : public StaticActs { + public: + ~DataShareStatic() override {}; + int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; + }; class Factory { public: Factory(); ~Factory(); + private: + std::shared_ptr staticActs_; }; class TimerReceiver : public EventFwk::CommonEventSubscriber { public: diff --git a/services/distributeddataservice/service/object/object_service_impl.cpp b/services/distributeddataservice/service/object/object_service_impl.cpp index c38e77dd9..132faa2bb 100644 --- a/services/distributeddataservice/service/object/object_service_impl.cpp +++ b/services/distributeddataservice/service/object/object_service_impl.cpp @@ -44,6 +44,8 @@ ObjectServiceImpl::Factory::Factory() return std::make_shared(); }, FeatureSystem::BIND_NOW); + staticActs_ = std::make_shared(); + FeatureSystem::GetInstance().RegisterStaticActs("data_object", staticActs_); } ObjectServiceImpl::Factory::~Factory() @@ -219,7 +221,7 @@ void ObjectServiceImpl::Clear() return; } -int32_t ObjectServiceImpl::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +int32_t ObjectServiceImpl::ObjectStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) { ZLOGI("begin. %{public}s", bundleName.c_str()); int32_t result = ObjectStoreManager::GetInstance()->DeleteByAppId(bundleName); diff --git a/services/distributeddataservice/service/object/object_service_impl.h b/services/distributeddataservice/service/object/object_service_impl.h index f9e038a12..caa1c3404 100644 --- a/services/distributeddataservice/service/object/object_service_impl.h +++ b/services/distributeddataservice/service/object/object_service_impl.h @@ -16,6 +16,7 @@ #ifndef DISTRIBUTEDDATASERVICE_OBJECT_SERVICE_H #define DISTRIBUTEDDATASERVICE_OBJECT_SERVICE_H +#include "feature/static_acts.h" #include "object_manager.h" #include "object_service_stub.h" #include "visibility.h" @@ -43,14 +44,21 @@ public: int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &appId) override; int32_t OnInitialize() override; int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override; - int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; int32_t OnBind(const BindInfo &bindInfo) override; private: + using StaticActs = DistributedData::StaticActs; + class ObjectStatic : public StaticActs { + public: + ~ObjectStatic() override {}; + int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; + }; class Factory { public: Factory(); ~Factory(); + private: + std::shared_ptr staticActs_; }; static Factory factory_; std::shared_ptr executors_; diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 5e9fbcfc5..d68e7787d 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -64,7 +64,9 @@ RdbServiceImpl::Factory::Factory() AutoCache::GetInstance().RegCreator(RDB_DEVICE_COLLABORATION, [](const StoreMetaData &metaData) -> GeneralStore* { return new (std::nothrow) RdbGeneralStore(metaData); }); - FeatureSystem::GetInstance().RegisterHandler(RdbServiceImpl::SERVICE_NAME, std::move(RdbHandler())); + staticActs_ = std::make_shared(); + FeatureSystem::GetInstance().RegisterStaticActs(RdbServiceImpl::SERVICE_NAME, + staticActs_); } RdbServiceImpl::Factory::~Factory() @@ -634,37 +636,19 @@ int32_t RdbServiceImpl::OnBind(const BindInfo &bindInfo) return 0; } -int32_t RdbServiceImpl::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +int32_t RdbServiceImpl::RdbStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) { return CloseStore(bundleName, user, index); } -int32_t RdbServiceImpl::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) +int32_t RdbServiceImpl::RdbStatic::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) { return CloseStore(bundleName, user, index); } -int32_t RdbServiceImpl::CloseStore(const std::string &bundleName, int32_t user, int32_t index) const +int32_t RdbServiceImpl::RdbStatic::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) { - std::string prefix = StoreMetaData::GetPrefix( - { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(user), "default", bundleName }); - std::vector storeMetaData; - if (!MetaDataManager::GetInstance().LoadMeta(prefix, storeMetaData)) { - ZLOGE("load meta failed! bundleName:%{public}s, user:%{public}d, index:%{public}d", - bundleName.c_str(), user, index); - return E_ERROR; - } - for (const auto &meta : storeMetaData) { - if (meta.storeType < StoreMetaData::STORE_RELATIONAL_BEGIN || - meta.storeType > StoreMetaData::STORE_RELATIONAL_END) { - continue; - } - if (meta.instanceId == index && !meta.appId.empty() && !meta.storeId.empty()) { - AutoCache::GetInstance().CloseStore(meta.tokenId); - break; - } - } - return E_OK; + return CloseStore(bundleName, user, index); } void RdbServiceImpl::SyncAgent::ReInit(pid_t pid, const std::string &bundleName) @@ -696,9 +680,26 @@ void RdbServiceImpl::SyncAgent::SetWatcher(std::shared_ptr watcher) } } -int32_t RdbServiceImpl::RdbHandler::ClearData(uint32_t &tokenId, std::string &storeId) +int32_t RdbServiceImpl::RdbStatic::CloseStore(const std::string &bundleName, int32_t user, int32_t index) const { - AutoCache::GetInstance().CloseStore(tokenId, storeId); - return RDB_OK; + std::string prefix = StoreMetaData::GetPrefix( + { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(user), "default", bundleName }); + std::vector storeMetaData; + if (!MetaDataManager::GetInstance().LoadMeta(prefix, storeMetaData)) { + ZLOGE("load meta failed! bundleName:%{public}s, user:%{public}d, index:%{public}d", + bundleName.c_str(), user, index); + return E_ERROR; + } + for (const auto &meta : storeMetaData) { + if (meta.storeType < StoreMetaData::STORE_RELATIONAL_BEGIN || + meta.storeType > StoreMetaData::STORE_RELATIONAL_END) { + continue; + } + if (meta.instanceId == index && !meta.appId.empty() && !meta.storeId.empty()) { + AutoCache::GetInstance().CloseStore(meta.tokenId); + break; + } + } + return E_OK; } } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 9505c9f0a..65eefe6ea 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -22,6 +22,7 @@ #include #include #include "concurrent_map.h" +#include "feature/static_acts.h" #include "metadata/secret_key_meta_data.h" #include "metadata/store_meta_data.h" #include "rdb_notifier_proxy.h" @@ -31,6 +32,7 @@ #include "store_observer.h" #include "visibility.h" #include "store/general_value.h" + namespace OHOS::DistributedRdb { class API_EXPORT RdbServiceImpl : public RdbServiceStub { public: @@ -61,26 +63,19 @@ public: int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) override; - int32_t OnInitialize() override; - int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName) override; - int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; - - int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) override; - int32_t GetSchema(const RdbSyncerParam ¶m) override; int32_t Delete(const RdbSyncerParam ¶m) override; int32_t OnBind(const BindInfo &bindInfo) override; - class RdbHandler : public Feature::Handler { - int32_t ClearData(uint32_t &tokenId, std::string &storeId) override; - }; + int32_t OnInitialize() override; private: using Watchers = DistributedData::AutoCache::Watchers; + using StaticActs = DistributedData::StaticActs; struct SyncAgent { pid_t pid_ = 0; int32_t count_ = 0; @@ -92,12 +87,23 @@ private: void SetWatcher(std::shared_ptr watcher); }; + class RdbStatic : public StaticActs { + public: + ~RdbStatic() override {}; + int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; + int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) override; + int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) override; + private: + int32_t CloseStore(const std::string &bundleName, int32_t user, int32_t index) const; + }; + class Factory { public: Factory(); ~Factory(); private: std::shared_ptr product_; + std::shared_ptr staticActs_; }; static constexpr inline uint32_t WAIT_TIME = 30 * 1000; @@ -134,8 +140,6 @@ private: static bool GetPassword(const StoreMetaData &metaData, DistributedDB::CipherPassword &password); - int32_t CloseStore(const std::string &bundleName, int32_t user, int32_t index) const; - static Factory factory_; ConcurrentMap syncAgents_; std::shared_ptr executors_; -- Gitee From a178c1d54a72f579a723eaf17b0258252e5b383f Mon Sep 17 00:00:00 2001 From: renjiecui Date: Tue, 29 Aug 2023 16:43:29 +0800 Subject: [PATCH 4/4] modify code Signed-off-by: renjiecui --- services/distributeddataservice/app/BUILD.gn | 4 +- .../app/src/feature_stub_impl.cpp | 16 ++++ .../app/src/feature_stub_impl.h | 2 + .../app/src/flowctrl_manager/BUILD.gn | 2 +- .../app/src/kvstore_data_service.cpp | 19 +++- .../app/src/kvstore_data_service.h | 3 +- .../app/src/kvstore_data_service_stub.cpp | 91 +++++++++++++++++++ .../app/src/kvstore_data_service_stub.h | 39 ++++++++ .../app/src/uninstaller/BUILD.gn | 2 +- .../distributeddataservice/app/test/BUILD.gn | 6 +- .../fuzztest/dataservicestub_fuzzer/BUILD.gn | 4 +- .../framework/feature/feature_system.cpp | 12 ++- .../framework/feature/static_acts.cpp | 2 +- .../include/feature/feature_system.h | 4 +- .../framework/include/feature/static_acts.h | 4 +- .../distributeddataservice/service/BUILD.gn | 1 - .../service/rdb/rdb_service_impl.cpp | 38 ++++---- .../service/rdb/rdb_service_impl.h | 6 +- .../fuzztest/cloudservicestub_fuzzer/BUILD.gn | 3 +- .../fuzztest/kvdbservicestub_fuzzer/BUILD.gn | 3 +- .../objectservicestub_fuzzer/BUILD.gn | 3 +- .../fuzztest/rdbresultsetstub_fuzzer/BUILD.gn | 3 +- .../fuzztest/rdbservicestub_fuzzer/BUILD.gn | 3 +- .../test/fuzztest/udmfservice_fuzzer/BUILD.gn | 1 + 24 files changed, 230 insertions(+), 41 deletions(-) create mode 100644 services/distributeddataservice/app/src/kvstore_data_service_stub.cpp create mode 100644 services/distributeddataservice/app/src/kvstore_data_service_stub.h diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn index 44bd1927b..b703e19e9 100644 --- a/services/distributeddataservice/app/BUILD.gn +++ b/services/distributeddataservice/app/BUILD.gn @@ -39,7 +39,7 @@ config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/bootstrap/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/config/include", @@ -80,6 +80,7 @@ ohos_shared_library("distributeddataservice") { "src/feature_stub_impl.cpp", "src/kvstore_account_observer.cpp", "src/kvstore_data_service.cpp", + "src/kvstore_data_service_stub.cpp", "src/kvstore_device_listener.cpp", "src/kvstore_meta_manager.cpp", "src/security/security.cpp", @@ -124,6 +125,7 @@ ohos_shared_library("distributeddataservice") { "hitrace:libhitracechain", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "kv_store:distributeddb", "safwk:system_ability_fwk", "samgr:samgr_proxy", diff --git a/services/distributeddataservice/app/src/feature_stub_impl.cpp b/services/distributeddataservice/app/src/feature_stub_impl.cpp index 010dc03fc..4ac875dfc 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.cpp +++ b/services/distributeddataservice/app/src/feature_stub_impl.cpp @@ -53,6 +53,22 @@ int32_t FeatureStubImpl::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const return featureImpl_->OnAppExit(uid, pid, tokenId, bundleName); } +int32_t FeatureStubImpl::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +{ + if (featureImpl_ == nullptr) { + return -1; + } + return featureImpl_->OnAppUninstall(bundleName, user, index); +} + +int32_t FeatureStubImpl::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) +{ + if (featureImpl_ == nullptr) { + return -1; + } + return featureImpl_->OnAppUpdate(bundleName, user, index); +} + int32_t FeatureStubImpl::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) { if (featureImpl_ == nullptr) { diff --git a/services/distributeddataservice/app/src/feature_stub_impl.h b/services/distributeddataservice/app/src/feature_stub_impl.h index 28f47182c..b9714b95c 100644 --- a/services/distributeddataservice/app/src/feature_stub_impl.h +++ b/services/distributeddataservice/app/src/feature_stub_impl.h @@ -32,6 +32,8 @@ public: MessageOption &option) override; int32_t OnInitialize(std::shared_ptr executor); int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName); + int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); + int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m); int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account); int32_t Online(const std::string &device); diff --git a/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn b/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn index d4d44bd53..274d88471 100755 --- a/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn +++ b/services/distributeddataservice/app/src/flowctrl_manager/BUILD.gn @@ -20,7 +20,7 @@ ohos_static_library("distributeddata_flowctrl_static") { include_dirs = [ "../../../adapter/include/account", "../../src", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/interfaces/innerkits/distributeddata/include", "//third_party/json/single_include", diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 79fc2a164..6c0c41d23 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -19,6 +19,7 @@ #include #include +#include "accesstoken_kit.h" #include "auth_delegate.h" #include "auto_launch_export.h" #include "bootstrap.h" @@ -58,6 +59,7 @@ namespace OHOS::DistributedKv { using namespace std::chrono; using namespace OHOS::DistributedData; using namespace OHOS::DistributedDataDfx; +using namespace Security::AccessToken; using KvStoreDelegateManager = DistributedDB::KvStoreDelegateManager; using SecretKeyMeta = DistributedData::SecretKeyMetaData; using DmAdapter = DistributedData::DeviceManagerAdapter; @@ -703,13 +705,20 @@ int32_t KvStoreDataService::OnUpdate(const std::string &bundleName, int32_t user return SUCCESS; } -int32_t KvStoreDataService::ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex) +int32_t KvStoreDataService::ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex, + int32_t tokenId) { + HapTokenInfo hapTokenInfo; + if (AccessTokenKit::GetHapTokenInfo(tokenId, hapTokenInfo) != RET_SUCCESS || hapTokenInfo.tokenID != tokenId) { + ZLOGE("passed wrong tokenId: %{public}d", tokenId); + return ERROR; + } auto staticActs = FeatureSystem::GetInstance().GetStaticActs(); - staticActs.ForEachCopies([bundleName, userId, appIndex](const auto &, const std::shared_ptr& acts) { - acts->OnClearAppStorage(bundleName, userId, appIndex); - return false; - }); + staticActs.ForEachCopies( + [bundleName, userId, appIndex, tokenId](const auto &, const std::shared_ptr &acts) { + acts->OnClearAppStorage(bundleName, userId, appIndex, tokenId); + return false; + }); std::vector metaData; std::string prefix = StoreMetaData::GetPrefix( diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index cd61eae8a..b67fbd979 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -28,7 +28,6 @@ #include "kvstore_device_listener.h" #include "kvstore_meta_manager.h" #include "kvstore_data_service_stub.h" -#include "kvstore_data_service_proxy.h" #include "metadata/store_meta_data.h" #include "reporter.h" #include "runtime_config.h" @@ -55,7 +54,7 @@ public: sptr GetFeatureInterface(const std::string &name) override; - int32_t ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex) override; + int32_t ClearAppStorage(const std::string &bundleName, int32_t userId, int32_t appIndex, int32_t tokenId) override; void OnDump() override; diff --git a/services/distributeddataservice/app/src/kvstore_data_service_stub.cpp b/services/distributeddataservice/app/src/kvstore_data_service_stub.cpp new file mode 100644 index 000000000..f8a13daab --- /dev/null +++ b/services/distributeddataservice/app/src/kvstore_data_service_stub.cpp @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2023 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. +*/ + +#define LOG_TAG "KvStoreDataServiceStub" + +#include "kvstore_data_service_stub.h" +#include +#include "itypes_util.h" +#include "message_parcel.h" +#include "types.h" +#include "log_print.h" + +namespace OHOS { +namespace DistributedKv { +constexpr KvStoreDataServiceStub::RequestHandler + KvStoreDataServiceStub::HANDLERS[static_cast(KvStoreDataServiceInterfaceCode::SERVICE_CMD_LAST)]; + +int32_t KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote(MessageParcel &data, MessageParcel &reply) +{ + AppId appId = { data.ReadString() }; + sptr kvStoreClientDeathObserverProxy = data.ReadRemoteObject(); + if (kvStoreClientDeathObserverProxy == nullptr) { + return -1; + } + Status status = RegisterClientDeathObserver(appId, std::move(kvStoreClientDeathObserverProxy)); + if (!reply.WriteInt32(static_cast(status))) { + return -1; + } + return 0; +} + +int32_t KvStoreDataServiceStub::GetFeatureInterfaceOnRemote(MessageParcel &data, MessageParcel &reply) +{ + std::string name; + if (!ITypesUtil::Unmarshal(data, name)) { + return -1; + } + auto remoteObject = GetFeatureInterface(name); + if (!ITypesUtil::Marshal(reply, remoteObject)) { + return -1; + } + return 0; +} + +int32_t KvStoreDataServiceStub::ClearAppStorageOnRemote(MessageParcel &data, MessageParcel &reply) +{ + std::string bundleName; + int32_t userId; + int32_t appIndex; + int32_t tokenId; + if (!ITypesUtil::Unmarshal(data, bundleName, userId, appIndex, tokenId)) { + return -1; + } + auto remoteObject = ClearAppStorage(bundleName, userId, appIndex, tokenId); + if (!ITypesUtil::Marshal(reply, remoteObject)) { + return -1; + } + return 0; +} + +int32_t KvStoreDataServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) +{ + ZLOGD("code:%{public}u, callingPid:%{public}d", code, IPCSkeleton::GetCallingPid()); + std::u16string descriptor = KvStoreDataServiceStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (descriptor != remoteDescriptor) { + ZLOGE("local descriptor is not equal to remote"); + return -1; + } + if (code >= 0 && code < static_cast(KvStoreDataServiceInterfaceCode::SERVICE_CMD_LAST)) { + return (this->*HANDLERS[code])(data, reply); + } else { + MessageOption mo{ MessageOption::TF_SYNC }; + return IPCObjectStub::OnRemoteRequest(code, data, reply, mo); + } +} +} // namespace DistributedKv +} // namespace OHOS diff --git a/services/distributeddataservice/app/src/kvstore_data_service_stub.h b/services/distributeddataservice/app/src/kvstore_data_service_stub.h new file mode 100644 index 000000000..08767f6d5 --- /dev/null +++ b/services/distributeddataservice/app/src/kvstore_data_service_stub.h @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2023 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 KVSTORE_DATA_SERVICE_STUB_H +#define KVSTORE_DATA_SERVICE_STUB_H +#include "ikvstore_data_service.h" +#include "distributeddata_ipc_interface_code.h" +namespace OHOS::DistributedKv { +class API_EXPORT KvStoreDataServiceStub : public IRemoteStub { +public: + int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) override; + +private: + int32_t GetFeatureInterfaceOnRemote(MessageParcel &data, MessageParcel &reply); + int32_t RegisterClientDeathObserverOnRemote(MessageParcel &data, MessageParcel &reply); + int32_t ClearAppStorageOnRemote(MessageParcel &data, MessageParcel &reply); + + using RequestHandler = int32_t (KvStoreDataServiceStub::*)(MessageParcel &, MessageParcel &); + using code = KvStoreDataServiceInterfaceCode; + static constexpr RequestHandler HANDLERS[static_cast(code::SERVICE_CMD_LAST)] = { + &KvStoreDataServiceStub::GetFeatureInterfaceOnRemote, + &KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote, + &KvStoreDataServiceStub::ClearAppStorageOnRemote, + }; +}; +} // namespace OHOS::DistributedKv +#endif // KVSTORE_DATA_SERVICE_STUB_H diff --git a/services/distributeddataservice/app/src/uninstaller/BUILD.gn b/services/distributeddataservice/app/src/uninstaller/BUILD.gn index f05af203b..87cf3b894 100755 --- a/services/distributeddataservice/app/src/uninstaller/BUILD.gn +++ b/services/distributeddataservice/app/src/uninstaller/BUILD.gn @@ -23,7 +23,7 @@ ohos_static_library("distributeddata_uninstaller_static") { include_dirs = [ "../../../adapter/include/account", "../../src", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/interfaces/innerkits/distributeddata/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index 2a15f1687..42bdfd5c7 100644 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -19,8 +19,8 @@ module_output_path = "datamgr_service/distributeddataservice" config("module_private_config") { visibility = [ ":*" ] include_dirs = [ + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "//foundation/distributeddatamgr/kv_store/frameworks/common", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", @@ -70,6 +70,7 @@ ohos_unittest("KvStoreDataServiceTest") { "../src/feature_stub_impl.cpp", "../src/kvstore_account_observer.cpp", "../src/kvstore_data_service.cpp", + "../src/kvstore_data_service_stub.cpp", "../src/kvstore_device_listener.cpp", "../src/kvstore_meta_manager.cpp", "../src/security/security.cpp", @@ -105,6 +106,7 @@ ohos_unittest("KvStoreDataServiceTest") { } deps = [ + "${kv_store_path}/interfaces/innerkits/distributeddatamgr:distributeddata_mgr", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", @@ -155,6 +157,7 @@ ohos_unittest("SessionManagerTest") { } deps = [ + "${kv_store_path}/interfaces/innerkits/distributeddatamgr:distributeddata_mgr", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", @@ -194,6 +197,7 @@ ohos_unittest("KvStoreFlowCtrlManagerTest") { } deps = [ + "${kv_store_path}/interfaces/innerkits/distributeddatamgr:distributeddata_mgr", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", diff --git a/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn index addb7be63..822c306cf 100644 --- a/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/app/test/fuzztest/dataservicestub_fuzzer/BUILD.gn @@ -21,8 +21,8 @@ ohos_fuzztest("DataServiceStubFuzzTest") { include_dirs = [ "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${data_service_path}/service/bootstrap/include", "${data_service_path}/service/config/include", "${data_service_path}/service/crypto/include", @@ -66,6 +66,7 @@ ohos_fuzztest("DataServiceStubFuzzTest") { "${data_service_path}/app/src/feature_stub_impl.cpp", "${data_service_path}/app/src/kvstore_account_observer.cpp", "${data_service_path}/app/src/kvstore_data_service.cpp", + "${data_service_path}/app/src/kvstore_data_service_stub.cpp", "${data_service_path}/app/src/kvstore_device_listener.cpp", "${data_service_path}/app/src/kvstore_meta_manager.cpp", "${data_service_path}/app/src/security/security.cpp", @@ -103,6 +104,7 @@ ohos_fuzztest("DataServiceStubFuzzTest") { "hitrace:libhitracechain", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/services/distributeddataservice/framework/feature/feature_system.cpp b/services/distributeddataservice/framework/feature/feature_system.cpp index f613cb524..b94ef987f 100644 --- a/services/distributeddataservice/framework/feature/feature_system.cpp +++ b/services/distributeddataservice/framework/feature/feature_system.cpp @@ -44,7 +44,7 @@ int32_t FeatureSystem::RegisterStaticActs(const std::string &name, std::shared_p return E_OK; } -ConcurrentMap> &FeatureSystem::GetStaticActs() +const ConcurrentMap> &FeatureSystem::GetStaticActs() { return staticActs_; } @@ -76,6 +76,16 @@ int32_t FeatureSystem::Feature::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId return E_OK; } +int32_t FeatureSystem::Feature::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +{ + return E_OK; +} + +int32_t FeatureSystem::Feature::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) +{ + return E_OK; +} + int32_t FeatureSystem::Feature::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) { return E_OK; diff --git a/services/distributeddataservice/framework/feature/static_acts.cpp b/services/distributeddataservice/framework/feature/static_acts.cpp index aea467705..817441af9 100644 --- a/services/distributeddataservice/framework/feature/static_acts.cpp +++ b/services/distributeddataservice/framework/feature/static_acts.cpp @@ -28,7 +28,7 @@ int32_t StaticActs::OnAppUpdate(const std::string &bundleName, int32_t user, int return E_OK; } -int32_t StaticActs::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) +int32_t StaticActs::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId) { return E_OK; } diff --git a/services/distributeddataservice/framework/include/feature/feature_system.h b/services/distributeddataservice/framework/include/feature/feature_system.h index b96f379d8..cc8035960 100644 --- a/services/distributeddataservice/framework/include/feature/feature_system.h +++ b/services/distributeddataservice/framework/include/feature/feature_system.h @@ -47,6 +47,8 @@ public: virtual int32_t OnInitialize(); virtual int32_t OnBind(const BindInfo &bindInfo); virtual int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName); + virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); + virtual int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m); virtual int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account); virtual int32_t Online(const std::string &device); @@ -58,7 +60,7 @@ public: int32_t RegisterCreator(const std::string &name, Creator creator, int32_t flag = BIND_LAZY); Creator GetCreator(const std::string &name); int32_t RegisterStaticActs(const std::string &name, std::shared_ptr staticActs); - ConcurrentMap> &GetStaticActs(); + const ConcurrentMap> &GetStaticActs(); std::vector GetFeatureName(int32_t flag); private: diff --git a/services/distributeddataservice/framework/include/feature/static_acts.h b/services/distributeddataservice/framework/include/feature/static_acts.h index 7d1517459..d989f0a5d 100644 --- a/services/distributeddataservice/framework/include/feature/static_acts.h +++ b/services/distributeddataservice/framework/include/feature/static_acts.h @@ -25,7 +25,7 @@ public: virtual ~StaticActs(); virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); - virtual int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index); + virtual int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId); }; } // namespace OHOS::DistributedData -#endif //OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H +#endif // OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index 1913ded4e..023498d58 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -42,7 +42,6 @@ config("module_public_config") { "${datashare_path}/interfaces/inner_api/common/include", "${datashare_path}/interfaces/inner_api/consumer/include", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}/include/", diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index d68e7787d..cd78e9f2e 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -636,21 +636,6 @@ int32_t RdbServiceImpl::OnBind(const BindInfo &bindInfo) return 0; } -int32_t RdbServiceImpl::RdbStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) -{ - return CloseStore(bundleName, user, index); -} - -int32_t RdbServiceImpl::RdbStatic::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) -{ - return CloseStore(bundleName, user, index); -} - -int32_t RdbServiceImpl::RdbStatic::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) -{ - return CloseStore(bundleName, user, index); -} - void RdbServiceImpl::SyncAgent::ReInit(pid_t pid, const std::string &bundleName) { pid_ = pid; @@ -680,8 +665,13 @@ void RdbServiceImpl::SyncAgent::SetWatcher(std::shared_ptr watcher) } } -int32_t RdbServiceImpl::RdbStatic::CloseStore(const std::string &bundleName, int32_t user, int32_t index) const +int32_t RdbServiceImpl::RdbStatic::CloseStore(const std::string &bundleName, int32_t user, int32_t index, + int32_t tokenId) const { + if (tokenId != RdbServiceImpl::RdbStatic::INVALID_TOKENID) { + AutoCache::GetInstance().CloseStore(tokenId); + return E_OK; + } std::string prefix = StoreMetaData::GetPrefix( { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(user), "default", bundleName }); std::vector storeMetaData; @@ -702,4 +692,20 @@ int32_t RdbServiceImpl::RdbStatic::CloseStore(const std::string &bundleName, int } return E_OK; } + +int32_t RdbServiceImpl::RdbStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) +{ + return CloseStore(bundleName, user, index); +} + +int32_t RdbServiceImpl::RdbStatic::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) +{ + return CloseStore(bundleName, user, index); +} + +int32_t RdbServiceImpl::RdbStatic::OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, + int32_t tokenId) +{ + return CloseStore(bundleName, user, index, tokenId); +} } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 65eefe6ea..c8999344b 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -92,9 +92,11 @@ private: ~RdbStatic() override {}; int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) override; - int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index) override; + int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId) override; private: - int32_t CloseStore(const std::string &bundleName, int32_t user, int32_t index) const; + static constexpr inline int32_t INVALID_TOKENID = 0; + int32_t CloseStore(const std::string &bundleName, int32_t user, int32_t index, + int32_t tokenId = INVALID_TOKENID) const; }; class Factory { diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index 0f55bbc75..7683a031a 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -34,8 +34,8 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "${data_service_path}/service/permission/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", "${kv_store_distributeddb_path}/include/", @@ -100,6 +100,7 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "relational_store:native_rdb", ] } diff --git a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn index a5513bcb0..58e977061 100644 --- a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn @@ -32,8 +32,8 @@ ohos_fuzztest("KvdbServiceStubFuzzTest") { "${data_service_path}/service/matrix/include", "${data_service_path}/service/permission/include", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", "${kv_store_distributeddb_path}/include/", @@ -102,6 +102,7 @@ ohos_fuzztest("KvdbServiceStubFuzzTest") { "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", ] } diff --git a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn index f9f66c163..f71790cf9 100644 --- a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn @@ -29,8 +29,8 @@ ohos_fuzztest("ObjectServiceStubFuzzTest") { "${data_service_path}/service/crypto/include", "${data_service_path}/service/object", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", "${kv_store_distributeddb_path}/include/", @@ -91,6 +91,7 @@ ohos_fuzztest("ObjectServiceStubFuzzTest") { "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", ] } diff --git a/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn index efac5a958..68a76083f 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbresultsetstub_fuzzer/BUILD.gn @@ -25,8 +25,8 @@ ohos_fuzztest("RdbResultSetStubFuzzTest") { "${data_service_path}/framework/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", "${kv_store_distributeddb_path}/include/", @@ -75,6 +75,7 @@ ohos_fuzztest("RdbResultSetStubFuzzTest") { "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "relational_store:native_rdb", ] } diff --git a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn index 301aa8493..c3cc42bf7 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn @@ -35,8 +35,8 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { "${data_service_path}/service/permission/include", "${data_service_path}/service/rdb", "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk", "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", + "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", "${kv_store_distributeddb_path}", "${kv_store_distributeddb_path}/include/", @@ -97,6 +97,7 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "relational_store:native_rdb", ] } diff --git a/services/distributeddataservice/service/test/fuzztest/udmfservice_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/udmfservice_fuzzer/BUILD.gn index 4656e9aa1..4a878c22e 100644 --- a/services/distributeddataservice/service/test/fuzztest/udmfservice_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/udmfservice_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("UdmfServiceFuzzTest") { "hilog:libhilog", "ipc:ipc_core", "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", "udmf:udmf_client", ] } -- Gitee