diff --git a/bundle.json b/bundle.json index eb78c8cf7f0148b29ebc5fda126f7ca0c8360fc8..3a22c1c1438d9735f477f87a0a408270b3f1ce8f 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 b1d053eb86d9616784faa85c6ffef2ad8e5e38ee..69b0995a96bc73e33b971878ea0070267e213d83 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 d6a78e9c8e41c255f6eb83c4ead622aac80d4e64..e5cf64a8c6c0a5dd36fb5562cdbfd306819ecd02 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 744b1f3768bf54676554dfe68f28feefd69704fd..a41f0430c2b4d8e6e55bcc799c77fd81daff5882 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" ] } @@ -121,6 +123,7 @@ ohos_unittest("DeviceManagerAdapterTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -256,6 +259,7 @@ ohos_unittest("SoftbusClientTest") { ] deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/framework:distributeddatasvcfwk", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -286,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/communicator/test/unittest/device_manager_adapter_test.cpp b/services/distributeddataservice/adapter/communicator/test/unittest/device_manager_adapter_test.cpp index a813fb8a0e8c2cf1c2973583e2ab7f7f913d4fe2..f08d3153b29341fecb6934cd3cd029a1e53cc6bb 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/commu_types.h b/services/distributeddataservice/adapter/include/communicator/commu_types.h index 6b1f1af696dcb9482181dea2df903ce5f51913a8..8b194401524bb8eb907c84055a4e8281c622ba51 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/adapter/include/communicator/device_manager_adapter.h b/services/distributeddataservice/adapter/include/communicator/device_manager_adapter.h index 53135966b3566c5e059880aa4ceb1c7ca0283e84..575a2f3931a8b3435f3492cec42cc0823803810d 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 3c80f07412250657d6fed0790cd4d0f13aceef56..aff30c73f51f77c0563a8378c951c84621bf2396 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 1b785ff30260edb28740d286e1155e62bba1c166..1472fdd593d2239797847c6403e2162908e11bf3 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 5dbb1d584a4e8ca2fe1983c8e58832607b231d25..beee71e609817e9dac41879ea71d402fffd9e861 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 7ef3c07d60c2b516346430cdf66445aec7b10a40..3857df59528d2f357a3ac442ab6434e6de952093 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -69,6 +69,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 +136,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 4db5b90d5a9cf4918c75b7611c7574d3259bd1a5..0a15a83565fc8d6b2764413808a6c121dc6659ef 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 0000000000000000000000000000000000000000..e85b94b97de9961e7431731f25a6ae2ab634cc25 --- /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 8ac7b2f03e26c19c7dce07eef656612f0d718494..805ed1b95868d162530737c9af2f17269cf5c015 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 0000000000000000000000000000000000000000..0e7d5782993a1c720d6a30239d1f7ddd58d58338 --- /dev/null +++ b/services/distributeddataservice/framework/include/device_manager/device_manager_delegate.h @@ -0,0 +1,35 @@ +/* + * 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 "device_manager_types.h" +#include "visibility.h" + +namespace OHOS { +namespace DistributedData { +class DeviceManagerDelegate { +public: + 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/device_manager/device_manager_types.h b/services/distributeddataservice/framework/include/device_manager/device_manager_types.h new file mode 100644 index 0000000000000000000000000000000000000000..315e76c172891ea9d2ef0ad371eeb5776fd38816 --- /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 diff --git a/services/distributeddataservice/framework/include/directory/directory_manager.h b/services/distributeddataservice/framework/include/directory/directory_manager.h index 0570bcd62c1c4d14cbe7ea3fda36474ca3ed3b48..5ec7eb4410f06110aab79e0b13b6326a76f10816 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 daa3f89c5618f9e4ab380d5b382e150b0007996e..7aa999697581d3427e45bd4fe9636526a14d2613 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 f75ebfcd39b40948512fd808c4bdcfe29780cb92..79bc96ffbde5c46340e2ee1ec766a04ad3de3695 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 a218e46fbce9cf3acadb872b6a8fa9c7ffde937e..9b7398de3646f42daeae823a75eefdeeebd69607 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 57d7a2e0e75e94207816292fd025713824df301a..8c96a953ed566640e57e1d6f5ae5f0d8a021a334 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 e384535fdd66a93984fb6cf95b1c152df2aed883..9226e02b263b6dd9eb044f5c13967e0f8b1b15c7 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 791b392a99c71c1d47848c84d6b7c44109013f0f..106363c184ef1411ddb50a9513a811abe7538f7c 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 034224999aea26e3220458857f877e2aa544cb5f..8d7f170d2bc6d1fc764aff75c0e2b7eb888837bd 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 9f01b1e70bdb22a951990ee9f792a0f945761a4c..58d4f493061c3d8aead0b6011dd510b2e97bc8fb 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 bbd37ad4b6e705dd4300d25cbc4a12154b57e300..0000000000000000000000000000000000000000 --- 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 ee27afe0c34a84bf1dd33caf9aa0932b23761771..1a18ae040e24374a7ea467a82404cca62a9b8047 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 4c8a984732191fc98cfa9bcb7b3f44f1ac428841..9fd1fe9d0f0d4785b940859fa673f5ed6341fd50 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 fd7f4e8c82c55298a046e6fe8c654333f4cdcd10..dd185700db36228cfe8a58253e5a1babcd88b06d 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 3eba0a70fafc41495771bd42db04df8beff38cc2..3849f82eabc8e7e0b7222593469d4877d24b6513 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 9c126c795e02cd1ab24ec380b516a6804708d2cf..4273bba4511c5bcb29e1359ba1d6c687e56f3c21 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 83ca0433155a903adc6174b34010d4d298bd85a8..9455db59a84c8301295cc4a669a135481a548c24 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 750765e9c055dba96b49c719b45d70d20e01cc50..33c01c74e16cbde63d8388fa59ddd5d2ffe8e554 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 7c20c4aa2ad038db6804228edef4467b3de9a991..e49bc9089863d21b58e418be6f4ba21059ec7652 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 cccff99d09d64ba74558c48ac84f65dcf457172f..a47405b3f959c9217b46a009c166badb3638a86a 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 bda34eb8bbd7b6fd00077954cea3903753ff69ca..fe4e537f1d7d69afe5b61a9c92dfdca343f050d5 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 a71c6df46860fb6faa4083ac8c466700b22e7094..85e3db8e1efda0db6e3cf20f176fb8f9f61a6944 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 227596c5f7a5fd9fec5348bdaa1342f5954dd92c..8f2dc9fbb4b701f19ee5edffcc26f5b392953b44 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 9d8dc61bfa86f3220dff7b431c5c1d866269200c..6e09939e73e7604e5e485e5dd8ae57965cb2430a 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 1fa88f886e60a2cacc991f413cc3a2c9d02453c7..39050c67f298113a9c98b37fc65e91a89923fdab 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 a6d46bbb9727ae8fa7f139d0c195cf2636c3b6c1..7be5d9029e7f4edd5adaec52996439e3ceeb499d 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 4938a7384db0ead931d6ce18657a1cb4cb93f588..efcb438523629b85817dbf3dfa4bfc4946b6ca2e 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 80990d1797c0940418e490864cd6a8c4f2cf0b36..22689b6d91a80ebf07a49f1255c4fcbe4dd62333 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 73a3ec5646f5b701ec674e01548c5ab835fd548d..5a59ce33d624604ef72509e2d96f1e7ff50bb0e5 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 14f8263647ce09ed05bf04573e323c05d037127a..62989305ebc7367c1a2545179bf449e061a7e76d 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 9117d4027586385ebd57ebe68691dbfc479fd38a..d13e1adec59091eef37cf2d6d2b077895a07dc57 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 1ceb45cc8c31ec8eb3c3b032727484ca8aa1cecb..a3ea7ce7ed82c0f2bd1b2bb1adb1994d7014eca3 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; }