From 91f243dffc3a084462713e6fde80a861225c1396 Mon Sep 17 00:00:00 2001 From: yanhui Date: Thu, 19 Jun 2025 15:09:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhui Change-Id: I6562270067cbe83909bd67dec92d2f172f6c2edc --- bundle.json | 2 + conf/config.json | 14 +++++ .../src/device_manager_adapter.cpp | 2 + .../adapter/communicator/test/BUILD.gn | 1 + .../unittest/device_manager_adapter_test.cpp | 14 +++++ .../communicator/device_manager_adapter.h | 5 +- .../app/src/kvstore_data_service.cpp | 2 +- .../app/src/kvstore_meta_manager.cpp | 2 +- .../unittest/kvstore_data_service_test.cpp | 2 +- .../distributeddataservice/framework/BUILD.gn | 4 ++ .../crypto}/crypto_manager.cpp | 3 +- .../device_manager_delegate.cpp | 36 ++++++++++++ .../framework/directory/directory_manager.cpp | 21 +++---- .../include/crypto}/crypto_manager.h | 0 .../device_manager/device_manager_delegate.h | 36 ++++++++++++ .../include/directory/directory_manager.h | 7 ++- .../include/metadata/store_meta_data.h | 4 +- .../distributeddataservice/service/BUILD.gn | 1 - .../service/backup/BUILD.gn | 1 - .../service/backup/src/backup_manager.cpp | 2 +- .../service/bootstrap/BUILD.gn | 1 - .../service/bootstrap/src/bootstrap.cpp | 7 ++- .../config/include/model/directory_config.h | 5 ++ .../config/src/model/directory_config.cpp | 19 ++++++- .../service/crypto/BUILD.gn | 57 ------------------- .../data_share/common/rdb_delegate.cpp | 2 +- .../service/kvdb/kvdb_general_store.cpp | 2 +- .../service/kvdb/kvdb_service_impl.h | 2 +- .../service/permission/BUILD.gn | 1 - .../service/rdb/BUILD.gn | 1 - .../service/rdb/rdb_general_store.cpp | 2 +- .../service/rdb/rdb_service_impl.h | 2 +- .../service/test/BUILD.gn | 2 - .../test/backup_manager_service_test.cpp | 2 +- .../service/test/crypto_manager_test.cpp | 2 +- .../service/test/directory_manager_test.cpp | 35 +++++++++++- .../datashareservicestub_fuzzer/BUILD.gn | 1 - .../fuzztest/kvdbservicestub_fuzzer/BUILD.gn | 1 - .../objectservicestub_fuzzer/BUILD.gn | 1 - .../test/kvdb_general_store_abnormal_test.cpp | 2 +- .../service/test/kvdb_general_store_test.cpp | 2 +- .../service/test/kvdb_service_test.cpp | 2 +- .../service/test/rdb_service_impl_test.cpp | 2 +- .../test/rdb_service_impl_token_test.cpp | 2 +- .../service/udmf/store/runtime_store.cpp | 4 +- .../service/udmf/udmf_service_impl.cpp | 7 ++- 46 files changed, 212 insertions(+), 113 deletions(-) rename services/distributeddataservice/{service/crypto/src => framework/crypto}/crypto_manager.cpp (99%) create mode 100644 services/distributeddataservice/framework/device_manager/device_manager_delegate.cpp rename services/distributeddataservice/{service/crypto/include => framework/include/crypto}/crypto_manager.h (100%) create mode 100644 services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h delete mode 100644 services/distributeddataservice/service/crypto/BUILD.gn diff --git a/bundle.json b/bundle.json index eb78c8cf7..3a22c1c14 100644 --- a/bundle.json +++ b/bundle.json @@ -130,6 +130,8 @@ "cloud/schema_meta.h", "cloud/subscription.h", "cloud/sync_event.h", + "crypto/crypto_manager.h", + "device_manager/device_manager_delegate.h", "dfx/dfx_types.h", "dfx/reporter.h", "directory/directory_manager.h", diff --git a/conf/config.json b/conf/config.json index b1d053eb8..69b0995a9 100644 --- a/conf/config.json +++ b/conf/config.json @@ -75,6 +75,20 @@ "metaPath": "/data/service/el1/public/database/distributeddata/meta", "clonePath": "/data/service/el2/{userId}/database/distributeddata/secret_key_backup.conf" } + ], + "storeTypes": [ + { + "range": [0, 9], + "type": "kvdb" + }, + { + "range": [10, 19], + "type": "rdb" + }, + { + "range": [20, 29], + "type": "kvdb" + } ] }, "backup": { diff --git a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp index d6a78e9c8..e5cf64a8c 100644 --- a/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp +++ b/services/distributeddataservice/adapter/communicator/src/device_manager_adapter.cpp @@ -28,6 +28,8 @@ using namespace OHOS::AppDistributedKv; using KvStoreUtils = OHOS::DistributedKv::KvStoreUtils; constexpr int32_t DM_OK = 0; constexpr const char *PKG_NAME = "ohos.distributeddata.service"; +__attribute__((used)) static bool g_delegateInit = + DeviceManagerDelegate::RegisterInstance(&DeviceManagerAdapter::GetInstance()); class DataMgrDmStateCall final : public DistributedHardware::DeviceStateCallback { public: explicit DataMgrDmStateCall(DeviceManagerAdapter &dmAdapter) : dmAdapter_(dmAdapter) {} diff --git a/services/distributeddataservice/adapter/communicator/test/BUILD.gn b/services/distributeddataservice/adapter/communicator/test/BUILD.gn index 744b1f376..c014f94b9 100755 --- a/services/distributeddataservice/adapter/communicator/test/BUILD.gn +++ b/services/distributeddataservice/adapter/communicator/test/BUILD.gn @@ -121,6 +121,7 @@ ohos_unittest("DeviceManagerAdapterTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } diff --git a/services/distributeddataservice/adapter/communicator/test/unittest/device_manager_adapter_test.cpp b/services/distributeddataservice/adapter/communicator/test/unittest/device_manager_adapter_test.cpp index a813fb8a0..f08d3153b 100644 --- a/services/distributeddataservice/adapter/communicator/test/unittest/device_manager_adapter_test.cpp +++ b/services/distributeddataservice/adapter/communicator/test/unittest/device_manager_adapter_test.cpp @@ -14,6 +14,7 @@ */ #include "device_manager_adapter.h" +#include "device_manager/device_manager_delegate.h" #include "gtest/gtest.h" #include "accesstoken_kit.h" #include "executor_pool.h" @@ -622,4 +623,17 @@ HWTEST_F(DeviceManagerAdapterTest, IsSameAccount01, TestSize.Level0) auto status = DeviceManagerAdapter::GetInstance().IsSameAccount(networkId); EXPECT_EQ(status, false); } + +/** +* @tc.name: RegisterDelegateInstance +* @tc.desc: test DeviceManagerDelegate::RegisterInstance function +* @tc.type: FUNC +*/ +HWTEST_F(DeviceManagerAdapterTest, RegisterDelegateInstance, TestSize.Level0) +{ + DeviceManagerDelegate::RegisterInstance(&DeviceManagerAdapter::GetInstance()); + // Repeated registration + DeviceManagerDelegate::RegisterInstance(&DeviceManagerAdapter::GetInstance()); + EXPECT_NE(nullptr, DeviceManagerDelegate::GetInstance()); +} } // namespace \ No newline at end of file diff --git a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h index 53135966b..575a2f393 100644 --- a/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h +++ b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h @@ -24,13 +24,14 @@ #include "concurrent_map.h" #include "device_manager.h" #include "device_manager_callback.h" +#include "device_manager/device_manager_delegate.h" #include "dm_device_info.h" #include "executor_pool.h" #include "lru_bucket.h" namespace OHOS { namespace DistributedData { -class API_EXPORT DeviceManagerAdapter { +class API_EXPORT DeviceManagerAdapter : public DeviceManagerDelegate { public: enum DeviceState { DEVICE_ONLINE, @@ -52,7 +53,7 @@ public: void Init(std::shared_ptr executors); Status StartWatchDeviceChange(const AppDeviceChangeListener *observer, const PipeInfo &pipeInfo); Status StopWatchDeviceChange(const AppDeviceChangeListener *observer, const PipeInfo &pipeInfo); - DeviceInfo GetLocalDevice(); + DeviceInfo GetLocalDevice() override; std::vector GetRemoteDevices(); std::vector GetOnlineDevices(); bool IsDeviceReady(const std::string &id); diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 3c80f0741..aff30c73f 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -33,7 +33,7 @@ #include "communication_provider.h" #include "communicator_context.h" #include "config_factory.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "db_info_handle_impl.h" #include "device_manager_adapter.h" #include "device_matrix.h" diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp index 1b785ff30..1472fdd59 100644 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp @@ -23,7 +23,7 @@ #include "account/account_delegate.h" #include "bootstrap.h" #include "communication_provider.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "device_matrix.h" #include "directory/directory_manager.h" diff --git a/services/distributeddataservice/app/test/unittest/kvstore_data_service_test.cpp b/services/distributeddataservice/app/test/unittest/kvstore_data_service_test.cpp index 5dbb1d584..beee71e60 100644 --- a/services/distributeddataservice/app/test/unittest/kvstore_data_service_test.cpp +++ b/services/distributeddataservice/app/test/unittest/kvstore_data_service_test.cpp @@ -15,7 +15,7 @@ #include "auth_delegate.h" #include "bootstrap.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "executor_pool.h" #include diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index 7ef3c07d6..b3b8044f5 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -30,6 +30,7 @@ config("module_public_config") { visibility = [ ":*" ] include_dirs = [ "include", + "${data_service_path}/adapter/include/communicator", ] } @@ -69,6 +70,8 @@ ohos_shared_library("distributeddatasvcfwk") { "cloud/sync_event.cpp", "cloud/sync_strategy.cpp", "communication/connect_manager.cpp", + "crypto/crypto_manager.cpp", + "device_manager/device_manager_delegate.cpp", "device_sync_app/device_sync_app_manager.cpp", "dfx/reporter.cpp", "directory/directory_manager.cpp", @@ -134,6 +137,7 @@ ohos_shared_library("distributeddatasvcfwk") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "hilog:libhilog", + "huks:libhukssdk", "cJSON:cjson", "openssl:libcrypto_shared", "kv_store:datamgr_common", diff --git a/services/distributeddataservice/service/crypto/src/crypto_manager.cpp b/services/distributeddataservice/framework/crypto/crypto_manager.cpp similarity index 99% rename from services/distributeddataservice/service/crypto/src/crypto_manager.cpp rename to services/distributeddataservice/framework/crypto/crypto_manager.cpp index 4db5b90d5..0a15a8356 100644 --- a/services/distributeddataservice/service/crypto/src/crypto_manager.cpp +++ b/services/distributeddataservice/framework/crypto/crypto_manager.cpp @@ -13,8 +13,7 @@ * limitations under the License. */ #define LOG_TAG "CryptoManager" - -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include #include diff --git a/services/distributeddataservice/framework/device_manager/device_manager_delegate.cpp b/services/distributeddataservice/framework/device_manager/device_manager_delegate.cpp new file mode 100644 index 000000000..e85b94b97 --- /dev/null +++ b/services/distributeddataservice/framework/device_manager/device_manager_delegate.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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 "device_manager/device_manager_delegate.h" + +namespace OHOS { +namespace DistributedData { +DeviceManagerDelegate *DeviceManagerDelegate::instance_ = nullptr; + +bool DeviceManagerDelegate::RegisterInstance(DeviceManagerDelegate *instance) +{ + if (instance_ != nullptr) { + return false; + } + instance_ = instance; + return true; +} + +DeviceManagerDelegate *DeviceManagerDelegate::GetInstance() +{ + return instance_; +} +} // namespace DistributedData +} // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/framework/directory/directory_manager.cpp b/services/distributeddataservice/framework/directory/directory_manager.cpp index 8ac7b2f03..805ed1b95 100644 --- a/services/distributeddataservice/framework/directory/directory_manager.cpp +++ b/services/distributeddataservice/framework/directory/directory_manager.cpp @@ -107,7 +107,7 @@ std::string DirectoryManager::GetClonePath(const std::string &userId, uint32_t v return ""; } -void DirectoryManager::Initialize(const std::vector &strategies) +void DirectoryManager::Initialize(const std::vector &strategies, const std::vector &storeTypes) { strategies_.resize(strategies.size()); for (size_t i = 0; i < strategies.size(); ++i) { @@ -127,6 +127,8 @@ void DirectoryManager::Initialize(const std::vector &strategies) std::sort(strategies_.begin(), strategies_.end(), [](const StrategyImpl &curr, const StrategyImpl &prev) { return curr.version > prev.version; }); + + storeTypes_ = storeTypes; } std::string DirectoryManager::GetType(const StoreMetaData &metaData) const @@ -140,19 +142,10 @@ std::string DirectoryManager::GetType(const StoreMetaData &metaData) const std::string DirectoryManager::GetStore(const StoreMetaData &metaData) const { - if (metaData.storeType >= StoreMetaData::StoreType::STORE_KV_BEGIN && - metaData.storeType <= StoreMetaData::StoreType::STORE_KV_END) { - return "kvdb"; - } - // rdb use empty session - if (metaData.storeType >= StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN && - metaData.storeType <= StoreMetaData::StoreType::STORE_RELATIONAL_END) { - return "rdb"; - } - // object use meta - if (metaData.storeType >= StoreMetaData::StoreType::STORE_OBJECT_BEGIN && - metaData.storeType <= StoreMetaData::StoreType::STORE_OBJECT_END) { - return "kvdb"; + for (const auto &storeType : storeTypes_) { + if (metaData.storeType >= storeType.range.front() && metaData.storeType <= storeType.range.back()) { + return storeType.type; + } } return "other"; } diff --git a/services/distributeddataservice/service/crypto/include/crypto_manager.h b/services/distributeddataservice/framework/include/crypto/crypto_manager.h similarity index 100% rename from services/distributeddataservice/service/crypto/include/crypto_manager.h rename to services/distributeddataservice/framework/include/crypto/crypto_manager.h diff --git a/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h b/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h new file mode 100644 index 000000000..fa5ba9b63 --- /dev/null +++ b/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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 DISTRIBUTEDDATAMGR_DEVICE_MANAGER_DELEGATE_H +#define DISTRIBUTEDDATAMGR_DEVICE_MANAGER_DELEGATE_H + +#include "commu_types.h" +#include "visibility.h" + +namespace OHOS { +namespace DistributedData { +class DeviceManagerDelegate { +public: + using DeviceInfo = OHOS::AppDistributedKv::DeviceInfo; + virtual ~DeviceManagerDelegate() = default; + virtual DeviceInfo GetLocalDevice() = 0; + API_EXPORT static bool RegisterInstance(DeviceManagerDelegate *instance); + API_EXPORT static DeviceManagerDelegate *GetInstance(); +private: + static DeviceManagerDelegate *instance_; +}; +} // namespace DistributedData +} // namespace OHOS +#endif // DISTRIBUTEDDATAMGR_DEVICE_MANAGER_DELEGATE_H \ No newline at end of file diff --git a/services/distributeddataservice/framework/include/directory/directory_manager.h b/services/distributeddataservice/framework/include/directory/directory_manager.h index 0570bcd62..5ec7eb441 100644 --- a/services/distributeddataservice/framework/include/directory/directory_manager.h +++ b/services/distributeddataservice/framework/include/directory/directory_manager.h @@ -32,6 +32,10 @@ public: std::string metaPath; std::string clonePath; }; + struct StoreType { + std::vector range; + std::string type; + }; API_EXPORT static DirectoryManager &GetInstance(); API_EXPORT std::string GetStorePath(const StoreMetaData &metaData, uint32_t version = INVALID_VERSION); API_EXPORT std::string GetSecretKeyPath(const StoreMetaData &metaData, uint32_t version = INVALID_VERSION); @@ -40,7 +44,7 @@ public: API_EXPORT std::string GetMetaStorePath(uint32_t version = INVALID_VERSION); API_EXPORT std::string GetMetaBackupPath(uint32_t version = INVALID_VERSION); API_EXPORT std::vector GetVersions(); - API_EXPORT void Initialize(const std::vector &strategies); + API_EXPORT void Initialize(const std::vector &strategies, const std::vector &storeTypes); API_EXPORT bool CreateDirectory(const std::string &path) const; API_EXPORT bool DeleteDirectory(const char* path); @@ -69,6 +73,7 @@ private: std::string GenPath(const StoreMetaData &metaData, uint32_t version, const std::string &exPath = "") const; const std::map actions_; std::vector strategies_; + std::vector storeTypes_; }; } // namespace OHOS::DistributedData #endif // DISTRIBUTEDDATAMGR_DIRECTORY_MANAGER_H diff --git a/services/distributeddataservice/framework/include/metadata/store_meta_data.h b/services/distributeddataservice/framework/include/metadata/store_meta_data.h index daa3f89c5..7aa999697 100644 --- a/services/distributeddataservice/framework/include/metadata/store_meta_data.h +++ b/services/distributeddataservice/framework/include/metadata/store_meta_data.h @@ -69,8 +69,8 @@ struct API_EXPORT StoreMetaData : public Serializable { STORE_RELATIONAL_END = 19, STORE_OBJECT_BEGIN = 20, STORE_OBJECT_END = 29, - STORE_UDMF_BEGIN = 30, - STORE_UDMF_END = 39, + STORE_GDB_BEGIN = 30, + STORE_GDB_END = 39, STORE_BUTT = 255 }; diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index f75ebfcd3..79bc96ffb 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -84,7 +84,6 @@ ohos_shared_library("distributeddatasvc") { "${data_service_path}/service/bootstrap:distributeddata_bootstrap", "${data_service_path}/service/common:distributeddata_common", "${data_service_path}/service/config:distributeddata_config", - "${data_service_path}/service/crypto:distributeddata_crypto", "${data_service_path}/service/dumper:distributeddata_dumper", "${data_service_path}/service/matrix:distributeddata_matrix", "${data_service_path}/service/permission:distributeddata_permit", diff --git a/services/distributeddataservice/service/backup/BUILD.gn b/services/distributeddataservice/service/backup/BUILD.gn index a218e46fb..9b7398de3 100755 --- a/services/distributeddataservice/service/backup/BUILD.gn +++ b/services/distributeddataservice/service/backup/BUILD.gn @@ -50,7 +50,6 @@ ohos_source_set("distributeddata_backup") { deps = [ "${data_service_path}/framework:distributeddatasvcfwk", - "${data_service_path}/service/crypto:distributeddata_crypto", ] external_deps = [ diff --git a/services/distributeddataservice/service/backup/src/backup_manager.cpp b/services/distributeddataservice/service/backup/src/backup_manager.cpp index 57d7a2e0e..8c96a953e 100644 --- a/services/distributeddataservice/service/backup/src/backup_manager.cpp +++ b/services/distributeddataservice/service/backup/src/backup_manager.cpp @@ -21,7 +21,7 @@ #include #include "backuprule/backup_rule_manager.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "directory/directory_manager.h" #include "log_print.h" diff --git a/services/distributeddataservice/service/bootstrap/BUILD.gn b/services/distributeddataservice/service/bootstrap/BUILD.gn index e384535fd..9226e02b2 100644 --- a/services/distributeddataservice/service/bootstrap/BUILD.gn +++ b/services/distributeddataservice/service/bootstrap/BUILD.gn @@ -49,7 +49,6 @@ ohos_source_set("distributeddata_bootstrap") { "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service/backup:distributeddata_backup", "${data_service_path}/service/config:distributeddata_config", - "${data_service_path}/service/crypto:distributeddata_crypto", ] external_deps = [ diff --git a/services/distributeddataservice/service/bootstrap/src/bootstrap.cpp b/services/distributeddataservice/service/bootstrap/src/bootstrap.cpp index 791b392a9..106363c18 100644 --- a/services/distributeddataservice/service/bootstrap/src/bootstrap.cpp +++ b/services/distributeddataservice/service/bootstrap/src/bootstrap.cpp @@ -156,7 +156,12 @@ void Bootstrap::LoadDirectory() for (size_t i = 0; i < config->strategy.size(); ++i) { strategies[i] = config->strategy[i]; } - DirectoryManager::GetInstance().Initialize(strategies); + auto typeSize = config->storeTypes.size(); + std::vector storeTypes(typeSize); + for (size_t i = 0; i < typeSize; ++i) { + storeTypes[i] = config->storeTypes[i]; + } + DirectoryManager::GetInstance().Initialize(strategies, storeTypes); } void Bootstrap::LoadCloud() diff --git a/services/distributeddataservice/service/config/include/model/directory_config.h b/services/distributeddataservice/service/config/include/model/directory_config.h index 034224999..8d7f170d2 100644 --- a/services/distributeddataservice/service/config/include/model/directory_config.h +++ b/services/distributeddataservice/service/config/include/model/directory_config.h @@ -25,7 +25,12 @@ public: bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; }; + struct StoreType final : public Serializable, public DirectoryManager::StoreType { + bool Marshal(json &node) const override; + bool Unmarshal(const json &node) override; + }; std::vector strategy; + std::vector storeTypes; bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; }; diff --git a/services/distributeddataservice/service/config/src/model/directory_config.cpp b/services/distributeddataservice/service/config/src/model/directory_config.cpp index 9f01b1e70..58d4f4930 100644 --- a/services/distributeddataservice/service/config/src/model/directory_config.cpp +++ b/services/distributeddataservice/service/config/src/model/directory_config.cpp @@ -36,15 +36,32 @@ bool DirectoryConfig::DirectoryStrategy::Unmarshal(const json &node) return true; } +bool DirectoryConfig::StoreType::Marshal(json &node) const +{ + SetValue(node[GET_NAME(range)], range); + SetValue(node[GET_NAME(type)], type); + return true; +} + +bool DirectoryConfig::StoreType::Unmarshal(const json &node) +{ + GetValue(node, GET_NAME(range), range); + GetValue(node, GET_NAME(type), type); + return true; +} + bool DirectoryConfig::Marshal(json &node) const { SetValue(node[GET_NAME(strategy)], strategy); + SetValue(node[GET_NAME(storeTypes)], storeTypes); return true; } bool DirectoryConfig::Unmarshal(const json &node) { - return GetValue(node, GET_NAME(strategy), strategy); + GetValue(node, GET_NAME(strategy), strategy); + GetValue(node, GET_NAME(storeTypes), storeTypes); + return true; } } // namespace DistributedData } // namespace OHOS diff --git a/services/distributeddataservice/service/crypto/BUILD.gn b/services/distributeddataservice/service/crypto/BUILD.gn deleted file mode 100644 index bbd37ad4b..000000000 --- a/services/distributeddataservice/service/crypto/BUILD.gn +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import("//build/ohos.gni") -import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") - -config("crypto_public_config") { - visibility = [ ":*" ] - include_dirs = [ "include" ] -} - -ohos_source_set("distributeddata_crypto") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - boundary_sanitize = true - ubsan = true - } - sources = [ "src/crypto_manager.cpp" ] - - cflags_cc = [ - "-fvisibility=hidden", - "-Oz", - ] - - include_dirs = [ "include" ] - - cflags = [ - "-Werror", - "-Wno-multichar", - "-Wno-c99-designator", - "-D_LIBCPP_HAS_COND_CLOCKWAIT", - "-Oz", - ] - configs = [ ":crypto_public_config" ] - public_configs = [ ":crypto_public_config" ] - deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ] - external_deps = [ - "dmsfwk:distributed_sdk", - "hilog:libhilog", - "huks:libhukssdk", - "kv_store:datamgr_common", - ] - subsystem_name = "distributeddatamgr" - part_name = "datamgr_service" -} \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp b/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp index ee27afe0c..1a18ae040 100644 --- a/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp +++ b/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp @@ -15,7 +15,7 @@ #define LOG_TAG "RdbAdaptor" #include "rdb_delegate.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "datashare_errno.h" #include "datashare_radar_reporter.h" #include "device_manager_adapter.h" diff --git a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp index 4c8a98473..9fd1fe9d0 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp @@ -22,7 +22,7 @@ #include "checker/checker_manager.h" #include "cloud/cloud_sync_finished_event.h" #include "cloud/schema_meta.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "device_matrix.h" #include "dfx/dfx_types.h" diff --git a/services/distributeddataservice/service/kvdb/kvdb_service_impl.h b/services/distributeddataservice/service/kvdb/kvdb_service_impl.h index fd7f4e8c8..dd185700d 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_service_impl.h +++ b/services/distributeddataservice/service/kvdb/kvdb_service_impl.h @@ -19,7 +19,7 @@ #include #include "concurrent_map.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_matrix.h" #include "kv_store_delegate_manager.h" #include "kv_store_nb_delegate.h" diff --git a/services/distributeddataservice/service/permission/BUILD.gn b/services/distributeddataservice/service/permission/BUILD.gn index 3eba0a70f..3849f82ea 100644 --- a/services/distributeddataservice/service/permission/BUILD.gn +++ b/services/distributeddataservice/service/permission/BUILD.gn @@ -55,7 +55,6 @@ ohos_source_set("distributeddata_permit") { deps = [ "${data_service_path}/framework:distributeddatasvcfwk", - "${data_service_path}/service/crypto:distributeddata_crypto", ] external_deps = [ "access_token:libaccesstoken_sdk", diff --git a/services/distributeddataservice/service/rdb/BUILD.gn b/services/distributeddataservice/service/rdb/BUILD.gn index 9c126c795..4273bba45 100644 --- a/services/distributeddataservice/service/rdb/BUILD.gn +++ b/services/distributeddataservice/service/rdb/BUILD.gn @@ -68,7 +68,6 @@ ohos_source_set("distributeddata_rdb") { deps = [ "${data_service_path}/service/bootstrap:distributeddata_bootstrap", "${data_service_path}/service/common:distributeddata_common", - "${data_service_path}/service/crypto:distributeddata_crypto", "${data_service_path}/service/matrix:distributeddata_matrix", "${data_service_path}/service/permission:distributeddata_permit", ] diff --git a/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/services/distributeddataservice/service/rdb/rdb_general_store.cpp index 83ca04331..9455db59a 100644 --- a/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -29,7 +29,7 @@ #include "device_sync_app/device_sync_app_manager.h" #include "cloud_service.h" #include "commonevent/data_sync_event.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "dfx/dfx_types.h" #include "dfx/reporter.h" diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index 750765e9c..33c01c74e 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -24,7 +24,7 @@ #include "commonevent/data_change_event.h" #include "commonevent/set_searchable_event.h" #include "concurrent_map.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "feature/static_acts.h" #include "metadata/secret_key_meta_data.h" #include "metadata/store_meta_data.h" diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index 7c20c4aa2..e49bc9089 100644 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -1014,7 +1014,6 @@ ohos_unittest("DataShareServiceImplTest") { sources = [ "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/crypto/src/crypto_manager.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", "${data_service_path}/service/data_share/common/common_utils.cpp", @@ -1982,7 +1981,6 @@ ohos_unittest("UpgradeMockTest") { "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", - "${data_service_path}/service/crypto:distributeddata_crypto", "${data_service_path}/service/matrix:distributeddata_matrix", "${data_service_path}/service/rdb:distributeddata_rdb", "${data_service_path}/service/test/mock:distributeddata_mock_static", diff --git a/services/distributeddataservice/service/test/backup_manager_service_test.cpp b/services/distributeddataservice/service/test/backup_manager_service_test.cpp index cccff99d0..a47405b3f 100644 --- a/services/distributeddataservice/service/test/backup_manager_service_test.cpp +++ b/services/distributeddataservice/service/test/backup_manager_service_test.cpp @@ -20,7 +20,7 @@ #include "backup_manager.h" #include "backuprule/backup_rule_manager.h" #include "bootstrap.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "directory/directory_manager.h" #include "file_ex.h" diff --git a/services/distributeddataservice/service/test/crypto_manager_test.cpp b/services/distributeddataservice/service/test/crypto_manager_test.cpp index bda34eb8b..fe4e537f1 100644 --- a/services/distributeddataservice/service/test/crypto_manager_test.cpp +++ b/services/distributeddataservice/service/test/crypto_manager_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include diff --git a/services/distributeddataservice/service/test/directory_manager_test.cpp b/services/distributeddataservice/service/test/directory_manager_test.cpp index a71c6df46..85e3db8e1 100644 --- a/services/distributeddataservice/service/test/directory_manager_test.cpp +++ b/services/distributeddataservice/service/test/directory_manager_test.cpp @@ -208,10 +208,10 @@ HWTEST_F(DirectoryManagerTest, GetUdmfStorePath, TestSize.Level0) metaData.tokenId = GetAccessTokenId(&tokenParam_); metaData.area = DistributedKv::Area::EL2; metaData.uid = static_cast(getuid()); - metaData.storeType = StoreMetaData::StoreType::STORE_UDMF_BEGIN; + metaData.storeType = DistributedKv::KvStoreType::SINGLE_VERSION; metaData.dataType = DistributedKv::DataType::TYPE_DYNAMICAL; metaData.authType = DistributedKv::AuthType::IDENTICAL_ACCOUNT; - metaData.dataDir = "/data/service/el2/100/database/distributeddata/other"; + metaData.dataDir = "/data/service/el2/100/database/distributeddata/kvdb"; auto path = DirectoryManager::GetInstance().GetStorePath(metaData); EXPECT_EQ(path, metaData.dataDir); auto res = DistributedData::DirectoryManager::GetInstance().CreateDirectory(path); @@ -282,4 +282,35 @@ HWTEST_F(DirectoryManagerTest, DeleteDirectory, TestSize.Level0) bool ret1 = DirectoryManager::GetInstance().DeleteDirectory(deleteDir.c_str()); EXPECT_TRUE(ret1); EXPECT_EQ(access(deleteDir.c_str(), F_OK), -1); +} + +/** +* @tc.name: GetStoreTypePath +* @tc.desc: test get db dir +* @tc.type: FUNC +*/ +HWTEST_F(DirectoryManagerTest, GetStoreTypePath, TestSize.Level0) +{ + StoreMetaData metaData; + metaData.user = "100"; + metaData.bundleName = "ohos.test.demo"; + metaData.securityLevel = SecurityLevel::S2; + metaData.area = 1; + metaData.tokenId = AccessTokenKit::GetHapTokenID(100, "ohos.test.demo", 0); + metaData.appId = "ohos.test.demo_09AEF01D"; + + metaData.storeType = StoreMetaData::StoreType::STORE_KV_BEGIN; + metaData.dataDir = "/data/app/el1/100/database/ohos.test.demo/kvdb"; + auto path = DirectoryManager::GetInstance().GetStorePath(metaData); + EXPECT_EQ(path, metaData.dataDir); + + metaData.storeType = StoreMetaData::StoreType::STORE_RELATIONAL_BEGIN; + metaData.dataDir = "/data/app/el1/100/database/ohos.test.demo/rdb"; + path = DirectoryManager::GetInstance().GetStorePath(metaData); + EXPECT_EQ(path, metaData.dataDir); + + metaData.storeType = StoreMetaData::StoreType::STORE_BUTT; + metaData.dataDir = "/data/app/el1/100/database/ohos.test.demo/other"; + path = DirectoryManager::GetInstance().GetStorePath(metaData); + EXPECT_EQ(path, metaData.dataDir); } \ No newline at end of file diff --git a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn index 227596c5f..8f2dc9fbb 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn @@ -49,7 +49,6 @@ ohos_fuzztest("DataShareServiceStubFuzzTest") { sources = [ "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/crypto/src/crypto_manager.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", "${data_service_path}/service/data_share/common/common_utils.cpp", diff --git a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn index 9d8dc61bf..6e09939e7 100644 --- a/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/kvdbservicestub_fuzzer/BUILD.gn @@ -67,7 +67,6 @@ ohos_fuzztest("KvdbServiceStubFuzzTest") { "${data_service_path}/service/config/src/model/network_config.cpp", "${data_service_path}/service/config/src/model/protocol_config.cpp", "${data_service_path}/service/config/src/model/thread_config.cpp", - "${data_service_path}/service/crypto/src/crypto_manager.cpp", "${data_service_path}/service/kvdb/auth_delegate.cpp", "${data_service_path}/service/kvdb/kvdb_exporter.cpp", "${data_service_path}/service/kvdb/kvdb_general_store.cpp", diff --git a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn index 1fa88f886..39050c67f 100755 --- a/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/objectservicestub_fuzzer/BUILD.gn @@ -63,7 +63,6 @@ ohos_fuzztest("ObjectServiceStubFuzzTest") { "${data_service_path}/service/config/src/model/network_config.cpp", "${data_service_path}/service/config/src/model/protocol_config.cpp", "${data_service_path}/service/config/src/model/thread_config.cpp", - "${data_service_path}/service/crypto/src/crypto_manager.cpp", "${data_service_path}/service/object/src/object_asset_loader.cpp", "${data_service_path}/service/object/src/object_asset_machine.cpp", "${data_service_path}/service/object/src/object_callback_proxy.cpp", diff --git a/services/distributeddataservice/service/test/kvdb_general_store_abnormal_test.cpp b/services/distributeddataservice/service/test/kvdb_general_store_abnormal_test.cpp index a6d46bbb9..7be5d9029 100644 --- a/services/distributeddataservice/service/test/kvdb_general_store_abnormal_test.cpp +++ b/services/distributeddataservice/service/test/kvdb_general_store_abnormal_test.cpp @@ -25,7 +25,7 @@ #include "cloud/asset_loader.h" #include "cloud/cloud_db.h" #include "cloud/schema_meta.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter_mock.h" #include "kv_store_nb_delegate_mock.h" #include "kvdb_query.h" diff --git a/services/distributeddataservice/service/test/kvdb_general_store_test.cpp b/services/distributeddataservice/service/test/kvdb_general_store_test.cpp index 4938a7384..efcb43852 100644 --- a/services/distributeddataservice/service/test/kvdb_general_store_test.cpp +++ b/services/distributeddataservice/service/test/kvdb_general_store_test.cpp @@ -24,7 +24,7 @@ #include "cloud/asset_loader.h" #include "cloud/cloud_db.h" #include "cloud/schema_meta.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "kv_store_nb_delegate_mock.h" #include "kvdb_query.h" diff --git a/services/distributeddataservice/service/test/kvdb_service_test.cpp b/services/distributeddataservice/service/test/kvdb_service_test.cpp index 80990d179..22689b6d9 100644 --- a/services/distributeddataservice/service/test/kvdb_service_test.cpp +++ b/services/distributeddataservice/service/test/kvdb_service_test.cpp @@ -18,7 +18,7 @@ #include "auth_delegate.h" #include "bootstrap.h" #include "change_notification.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "directory/directory_manager.h" #include "ikvstore_observer.h" diff --git a/services/distributeddataservice/service/test/rdb_service_impl_test.cpp b/services/distributeddataservice/service/test/rdb_service_impl_test.cpp index 73a3ec564..5a59ce33d 100644 --- a/services/distributeddataservice/service/test/rdb_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/rdb_service_impl_test.cpp @@ -20,7 +20,7 @@ #include "checker_mock.h" #include "cloud/change_event.h" #include "cloud/schema_meta.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "device_matrix.h" #include "event_center.h" diff --git a/services/distributeddataservice/service/test/rdb_service_impl_token_test.cpp b/services/distributeddataservice/service/test/rdb_service_impl_token_test.cpp index 14f826364..62989305e 100644 --- a/services/distributeddataservice/service/test/rdb_service_impl_token_test.cpp +++ b/services/distributeddataservice/service/test/rdb_service_impl_token_test.cpp @@ -19,7 +19,7 @@ #include "mock/access_token_mock.h" #include "bootstrap.h" #include "checker_mock.h" -#include "crypto_manager.h" +#include "crypto/crypto_manager.h" #include "device_manager_adapter.h" #include "device_matrix.h" #include "metadata/meta_data_manager.h" diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.cpp b/services/distributeddataservice/service/udmf/store/runtime_store.cpp index 9117d4027..d13e1adec 100644 --- a/services/distributeddataservice/service/udmf/store/runtime_store.cpp +++ b/services/distributeddataservice/service/udmf/store/runtime_store.cpp @@ -159,7 +159,7 @@ Status RuntimeStore::PutSummary(UnifiedKey &key, const Summary &summary) return status; } auto summaryKey = propertyKey + SUMMARY_SUFIX; - std::vector entries{{{summaryKey.begin(), summaryKey.end()}, value}};; + std::vector entries{{{summaryKey.begin(), summaryKey.end()}, value}}; return PutEntries(std::move(entries)); } @@ -479,7 +479,7 @@ bool RuntimeStore::BuildMetaDataParam(DistributedData::StoreMetaData &metaData) metaData.securityLevel = DistributedKv::SecurityLevel::S1; metaData.area = DistributedKv::Area::EL2; metaData.uid = static_cast(getuid()); - metaData.storeType = StoreMetaData::StoreType::STORE_UDMF_BEGIN; + metaData.storeType = DistributedKv::KvStoreType::SINGLE_VERSION; metaData.dataType = DistributedKv::DataType::TYPE_DYNAMICAL; metaData.authType = DistributedKv::AuthType::IDENTICAL_ACCOUNT; diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 1ceb45cc8..a3ea7ce7e 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -612,7 +612,8 @@ int32_t UdmfServiceImpl::StoreSync(const UnifiedKey &key, const QueryOption &que BizScene::SYNC_DATA, SyncDataStage::SYNC_END, StageRes::FAILED, E_DB_ERROR, BizState::DFX_END); } })) { - ZLOGW("bundleName:%{public}s, meta sync failed", key.bundleName.c_str()); + ZLOGE("bundleName:%{public}s, meta sync failed", key.bundleName.c_str()); + return E_DB_ERROR; } if (store->Sync(devices, callback) != E_OK) { ZLOGE("Store sync failed"); @@ -866,8 +867,8 @@ int32_t UdmfServiceImpl::ResolveAutoLaunch(const std::string &identifier, DBLaun } for (const auto &storeMeta : metaData) { - if (storeMeta.storeType < StoreMetaData::StoreType::STORE_UDMF_BEGIN || - storeMeta.storeType > StoreMetaData::StoreType::STORE_UDMF_END || + if (storeMeta.storeType < StoreMetaData::StoreType::STORE_KV_BEGIN || + storeMeta.storeType > StoreMetaData::StoreType::STORE_KV_END || storeMeta.appId != Bootstrap::GetInstance().GetProcessLabel()) { continue; } -- Gitee From a9bdc8fe8384bb3e30f25969a21326ed652e1ba9 Mon Sep 17 00:00:00 2001 From: yanhui Date: Thu, 26 Jun 2025 17:50:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fwk=E4=B8=8D=E4=BE=9D=E8=B5=96adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhui Change-Id: Ia4a59c22e03fbfaaedcef245f80cf40e080ee6e2 --- .../adapter/communicator/test/BUILD.gn | 4 +++ .../include/communicator/commu_types.h | 11 ++----- .../distributeddataservice/framework/BUILD.gn | 1 - .../device_manager/device_manager_delegate.h | 3 +- .../device_manager/device_manager_types.h | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 services/distributeddataservice/framework/include/device_manager/device_manager_types.h diff --git a/services/distributeddataservice/adapter/communicator/test/BUILD.gn b/services/distributeddataservice/adapter/communicator/test/BUILD.gn index c014f94b9..a41f0430c 100755 --- a/services/distributeddataservice/adapter/communicator/test/BUILD.gn +++ b/services/distributeddataservice/adapter/communicator/test/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("CommunicationProviderTest") { deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -68,6 +69,7 @@ ohos_unittest("CommunicatorContextTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -257,6 +259,7 @@ ohos_unittest("SoftbusClientTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -287,6 +290,7 @@ ohos_unittest("AppPipeMgrServiceTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } diff --git a/services/distributeddataservice/adapter/include/communicator/commu_types.h b/services/distributeddataservice/adapter/include/communicator/commu_types.h index 6b1f1af69..8b1944015 100644 --- a/services/distributeddataservice/adapter/include/communicator/commu_types.h +++ b/services/distributeddataservice/adapter/include/communicator/commu_types.h @@ -16,19 +16,12 @@ #ifndef OHOS_DISTRIBUTED_DATA_ADAPTER_COMMUNICATOR_COMMU_TYPES_H #define OHOS_DISTRIBUTED_DATA_ADAPTER_COMMUNICATOR_COMMU_TYPES_H #include +#include "device_manager/device_manager_types.h" #include "store_errno.h" #include "visibility.h" namespace OHOS::AppDistributedKv { using Status = DistributedKv::Status; -struct API_EXPORT DeviceInfo { - std::string uuid; - std::string udid; - std::string networkId; - std::string deviceName; - uint32_t deviceType; - int32_t osType; - int32_t authForm; -}; +using DeviceInfo = DistributedData::DeviceInfo; struct API_EXPORT AccessCaller { std::string accountId; diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index b3b8044f5..3857df595 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -30,7 +30,6 @@ config("module_public_config") { visibility = [ ":*" ] include_dirs = [ "include", - "${data_service_path}/adapter/include/communicator", ] } diff --git a/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h b/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h index fa5ba9b63..0e7d57829 100644 --- a/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h +++ b/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h @@ -16,14 +16,13 @@ #ifndef DISTRIBUTEDDATAMGR_DEVICE_MANAGER_DELEGATE_H #define DISTRIBUTEDDATAMGR_DEVICE_MANAGER_DELEGATE_H -#include "commu_types.h" +#include "device_manager_types.h" #include "visibility.h" namespace OHOS { namespace DistributedData { class DeviceManagerDelegate { public: - using DeviceInfo = OHOS::AppDistributedKv::DeviceInfo; virtual ~DeviceManagerDelegate() = default; virtual DeviceInfo GetLocalDevice() = 0; API_EXPORT static bool RegisterInstance(DeviceManagerDelegate *instance); diff --git a/services/distributeddataservice/framework/include/device_manager/device_manager_types.h b/services/distributeddataservice/framework/include/device_manager/device_manager_types.h new file mode 100644 index 000000000..315e76c17 --- /dev/null +++ b/services/distributeddataservice/framework/include/device_manager/device_manager_types.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 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_DEVICE_MANAGER_TYPES_H +#define OHOS_DISTRIBUTED_DATA_FRAMEWORK_DEVICE_MANAGER_TYPES_H +#include +#include "visibility.h" +namespace OHOS::DistributedData { +struct API_EXPORT DeviceInfo { + std::string uuid; + std::string udid; + std::string networkId; + std::string deviceName; + uint32_t deviceType; + int32_t osType; + int32_t authForm; +}; +} +#endif // OHOS_DISTRIBUTED_DATA_FRAMEWORK_DEVICE_MANAGER_TYPES_H -- Gitee