From 8c5bb1ecbf0706fd7905c655f4488f1a56014243 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Wed, 30 Apr 2025 20:30:39 +0800 Subject: [PATCH 1/4] obtain distribute table name Signed-off-by: htt1997 --- .../adapter/bundle_mgr/BUILD.gn | 58 +++++++++ .../adapter/bundle_mgr/bundle_mgr_adapter.cpp | 110 ++++++++++++++++++ .../adapter/bundle_mgr/bundle_mgr_adapter.h | 58 +++++++++ .../adapter/communicator/BUILD.gn | 13 ++- .../communicator/src/app_pipe_handler.cpp | 4 - .../communicator/src/app_pipe_handler.h | 1 - .../adapter/communicator/src/app_pipe_mgr.cpp | 1 - .../src/softbus_adapter_standard.cpp | 6 +- .../adapter/dfx/BUILD.gn | 9 +- .../src/behaviour/behaviour_reporter_impl.h | 2 +- .../dfx/src/fault/cloud_sync_fault_impl.h | 8 +- .../dfx/src/fault/communication_fault_impl.h | 8 +- .../dfx/src/fault/database_fault_impl.h | 6 +- .../adapter/dfx/src/fault/fault_reporter.cpp | 2 +- .../dfx/src/fault/runtime_fault_impl.h | 6 +- .../dfx/src/fault/service_fault_impl.h | 6 +- .../adapter/dfx/src/hiview_adapter.cpp | 2 +- .../adapter/dfx/src/hiview_adapter.h | 2 +- .../adapter/dfx/src/radar_reporter.cpp | 2 +- .../api_performance_statistic_impl.h | 9 +- .../src/statistic/database_statistic_impl.h | 2 +- .../dfx/src/statistic/statistic_reporter.cpp | 2 +- .../src/statistic/traffic_statistic_impl.h | 6 +- .../dfx/src/statistic/visit_statistic_impl.h | 6 +- .../adapter/include/dfx/reporter_impl.h | 10 +- .../adapter/network/BUILD.gn | 17 +-- .../src/network_delegate_default_impl.h | 2 +- .../src/network_delegate_normal_impl.h | 2 +- .../adapter/schema_helper/BUILD.gn | 11 +- .../{src => }/get_schema_helper.cpp | 0 .../schema_helper/get_schema_helper.h | 1 + .../adapter/screenlock/BUILD.gn | 14 ++- .../screenlock/{src => }/screen_lock.cpp | 2 +- .../{include => }/screenlock/screen_lock.h | 0 .../adapter/screenlock/test/BUILD.gn | 4 +- .../framework/dfx/reporter.cpp | 2 +- .../framework/store/auto_cache.cpp | 2 +- .../distributeddataservice/service/BUILD.gn | 1 + .../service/rdb/BUILD.gn | 1 + .../service/rdb/rdb_general_store.cpp | 7 +- .../service/rdb/rdb_service_impl.cpp | 13 ++- 41 files changed, 324 insertions(+), 94 deletions(-) create mode 100644 services/distributeddataservice/adapter/bundle_mgr/BUILD.gn create mode 100644 services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp create mode 100644 services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h rename services/distributeddataservice/adapter/schema_helper/{src => }/get_schema_helper.cpp (100%) rename services/distributeddataservice/adapter/{include => }/schema_helper/get_schema_helper.h (99%) rename services/distributeddataservice/adapter/screenlock/{src => }/screen_lock.cpp (99%) rename services/distributeddataservice/adapter/{include => }/screenlock/screen_lock.h (100%) diff --git a/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn b/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn new file mode 100644 index 000000000..3ea018ef3 --- /dev/null +++ b/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn @@ -0,0 +1,58 @@ +# 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. +import("//build/ohos.gni") +import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") + +config("module_public_config") { + visibility = [ ":*" ] + include_dirs = [ "${data_service_path}/adapter" ] +} + +ohos_source_set("distributeddata_bundle_mgr") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + boundary_sanitize = true + ubsan = true + } + sources = [] + cflags_cc = [ + "-fvisibility=hidden", + "-Oz", + "-fstack-protector-strong", + ] + + public_configs = [ ":module_public_config" ] + cflags = [ + "-fdata-sections", + "-ffunction-sections", + "-Werror", + "-Wno-multichar", + "-Wno-c99-designator", + "-D_LIBCPP_HAS_COND_CLOCKWAIT", + "-Oz", + "-fstack-protector-strong", + ] + + external_deps = [ "kv_store:datamgr_common" ] + sources += [ "bundle_mgr_adapter.cpp" ] + external_deps += [ + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "hilog:libhilog", + ] + subsystem_name = "distributeddatamgr" + part_name = "datamgr_service" +} diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp new file mode 100644 index 000000000..f6dfee2cf --- /dev/null +++ b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp @@ -0,0 +1,110 @@ +/* + * 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. + */ + +#define LOG_TAG "bundle_mgr_adapter" +#include "bundle_mgr/bundle_mgr_adapter.h" +#include "bundle_mgr_client.h" +#include "log_print.h" +using namespace OHOS::AppExecFwk; +namespace OHOS::DistributedData { +BundleFlag Convert(int32_t type) +{ + switch (type) { + case BundleMgrAdapter::BUNDLE_DEFAULT: + return GET_BUNDLE_DEFAULT; + case BundleMgrAdapter::BUNDLE_WITH_ABILITIES: + return GET_BUNDLE_WITH_ABILITIES; + case BundleMgrAdapter::BUNDLE_WITH_REQUESTED_PERMISSION: + return GET_BUNDLE_WITH_REQUESTED_PERMISSION; + case BundleMgrAdapter::BUNDLE_WITH_EXTENSION_INFO: + return GET_BUNDLE_WITH_EXTENSION_INFO; + case BundleMgrAdapter::BUNDLE_WITH_HASH_VALUE: + return GET_BUNDLE_WITH_HASH_VALUE; + case BundleMgrAdapter::BUNDLE_WITH_MENU: + return GET_BUNDLE_WITH_MENU; + case BundleMgrAdapter::BUNDLE_WITH_ROUTER_MAP: + return GET_BUNDLE_WITH_ROUTER_MAP; + case BundleMgrAdapter::BUNDLE_WITH_SKILL: + return GET_BUNDLE_WITH_SKILL; + } + ZLOGW("invalid type:%{public}d", type); + return GET_BUNDLE_DEFAULT; +} + +BundleMgrAdapter::HapModuleInfo Convert(AppExecFwk::HapModuleInfo &&info) +{ + BundleMgrAdapter::HapModuleInfo res; + res.hapPath = std::move(info.hapPath); + return res; +} + +BundleMgrAdapter::BundleInfo Convert(AppExecFwk::BundleInfo &&info) +{ + BundleMgrAdapter::BundleInfo res; + res.moduleDirs = info.moduleDirs; + res.hapModuleInfos.reserve(info.hapModuleInfos.size()); + for (auto &moduleInfo : info.hapModuleInfos) { + res.hapModuleInfos.push_back(Convert(std::move(moduleInfo))); + } + return res; +} + +BundleMgrAdapter &BundleMgrAdapter::GetInstance() +{ + static BundleMgrAdapter instance; + return instance; +} + +std::pair BundleMgrAdapter::GetBundleInfo(const std::string &bundleName, + BundleType type, int32_t user) +{ + AppExecFwk::BundleInfo info; + BundleMgrClient client; + bool res = client.GetBundleInfo(bundleName, Convert(type), info, user == 0 ? Constants::UNSPECIFIED_USERID : user); + if (!res) { + return { res, {} }; + } + BundleInfo bundleInfo = Convert(std::move(info)); + return { res, bundleInfo }; +} + +std::string BundleMgrAdapter::GetBundleName(int32_t uid) +{ + BundleMgrClient client; + std::string bundleName; + auto code = client.GetNameForUid(uid, bundleName); + if (code != 0) { + ZLOGE("failed. uid:%{public}d, code:%{public}d", uid, code); + return ""; + } + return bundleName; +} + +std::string BundleMgrAdapter::GetAppId(int32_t user, const std::string &bundleName) +{ + if (bundleName.empty()) { + ZLOGE("invalid args. user:%{public}d, bundleName:%{public}s", user, bundleName.c_str()); + return ""; + } + AppExecFwk::BundleInfo info; + BundleMgrClient client; + auto code = client.GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, info, + user == 0 ? Constants::UNSPECIFIED_USERID : user); + if (code != 0) { + ZLOGE("failed. user:%{public}d, bundleName:%{public}s", user, bundleName.c_str()); + } + return info.appId; +} +} // namespace OHOS::DistributedData \ No newline at end of file diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h new file mode 100644 index 000000000..fa0d4b955 --- /dev/null +++ b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h @@ -0,0 +1,58 @@ +/* + * 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_DATAMGR_BUNDLE_MANAGER_ADAPTER_H +#define DISTRIBUTEDDATAMGR_DATAMGR_BUNDLE_MANAGER_ADAPTER_H + +#include +#include +#include "visibility.h" + +namespace OHOS { +namespace DistributedData { +class API_EXPORT BundleMgrAdapter { +public: + struct HapModuleInfo { + std::string hapPath; + }; + struct BundleInfo { + std::vector hapModuleInfos; + std::vector moduleDirs; + }; + enum BundleType { + // get bundle info except abilityInfos + BUNDLE_DEFAULT = 0x00000000, + // get bundle info include abilityInfos + BUNDLE_WITH_ABILITIES = 0x00000001, + // get bundle info include request permissions + BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, + // get bundle info include extension info + BUNDLE_WITH_EXTENSION_INFO = 0x00000020, + // get bundle info include hash value + BUNDLE_WITH_HASH_VALUE = 0x00000030, + // get bundle info include menu, only for dump usage + BUNDLE_WITH_MENU = 0x00000040, + // get bundle info include router map, only for dump usage + BUNDLE_WITH_ROUTER_MAP = 0x00000080, + // get bundle info include skill info + BUNDLE_WITH_SKILL = 0x00000800, + }; + static BundleMgrAdapter &GetInstance(); + std::pair GetBundleInfo(const std::string &bundleName, BundleType type, int32_t user = 0); + std::string GetBundleName(int32_t uid); + std::string GetAppId(int32_t user, const std::string &bundleName); +}; +} // namespace DistributedData +} // namespace OHOS +#endif //DISTRIBUTEDDATAMGR_DATAMGR_BUNDLE_MANAGER_ADAPTER_H diff --git a/services/distributeddataservice/adapter/communicator/BUILD.gn b/services/distributeddataservice/adapter/communicator/BUILD.gn index ff2d7cf86..9cb388498 100755 --- a/services/distributeddataservice/adapter/communicator/BUILD.gn +++ b/services/distributeddataservice/adapter/communicator/BUILD.gn @@ -12,6 +12,11 @@ # limitations under the License. import("//build/ohos.gni") import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") + +config("module_public_config") { + visibility = [ ":*" ] + include_dirs = [ "${data_service_path}/adapter/include/communicator" ] +} ohos_source_set("distributeddata_communicator") { branch_protector_ret = "pac_ret" sanitize = { @@ -42,19 +47,15 @@ ohos_source_set("distributeddata_communicator") { ] include_dirs = [ - "../include/communicator", - "../include/utils", - "${data_service_path}/adapter/include/communicator", - "${data_service_path}/framework/include/dfx", - "${data_service_path}/framework/include/utils", + "${data_service_path}/adapter/include/utils", ] cflags_cc = [ "-fvisibility=hidden" ] + public_configs = [ ":module_public_config" ] deps = [ "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", - "../dfx:distributeddata_dfx", ] external_deps = [ diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp index 022f303db..352f2edb6 100644 --- a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp +++ b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp @@ -15,11 +15,7 @@ #include "app_pipe_handler.h" #include -#include -#include -#include #include "log_print.h" -#include "reporter.h" #ifdef LOG_TAG #undef LOG_TAG diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.h b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.h index 9ea304485..d4c550e0a 100644 --- a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.h +++ b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.h @@ -21,7 +21,6 @@ #include #include #include "log_print.h" -#include "reporter.h" #include "app_data_change_listener.h" #include "softbus_adapter.h" diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp index e96fde31b..0e66104f8 100644 --- a/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp +++ b/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp @@ -15,7 +15,6 @@ #include "app_pipe_mgr.h" #include "kvstore_utils.h" -#include "reporter.h" #undef LOG_TAG #define LOG_TAG "AppPipeMgr" diff --git a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp index f4df6deec..5d8e2cb4d 100644 --- a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp +++ b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp @@ -16,14 +16,14 @@ #include #include -#include "communicator_context.h" #include "communication/connect_manager.h" +#include "communicator_context.h" #include "data_level.h" #include "device_manager_adapter.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" +#include "dfx/reporter.h" #include "kvstore_utils.h" #include "log_print.h" -#include "reporter.h" #include "securec.h" #include "session.h" #include "softbus_adapter.h" diff --git a/services/distributeddataservice/adapter/dfx/BUILD.gn b/services/distributeddataservice/adapter/dfx/BUILD.gn index dc2a52cb3..1b2cc6e71 100644 --- a/services/distributeddataservice/adapter/dfx/BUILD.gn +++ b/services/distributeddataservice/adapter/dfx/BUILD.gn @@ -43,15 +43,14 @@ ohos_source_set("distributeddata_dfx") { "./src/fault", "./src/statistic", "../include/dfx", - "../include/log", - "../include/utils", - "../include/communicator", - "${data_service_path}/framework/include/dfx", - "${data_service_path}/framework/include/utils", ] cflags_cc = [ "-fvisibility=hidden" ] + deps = [ + "${data_service_path}/framework:distributeddatasvcfwk", + "${data_service_path}/adapter/communicator:distributeddata_communicator", + ] external_deps = [ "c_utils:utils", "device_manager:devicemanagersdk", diff --git a/services/distributeddataservice/adapter/dfx/src/behaviour/behaviour_reporter_impl.h b/services/distributeddataservice/adapter/dfx/src/behaviour/behaviour_reporter_impl.h index 5fff69e41..b460d27e6 100644 --- a/services/distributeddataservice/adapter/dfx/src/behaviour/behaviour_reporter_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/behaviour/behaviour_reporter_impl.h @@ -16,7 +16,7 @@ #ifndef DISTRIBUTEDDATAMGR_BEHAVIOUR_REPORTER_IMPL_H #define DISTRIBUTEDDATAMGR_BEHAVIOUR_REPORTER_IMPL_H -#include "behaviour_reporter.h" +#include "dfx/behaviour_reporter.h" #include "hiview_adapter.h" namespace OHOS { diff --git a/services/distributeddataservice/adapter/dfx/src/fault/cloud_sync_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/cloud_sync_fault_impl.h index e4e45bc90..54e6b60b1 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/cloud_sync_fault_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/fault/cloud_sync_fault_impl.h @@ -16,9 +16,9 @@ #ifndef DISTRIBUTEDDATAMGR_DATAMGR_SERVICE_CLOUD_SYNC_FAULT_IMPL_H #define DISTRIBUTEDDATAMGR_DATAMGR_SERVICE_CLOUD_SYNC_FAULT_IMPL_H -#include "fault_reporter.h" +#include "dfx/dfx_types.h" +#include "dfx/fault_reporter.h" #include "hiview_adapter.h" -#include "dfx_types.h" namespace OHOS { namespace DistributedDataDfx { @@ -43,6 +43,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_DATAMGR_SERVICE_CLOUD_SYNC_FAULT_IMPL_H \ No newline at end of file diff --git a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h index b5ec17f58..19673336e 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h @@ -16,9 +16,9 @@ #ifndef DISTRIBUTEDDATAMGR_COMMUNICATION_FAULT_IMPL_H #define DISTRIBUTEDDATAMGR_COMMUNICATION_FAULT_IMPL_H -#include "fault_reporter.h" +#include "dfx/dfx_types.h" +#include "dfx/fault_reporter.h" #include "hiview_adapter.h" -#include "dfx_types.h" namespace OHOS { namespace DistributedDataDfx { @@ -39,6 +39,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_COMMUNICATION_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h index 66c5b39be..1185dce0e 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h @@ -16,7 +16,7 @@ #ifndef DISTRIBUTEDDATAMGR_DATABASE_FAULT_IMPL_H #define DISTRIBUTEDDATAMGR_DATABASE_FAULT_IMPL_H -#include "fault_reporter.h" +#include "dfx/fault_reporter.h" #include "hiview_adapter.h" namespace OHOS { @@ -38,7 +38,7 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_DATABASE_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp index 9e714ee7a..1a7a35fd0 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "fault_reporter.h" +#include "dfx/fault_reporter.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h index f4aea1b0e..ae7f1a3e8 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h @@ -15,8 +15,8 @@ #ifndef DISTRIBUTEDDATAMGR_RUNTIME_FAULT_IMPL_H #define DISTRIBUTEDDATAMGR_RUNTIME_FAULT_IMPL_H +#include "dfx/fault_reporter.h" #include "hiview_adapter.h" -#include "fault_reporter.h" namespace OHOS { namespace DistributedDataDfx { @@ -37,6 +37,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_RUNTIME_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h index fb5eed6a8..df665d0c2 100644 --- a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h @@ -16,8 +16,8 @@ #ifndef DISTRIBUTEDDATAMGR_SERVICE_FAULT_IMPL_H #define DISTRIBUTEDDATAMGR_SERVICE_FAULT_IMPL_H +#include "dfx/fault_reporter.h" #include "hiview_adapter.h" -#include "fault_reporter.h" namespace OHOS { namespace DistributedDataDfx { @@ -38,6 +38,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_SERVICE_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp index 4e1b40f87..c27789c77 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp @@ -21,7 +21,7 @@ #include #include "log_print.h" -#include "time_utils.h" +#include "utils/time_utils.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h index a4c5f6654..f54703866 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h @@ -20,7 +20,7 @@ #include #include "dfx_code_constant.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" #include "executor_pool.h" #include "hisysevent_c.h" #include "value_hash.h" diff --git a/services/distributeddataservice/adapter/dfx/src/radar_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/radar_reporter.cpp index cec370a56..87aafd4b3 100644 --- a/services/distributeddataservice/adapter/dfx/src/radar_reporter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/radar_reporter.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "radar_reporter.h" +#include "dfx/radar_reporter.h" #include "device_manager_adapter.h" #include "hisysevent.h" diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h index f253ee7b3..f5cdff361 100644 --- a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h @@ -16,9 +16,9 @@ #ifndef DISTRIBUTEDDATAMGR_API_PERFORMANCE_STATISTIC_IMPL_H #define DISTRIBUTEDDATAMGR_API_PERFORMANCE_STATISTIC_IMPL_H -#include "statistic_reporter.h" +#include "dfx/dfx_types.h" +#include "dfx/statistic_reporter.h" #include "hiview_adapter.h" -#include "dfx_types.h" namespace OHOS { namespace DistributedDataDfx { @@ -31,7 +31,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_API_PERFORMANCE_STATISTIC_IMPL_H - diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h index c3aa6774d..453cd3dd4 100644 --- a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h @@ -16,7 +16,7 @@ #ifndef DISTRIBUTEDDATAMGR_DATABASE_STATISTIC_IMPL_H #define DISTRIBUTEDDATAMGR_DATABASE_STATISTIC_IMPL_H -#include "statistic_reporter.h" +#include "dfx/statistic_reporter.h" #include "hiview_adapter.h" namespace OHOS { diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp index 017ea12ec..e611e4411 100644 --- a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "statistic_reporter.h" +#include "dfx/statistic_reporter.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h index c65e88888..85238d9db 100644 --- a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h @@ -16,7 +16,7 @@ #ifndef DISTRIBUTEDDATAMGR_TRAFFIC_STATISTIC_IMPL_H #define DISTRIBUTEDDATAMGR_TRAFFIC_STATISTIC_IMPL_H -#include "statistic_reporter.h" +#include "dfx/statistic_reporter.h" #include "hiview_adapter.h" namespace OHOS { @@ -30,6 +30,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_TRAFFIC_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h index fb5b933ec..9898ad546 100644 --- a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h +++ b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h @@ -16,7 +16,7 @@ #ifndef DISTRIBUTEDDATAMGR_VISIT_STATISTIC_IMPL_H #define DISTRIBUTEDDATAMGR_VISIT_STATISTIC_IMPL_H -#include "statistic_reporter.h" +#include "dfx/statistic_reporter.h" #include "hiview_adapter.h" namespace OHOS { @@ -30,6 +30,6 @@ public: private: std::shared_ptr executors_; }; -} // namespace DistributedDataDfx -} // namespace OHOS +} // namespace DistributedDataDfx +} // namespace OHOS #endif // DISTRIBUTEDDATAMGR_VISIT_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/include/dfx/reporter_impl.h b/services/distributeddataservice/adapter/include/dfx/reporter_impl.h index f8cc3c453..c5e9f1f22 100644 --- a/services/distributeddataservice/adapter/include/dfx/reporter_impl.h +++ b/services/distributeddataservice/adapter/include/dfx/reporter_impl.h @@ -19,12 +19,12 @@ #include #include -#include "behaviour_reporter.h" -#include "dfx_types.h" +#include "dfx/behaviour_reporter.h" +#include "dfx/dfx_types.h" #include "executor_pool.h" -#include "fault_reporter.h" -#include "reporter.h" -#include "statistic_reporter.h" +#include "dfx/fault_reporter.h" +#include "dfx/reporter.h" +#include "dfx/statistic_reporter.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/adapter/network/BUILD.gn b/services/distributeddataservice/adapter/network/BUILD.gn index fb25666a3..880033e06 100644 --- a/services/distributeddataservice/adapter/network/BUILD.gn +++ b/services/distributeddataservice/adapter/network/BUILD.gn @@ -13,15 +13,9 @@ import("//build/ohos.gni") import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") -config("network_public_config") { +config("module_public_config") { visibility = [ ":*" ] - include_dirs = [ - "${data_service_path}/adapter/network/src", - "${data_service_path}/framework/include/network", - ] - if (datamgr_service_cloud) { - include_dirs += [ "${data_service_path}/adapter/include/communicator" ] - } + include_dirs = [ "${data_service_path}/adapter" ] } ohos_source_set("distributeddata_network") { @@ -39,7 +33,7 @@ ohos_source_set("distributeddata_network") { "-Oz", ] - configs = [ ":network_public_config" ] + configs = [ ":module_public_config" ] cflags = [ "-fdata-sections", "-ffunction-sections", @@ -50,13 +44,12 @@ ohos_source_set("distributeddata_network") { "-Oz", ] + deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ] external_deps = [ "kv_store:datamgr_common" ] if (datamgr_service_cloud) { sources += [ "src/network_delegate_normal_impl.cpp" ] - deps = [ - "${data_service_path}/adapter/communicator:distributeddata_communicator", - ] + deps += [ "${data_service_path}/adapter/communicator:distributeddata_communicator" ] external_deps += [ "device_manager:devicemanagersdk", "hilog:libhilog", diff --git a/services/distributeddataservice/adapter/network/src/network_delegate_default_impl.h b/services/distributeddataservice/adapter/network/src/network_delegate_default_impl.h index b3ddd1a17..16f3e2581 100644 --- a/services/distributeddataservice/adapter/network/src/network_delegate_default_impl.h +++ b/services/distributeddataservice/adapter/network/src/network_delegate_default_impl.h @@ -16,7 +16,7 @@ #ifndef OHOS_DISTRIBUTED_DATA_NETWORK_DELEGATE_DEFAULT_IMPL_H #define OHOS_DISTRIBUTED_DATA_NETWORK_DELEGATE_DEFAULT_IMPL_H -#include "network_delegate.h" +#include "network/network_delegate.h" namespace OHOS::DistributedData { class NetworkDelegateDefaultImpl : public NetworkDelegate { diff --git a/services/distributeddataservice/adapter/network/src/network_delegate_normal_impl.h b/services/distributeddataservice/adapter/network/src/network_delegate_normal_impl.h index f4c62051d..e5944270d 100644 --- a/services/distributeddataservice/adapter/network/src/network_delegate_normal_impl.h +++ b/services/distributeddataservice/adapter/network/src/network_delegate_normal_impl.h @@ -20,7 +20,7 @@ #include #include "dm_device_info.h" -#include "network_delegate.h" +#include "network/network_delegate.h" namespace OHOS::DistributedData { class NetworkDelegateNormalImpl : public NetworkDelegate { diff --git a/services/distributeddataservice/adapter/schema_helper/BUILD.gn b/services/distributeddataservice/adapter/schema_helper/BUILD.gn index 26095037d..c3516c441 100644 --- a/services/distributeddataservice/adapter/schema_helper/BUILD.gn +++ b/services/distributeddataservice/adapter/schema_helper/BUILD.gn @@ -15,7 +15,7 @@ import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") config("module_public_config") { visibility = [ ":*" ] - include_dirs = [ "../include/schema_helper" ] + include_dirs = [ "." ] } ohos_source_set("distributeddata_schema_helper") { @@ -27,11 +27,12 @@ ohos_source_set("distributeddata_schema_helper") { boundary_sanitize = true ubsan = true } - sources = [ "src/get_schema_helper.cpp" ] + sources = [ "get_schema_helper.cpp" ] - cflags_cc = [ "-fvisibility=hidden" ] - - include_dirs = [ "../include/schema_helper" ] + cflags_cc = [ + "-fvisibility=hidden", + "-fstack-protector-strong", + ] public_configs = [ ":module_public_config" ] external_deps = [ diff --git a/services/distributeddataservice/adapter/schema_helper/src/get_schema_helper.cpp b/services/distributeddataservice/adapter/schema_helper/get_schema_helper.cpp similarity index 100% rename from services/distributeddataservice/adapter/schema_helper/src/get_schema_helper.cpp rename to services/distributeddataservice/adapter/schema_helper/get_schema_helper.cpp diff --git a/services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h b/services/distributeddataservice/adapter/schema_helper/get_schema_helper.h similarity index 99% rename from services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h rename to services/distributeddataservice/adapter/schema_helper/get_schema_helper.h index 9a0462f78..ab937d351 100644 --- a/services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h +++ b/services/distributeddataservice/adapter/schema_helper/get_schema_helper.h @@ -17,6 +17,7 @@ #include #include +#include #include "iremote_object.h" diff --git a/services/distributeddataservice/adapter/screenlock/BUILD.gn b/services/distributeddataservice/adapter/screenlock/BUILD.gn index ed1fd3913..2398bf180 100644 --- a/services/distributeddataservice/adapter/screenlock/BUILD.gn +++ b/services/distributeddataservice/adapter/screenlock/BUILD.gn @@ -13,6 +13,11 @@ import("//build/ohos.gni") import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") +config("module_public_config") { + visibility = [ ":*" ] + include_dirs = [ "${data_service_path}/adapter" ] +} + ohos_source_set("distributeddata_screenlock") { branch_protector_ret = "pac_ret" sanitize = { @@ -22,16 +27,19 @@ ohos_source_set("distributeddata_screenlock") { boundary_sanitize = true ubsan = true } - sources = [ "src/screen_lock.cpp" ] + sources = [ "screen_lock.cpp" ] - cflags_cc = [ "-fvisibility=hidden" ] + cflags_cc = [ + "-fvisibility=hidden", + "-fstack-protector-strong", + ] include_dirs = [ - "../include/screenlock", "../include/utils", "${data_service_path}/framework/include", ] + public_configs = [ ":module_public_config" ] deps = [ "${data_service_path}/adapter/account:distributeddata_account" ] external_deps = [ diff --git a/services/distributeddataservice/adapter/screenlock/src/screen_lock.cpp b/services/distributeddataservice/adapter/screenlock/screen_lock.cpp similarity index 99% rename from services/distributeddataservice/adapter/screenlock/src/screen_lock.cpp rename to services/distributeddataservice/adapter/screenlock/screen_lock.cpp index 7cac20cbf..36c5d601a 100644 --- a/services/distributeddataservice/adapter/screenlock/src/screen_lock.cpp +++ b/services/distributeddataservice/adapter/screenlock/screen_lock.cpp @@ -14,7 +14,7 @@ */ #define LOG_TAG "ScreenLock" -#include "screen_lock.h" +#include "screenlock/screen_lock.h" #include "account/account_delegate.h" #include "log_print.h" diff --git a/services/distributeddataservice/adapter/include/screenlock/screen_lock.h b/services/distributeddataservice/adapter/screenlock/screen_lock.h similarity index 100% rename from services/distributeddataservice/adapter/include/screenlock/screen_lock.h rename to services/distributeddataservice/adapter/screenlock/screen_lock.h diff --git a/services/distributeddataservice/adapter/screenlock/test/BUILD.gn b/services/distributeddataservice/adapter/screenlock/test/BUILD.gn index f1f16b53b..4c67a419d 100755 --- a/services/distributeddataservice/adapter/screenlock/test/BUILD.gn +++ b/services/distributeddataservice/adapter/screenlock/test/BUILD.gn @@ -19,13 +19,13 @@ ohos_unittest("ScreenLockTest") { module_out_path = module_output_path sources = [ - "${data_service_path}/adapter/screenlock/src/screen_lock.cpp", + "${data_service_path}/adapter/screenlock/screen_lock.cpp", "${data_service_path}/framework/account/account_delegate.cpp", "${data_service_path}/framework/screen/screen_manager.cpp", "screen_lock_test.cpp", ] include_dirs = [ - "${data_service_path}/adapter/include/screenlock", + "${data_service_path}/adapter/screenlock", "${data_service_path}/framework/include", "${data_service_path}/framework/include/account", ] diff --git a/services/distributeddataservice/framework/dfx/reporter.cpp b/services/distributeddataservice/framework/dfx/reporter.cpp index 4b003109b..14ba18c83 100644 --- a/services/distributeddataservice/framework/dfx/reporter.cpp +++ b/services/distributeddataservice/framework/dfx/reporter.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "reporter.h" +#include "dfx/reporter.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/framework/store/auto_cache.cpp b/services/distributeddataservice/framework/store/auto_cache.cpp index 0b17f5bc3..ee8aa7342 100644 --- a/services/distributeddataservice/framework/store/auto_cache.cpp +++ b/services/distributeddataservice/framework/store/auto_cache.cpp @@ -21,7 +21,7 @@ #include "changeevent/remote_change_event.h" #include "eventcenter/event_center.h" #include "log_print.h" -#include "screenlock/screen_lock.h" +#include "screen/screen_manager.h" #include "utils/anonymous.h" namespace OHOS::DistributedData { using Account = AccountDelegate; diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index 952c92895..b2c3d0415 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -78,6 +78,7 @@ ohos_shared_library("distributeddatasvc") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service/backup:distributeddata_backup", diff --git a/services/distributeddataservice/service/rdb/BUILD.gn b/services/distributeddataservice/service/rdb/BUILD.gn index 9c126c795..db6465e9b 100644 --- a/services/distributeddataservice/service/rdb/BUILD.gn +++ b/services/distributeddataservice/service/rdb/BUILD.gn @@ -66,6 +66,7 @@ ohos_source_set("distributeddata_rdb") { ] deps = [ + "${data_service_path}/adapter/bundle_mgr:distributeddata_bundle_mgr", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", "${data_service_path}/service/common:distributeddata_common", "${data_service_path}/service/crypto:distributeddata_crypto", diff --git a/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/services/distributeddataservice/service/rdb/rdb_general_store.cpp index edd37fd99..f0d642bc8 100644 --- a/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -29,20 +29,17 @@ #include "device_sync_app/device_sync_app_manager.h" #include "cloud_service.h" #include "commonevent/data_sync_event.h" -#include "communicator/device_manager_adapter.h" #include "crypto_manager.h" -#include "dfx_types.h" #include "device_manager_adapter.h" +#include "dfx/dfx_types.h" +#include "dfx/reporter.h" #include "eventcenter/event_center.h" #include "log_print.h" #include "metadata/meta_data_manager.h" #include "metadata/secret_key_meta_data.h" #include "rdb_cursor.h" -#include "rdb_helper.h" #include "rdb_query.h" -#include "rdb_result_set_impl.h" #include "relational_store_manager.h" -#include "reporter.h" #include "snapshot/bind_event.h" #include "utils/anonymous.h" #include "value_proxy.h" diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 30e197972..7d2fd38f7 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -18,6 +18,7 @@ #include "abs_rdb_predicates.h" #include "accesstoken_kit.h" #include "account/account_delegate.h" +#include "bundle_mgr/bundle_mgr_adapter.h" #include "changeevent/remote_change_event.h" #include "checker/checker_manager.h" #include "cloud/change_event.h" @@ -234,7 +235,15 @@ bool RdbServiceImpl::CheckAccess(const std::string& bundleName, const std::strin std::string RdbServiceImpl::ObtainDistributedTableName(const std::string &device, const std::string &table) { ZLOGI("device=%{public}s table=%{public}s", Anonymous::Change(device).c_str(), table.c_str()); - auto uuid = DmAdapter::GetInstance().GetUuidByNetworkId(device); + auto tokenId = IPCSkeleton::GetCallingTokenID(); + auto uid = IPCSkeleton::GetCallingUid(); + std::string appId = ""; + if (AccessTokenKit::GetTokenTypeFlag(tokenId) == Security::AccessToken::TOKEN_HAP) { + auto bundleName = BundleMgrAdapter::GetInstance().GetBundleName(uid); + auto [instanceId, user] = GetInstIndexAndUser(tokenId, bundleName); + appId = BundleMgrAdapter::GetInstance().GetAppId(user, bundleName); + } + auto uuid = DmAdapter::GetInstance().CalcClientUuid(appId, device); if (uuid.empty()) { ZLOGE("get uuid failed"); return ""; @@ -597,7 +606,7 @@ void RdbServiceImpl::DoCloudSync(const RdbSyncerParam ¶m, const RdbService:: ? GeneralStore::ASSETS_SYNC_MODE : (option.isAutoSync ? GeneralStore::AUTO_SYNC_MODE : GeneralStore::MANUAL_SYNC_MODE); auto mixMode = static_cast(GeneralStore::MixMode(option.mode, highMode)); - SyncParam syncParam = { mixMode, (option.isAsync ? 0 : WAIT_TIME), option.isCompensation }; + SyncParam syncParam = { mixMode, (option.isAsync ? 0 : static_cast(WAIT_TIME)), option.isCompensation }; syncParam.asyncDownloadAsset = param.asyncDownloadAsset_; auto info = ChangeEvent::EventInfo(syncParam, option.isAutoSync, query, option.isAutoSync ? nullptr -- Gitee From 82afcd41ca06ffc720167878e8b4d1eae2946729 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Mon, 5 May 2025 16:34:56 +0800 Subject: [PATCH 2/4] fix ut Signed-off-by: htt1997 --- .../adapter/bundle_mgr/bundle_mgr_adapter.cpp | 2 +- .../adapter/communicator/test/BUILD.gn | 9 -- .../adapter/screenlock/BUILD.gn | 10 +- .../adapter/screenlock/screen_lock.cpp | 2 +- .../adapter/screenlock/test/BUILD.gn | 21 +-- .../screenlock/test/screen_lock_test.cpp | 6 +- .../adapter/test/BUILD.gn | 5 +- .../service/rdb/rdb_service_impl.cpp | 1 + .../service/rdb/rdb_service_stub.cpp | 3 +- .../service/test/BUILD.gn | 130 ++---------------- .../fuzztest/cloudservicestub_fuzzer/BUILD.gn | 48 +------ .../fuzztest/rdbservicestub_fuzzer/BUILD.gn | 38 +---- 12 files changed, 42 insertions(+), 233 deletions(-) diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp index f6dfee2cf..c501bbd4a 100644 --- a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp +++ b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 diff --git a/services/distributeddataservice/adapter/communicator/test/BUILD.gn b/services/distributeddataservice/adapter/communicator/test/BUILD.gn index 5e5a3489d..a85976697 100755 --- a/services/distributeddataservice/adapter/communicator/test/BUILD.gn +++ b/services/distributeddataservice/adapter/communicator/test/BUILD.gn @@ -153,9 +153,6 @@ ohos_unittest("ProcessCommunicatorImplTest") { "../src", "../../include/communicator", "../../include/utils", - "${data_service_path}/adapter/include/communicator", - "${data_service_path}/framework/include/dfx", - "${data_service_path}/framework/include/utils", ] external_deps = [ @@ -180,7 +177,6 @@ ohos_unittest("ProcessCommunicatorImplTest") { "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service:distributeddatasvc", - "../../dfx:distributeddata_dfx", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -190,9 +186,7 @@ ohos_unittest("SoftbusAdapterStandardTest") { sources = [ "../src/app_pipe_handler.cpp", - "../src/app_pipe_handler.h", "../src/app_pipe_mgr.cpp", - "../src/app_pipe_mgr.h", "../src/ark_communication_provider.cpp", "../src/communication_provider.cpp", "../src/communication_provider_impl.cpp", @@ -200,9 +194,7 @@ ohos_unittest("SoftbusAdapterStandardTest") { "../src/data_buffer.cpp", "../src/device_manager_adapter.cpp", "../src/process_communicator_impl.cpp", - "../src/softbus_adapter.h", "../src/softbus_client.cpp", - "../src/softbus_client.h", "unittest/softbus_adapter_standard_test.cpp", ] @@ -235,7 +227,6 @@ ohos_unittest("SoftbusAdapterStandardTest") { deps = [ "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", - "../../dfx:distributeddata_dfx", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } diff --git a/services/distributeddataservice/adapter/screenlock/BUILD.gn b/services/distributeddataservice/adapter/screenlock/BUILD.gn index 2398bf180..f7813d16a 100644 --- a/services/distributeddataservice/adapter/screenlock/BUILD.gn +++ b/services/distributeddataservice/adapter/screenlock/BUILD.gn @@ -34,13 +34,11 @@ ohos_source_set("distributeddata_screenlock") { "-fstack-protector-strong", ] - include_dirs = [ - "../include/utils", - "${data_service_path}/framework/include", - ] - public_configs = [ ":module_public_config" ] - deps = [ "${data_service_path}/adapter/account:distributeddata_account" ] + deps = [ + "${data_service_path}/adapter/account:distributeddata_account", + "${data_service_path}/framework:distributeddatasvcfwk", + ] external_deps = [ "c_utils:utils", diff --git a/services/distributeddataservice/adapter/screenlock/screen_lock.cpp b/services/distributeddataservice/adapter/screenlock/screen_lock.cpp index 36c5d601a..7cac20cbf 100644 --- a/services/distributeddataservice/adapter/screenlock/screen_lock.cpp +++ b/services/distributeddataservice/adapter/screenlock/screen_lock.cpp @@ -14,7 +14,7 @@ */ #define LOG_TAG "ScreenLock" -#include "screenlock/screen_lock.h" +#include "screen_lock.h" #include "account/account_delegate.h" #include "log_print.h" diff --git a/services/distributeddataservice/adapter/screenlock/test/BUILD.gn b/services/distributeddataservice/adapter/screenlock/test/BUILD.gn index 4c67a419d..b7d623574 100755 --- a/services/distributeddataservice/adapter/screenlock/test/BUILD.gn +++ b/services/distributeddataservice/adapter/screenlock/test/BUILD.gn @@ -18,30 +18,23 @@ module_output_path = "datamgr_service/datamgr_service/distributeddatafwk" ohos_unittest("ScreenLockTest") { module_out_path = module_output_path - sources = [ - "${data_service_path}/adapter/screenlock/screen_lock.cpp", - "${data_service_path}/framework/account/account_delegate.cpp", - "${data_service_path}/framework/screen/screen_manager.cpp", - "screen_lock_test.cpp", - ] - include_dirs = [ - "${data_service_path}/adapter/screenlock", - "${data_service_path}/framework/include", - "${data_service_path}/framework/include/account", - ] + sources = [ "screen_lock_test.cpp" ] + cflags = [ "-Dprivate=public", "-Dprotected=public", "-Werror", ] + deps = [ + "${data_service_path}/adapter/screenlock:distributeddata_screenlock", + "${data_service_path}/framework:distributeddatasvcfwk" + ] external_deps = [ - "c_utils:utils", "common_event_service:cesfwk_innerkits", "googletest:gtest_main", "hilog:libhilog", - "kv_store:distributeddata_inner", - "screenlock_mgr:screenlock_client", + "kv_store:datamgr_common", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } diff --git a/services/distributeddataservice/adapter/screenlock/test/screen_lock_test.cpp b/services/distributeddataservice/adapter/screenlock/test/screen_lock_test.cpp index be5a5f5f1..263c17dde 100644 --- a/services/distributeddataservice/adapter/screenlock/test/screen_lock_test.cpp +++ b/services/distributeddataservice/adapter/screenlock/test/screen_lock_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "screen_lock.h" +#include "screenlock/screen_lock.h" #include namespace { @@ -65,7 +65,6 @@ public: HWTEST_F(ScreenLockTest, Subscribe001, TestSize.Level0) { auto screenLock = std::make_shared(); - screenLock->ScreenManager::Subscribe(nullptr); screenLock->Subscribe(nullptr); EXPECT_TRUE(screenLock->observerMap_.Empty()); auto observer = std::make_shared(); @@ -101,7 +100,6 @@ HWTEST_F(ScreenLockTest, Subscribe002, TestSize.Level0) HWTEST_F(ScreenLockTest, Unsubscribe001, TestSize.Level0) { auto screenLock = std::make_shared(); - screenLock->ScreenManager::Unsubscribe(nullptr); auto observer = std::make_shared(); screenLock->Subscribe(observer); EXPECT_EQ(screenLock->observerMap_.Size(), 1); @@ -122,10 +120,8 @@ HWTEST_F(ScreenLockTest, SubscribeScreenEvent001, TestSize.Level0) screenLock->BindExecutor(executor); ASSERT_NE(screenLock->executors_, nullptr); EXPECT_EQ(screenLock->eventSubscriber_, nullptr); - screenLock->ScreenManager::SubscribeScreenEvent(); screenLock->SubscribeScreenEvent(); EXPECT_NE(screenLock->eventSubscriber_, nullptr); - screenLock->ScreenManager::UnsubscribeScreenEvent(); screenLock->UnsubscribeScreenEvent(); } } // namespace \ No newline at end of file diff --git a/services/distributeddataservice/adapter/test/BUILD.gn b/services/distributeddataservice/adapter/test/BUILD.gn index 6f6f3b435..db76543eb 100755 --- a/services/distributeddataservice/adapter/test/BUILD.gn +++ b/services/distributeddataservice/adapter/test/BUILD.gn @@ -22,9 +22,12 @@ group("unittest") { "../account/test:unittest", "../communicator/test:unittest", "../dfx/test:unittest", - "../screenlock/test:unittest", ] + if (defined(global_parts_info) && defined(global_parts_info.theme_screenlock_mgr)) { + deps += [ "${data_service_path}/adapter/screenlock/test:unittest" ] + } + if (datamgr_service_cloud) { deps += [ "../network/test:unittest" ] } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 7d2fd38f7..82802f597 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -248,6 +248,7 @@ std::string RdbServiceImpl::ObtainDistributedTableName(const std::string &device ZLOGE("get uuid failed"); return ""; } + ZLOGI("uuid=%{public}s appId=%{public}s", uuid.c_str(), appId.c_str()); return DistributedDB::RelationalStoreManager::GetDistributedTableName(uuid, table); } diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index 737b216bb..fd7ee6ee4 100755 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -36,7 +36,8 @@ int32_t RdbServiceStub::OnRemoteObtainDistributedTableName(MessageParcel &data, } std::string distributedTableName = ObtainDistributedTableName(device, table); - if (!ITypesUtil::Marshal(reply, distributedTableName)) { + int32_t status = distributedTableName.empty() ? RDB_ERROR : RDB_OK; + if (!ITypesUtil::Marshal(reply, status, distributedTableName)) { ZLOGE("Marshal distributedTableName:%{public}s", distributedTableName.c_str()); return IPC_STUB_WRITE_PARCEL_ERR; } diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index 0a54979be..8ec28f6e6 100644 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -67,51 +67,6 @@ ohos_unittest("CloudDataTest") { } module_out_path = module_output_path sources = [ - "${data_service_path}/service/backup/src/backup_manager.cpp", - "${data_service_path}/service/bootstrap/src/bootstrap.cpp", - "${data_service_path}/service/cloud/cloud_data_translate.cpp", - "${data_service_path}/service/cloud/cloud_service_impl.cpp", - "${data_service_path}/service/cloud/cloud_service_stub.cpp", - "${data_service_path}/service/cloud/cloud_types_util.cpp", - "${data_service_path}/service/cloud/cloud_value_util.cpp", - "${data_service_path}/service/cloud/sync_manager.cpp", - "${data_service_path}/service/cloud/sync_strategies/network_sync_strategy.cpp", - "${data_service_path}/service/common/common_types_utils.cpp", - "${data_service_path}/service/common/value_proxy.cpp", - "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/config/src/config_factory.cpp", - "${data_service_path}/service/config/src/model/app_id_mapping_config.cpp", - "${data_service_path}/service/config/src/model/backup_config.cpp", - "${data_service_path}/service/config/src/model/checker_config.cpp", - "${data_service_path}/service/config/src/model/cloud_config.cpp", - "${data_service_path}/service/config/src/model/component_config.cpp", - "${data_service_path}/service/config/src/model/datashare_config.cpp", - "${data_service_path}/service/config/src/model/device_sync_app_white_list_config.cpp", - "${data_service_path}/service/config/src/model/directory_config.cpp", - "${data_service_path}/service/config/src/model/global_config.cpp", - "${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/user_delegate.cpp", - "${data_service_path}/service/matrix/src/device_matrix.cpp", - "${data_service_path}/service/matrix/src/matrix_event.cpp", - "${data_service_path}/service/permission/src/permission_validator.cpp", - "${data_service_path}/service/permission/src/permit_delegate.cpp", - "${data_service_path}/service/rdb/cache_cursor.cpp", - "${data_service_path}/service/rdb/rdb_asset_loader.cpp", - "${data_service_path}/service/rdb/rdb_cloud.cpp", - "${data_service_path}/service/rdb/rdb_cursor.cpp", - "${data_service_path}/service/rdb/rdb_general_store.cpp", - "${data_service_path}/service/rdb/rdb_hiview_adapter.cpp", - "${data_service_path}/service/rdb/rdb_notifier_proxy.cpp", - "${data_service_path}/service/rdb/rdb_query.cpp", - "${data_service_path}/service/rdb/rdb_result_set_impl.cpp", - "${data_service_path}/service/rdb/rdb_result_set_stub.cpp", - "${data_service_path}/service/rdb/rdb_schema_config.cpp", - "${data_service_path}/service/rdb/rdb_service_impl.cpp", - "${data_service_path}/service/rdb/rdb_service_stub.cpp", - "${data_service_path}/service/rdb/rdb_watcher.cpp", "${data_service_path}/service/test/mock/checker_mock.cpp", "cloud_data_test.cpp", ] @@ -119,33 +74,26 @@ ohos_unittest("CloudDataTest") { configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", "access_token:libaccesstoken_sdk", "access_token:libtoken_setproc", "access_token:libtokenid_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", - "device_manager:devicemanagersdk", - "hicollie:libhicollie", - "hilog:libhilog", - "hisysevent:libhisysevent", - "huks:libhukssdk", - "ipc:ipc_core", + "json:nlohmann_json_static", "kv_store:distributeddata_inner", "kv_store:distributeddb", - "netmanager_base:net_conn_manager_if", "relational_store:native_rdb", - "resource_management:global_resmgr", - "samgr:samgr_proxy", ] deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", - "../../framework:distributeddatasvcfwk", + "${data_service_path}/service/bootstrap:distributeddata_bootstrap", + "${data_service_path}/service/cloud:distributeddata_cloud", + "${data_service_path}/service/common:distributeddata_common", + "${data_service_path}/service/rdb:distributeddata_rdb", + "${data_service_path}/framework:distributeddatasvcfwk", "mock:distributeddata_mock_static", "//third_party/googletest:gtest_main", ] @@ -165,51 +113,6 @@ ohos_unittest("CloudServiceImplTest") { } module_out_path = module_output_path sources = [ - "${data_service_path}/service/backup/src/backup_manager.cpp", - "${data_service_path}/service/bootstrap/src/bootstrap.cpp", - "${data_service_path}/service/cloud/cloud_data_translate.cpp", - "${data_service_path}/service/cloud/cloud_service_impl.cpp", - "${data_service_path}/service/cloud/cloud_service_stub.cpp", - "${data_service_path}/service/cloud/cloud_types_util.cpp", - "${data_service_path}/service/cloud/cloud_value_util.cpp", - "${data_service_path}/service/cloud/sync_manager.cpp", - "${data_service_path}/service/cloud/sync_strategies/network_sync_strategy.cpp", - "${data_service_path}/service/common/common_types_utils.cpp", - "${data_service_path}/service/common/value_proxy.cpp", - "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/config/src/config_factory.cpp", - "${data_service_path}/service/config/src/model/app_id_mapping_config.cpp", - "${data_service_path}/service/config/src/model/backup_config.cpp", - "${data_service_path}/service/config/src/model/checker_config.cpp", - "${data_service_path}/service/config/src/model/cloud_config.cpp", - "${data_service_path}/service/config/src/model/component_config.cpp", - "${data_service_path}/service/config/src/model/datashare_config.cpp", - "${data_service_path}/service/config/src/model/device_sync_app_white_list_config.cpp", - "${data_service_path}/service/config/src/model/directory_config.cpp", - "${data_service_path}/service/config/src/model/global_config.cpp", - "${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/user_delegate.cpp", - "${data_service_path}/service/matrix/src/device_matrix.cpp", - "${data_service_path}/service/matrix/src/matrix_event.cpp", - "${data_service_path}/service/permission/src/permission_validator.cpp", - "${data_service_path}/service/permission/src/permit_delegate.cpp", - "${data_service_path}/service/rdb/cache_cursor.cpp", - "${data_service_path}/service/rdb/rdb_asset_loader.cpp", - "${data_service_path}/service/rdb/rdb_cloud.cpp", - "${data_service_path}/service/rdb/rdb_cursor.cpp", - "${data_service_path}/service/rdb/rdb_general_store.cpp", - "${data_service_path}/service/rdb/rdb_hiview_adapter.cpp", - "${data_service_path}/service/rdb/rdb_notifier_proxy.cpp", - "${data_service_path}/service/rdb/rdb_query.cpp", - "${data_service_path}/service/rdb/rdb_result_set_impl.cpp", - "${data_service_path}/service/rdb/rdb_result_set_stub.cpp", - "${data_service_path}/service/rdb/rdb_schema_config.cpp", - "${data_service_path}/service/rdb/rdb_service_impl.cpp", - "${data_service_path}/service/rdb/rdb_service_stub.cpp", - "${data_service_path}/service/rdb/rdb_watcher.cpp", "${data_service_path}/service/test/mock/checker_mock.cpp", "cloud_service_impl_test.cpp", ] @@ -217,32 +120,25 @@ ohos_unittest("CloudServiceImplTest") { configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", "access_token:libaccesstoken_sdk", "access_token:libtoken_setproc", - "access_token:libtokenid_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", - "device_manager:devicemanagersdk", - "hicollie:libhicollie", "hilog:libhilog", - "hisysevent:libhisysevent", - "huks:libhukssdk", - "ipc:ipc_core", + "json:nlohmann_json_static", "kv_store:distributeddata_inner", "kv_store:distributeddb", - "netmanager_base:net_conn_manager_if", "relational_store:native_rdb", - "resource_management:global_resmgr", - "samgr:samgr_proxy", ] deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/communicator:distributeddata_communicator", + "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", + "${data_service_path}/service/bootstrap:distributeddata_bootstrap", + "${data_service_path}/service/cloud:distributeddata_cloud", + "${data_service_path}/service/common:distributeddata_common", + "${data_service_path}/service/rdb:distributeddata_rdb", "../../framework:distributeddatasvcfwk", "mock:distributeddata_mock_static", "//third_party/googletest:gtest_main", diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index ca4c9f005..266963ec3 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -64,49 +64,6 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { sources = [ "${data_service_path}/app/src/checker/bundle_checker.cpp", "${data_service_path}/app/src/checker/system_checker.cpp", - "${data_service_path}/service/backup/src/backup_manager.cpp", - "${data_service_path}/service/bootstrap/src/bootstrap.cpp", - "${data_service_path}/service/cloud/cloud_data_translate.cpp", - "${data_service_path}/service/cloud/cloud_service_impl.cpp", - "${data_service_path}/service/cloud/cloud_service_stub.cpp", - "${data_service_path}/service/cloud/cloud_types_util.cpp", - "${data_service_path}/service/cloud/cloud_value_util.cpp", - "${data_service_path}/service/cloud/sync_manager.cpp", - "${data_service_path}/service/cloud/sync_strategies/network_sync_strategy.cpp", - "${data_service_path}/service/common/common_types_utils.cpp", - "${data_service_path}/service/common/value_proxy.cpp", - "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/config/src/config_factory.cpp", - "${data_service_path}/service/config/src/model/app_id_mapping_config.cpp", - "${data_service_path}/service/config/src/model/backup_config.cpp", - "${data_service_path}/service/config/src/model/checker_config.cpp", - "${data_service_path}/service/config/src/model/cloud_config.cpp", - "${data_service_path}/service/config/src/model/component_config.cpp", - "${data_service_path}/service/config/src/model/datashare_config.cpp", - "${data_service_path}/service/config/src/model/device_sync_app_white_list_config.cpp", - "${data_service_path}/service/config/src/model/directory_config.cpp", - "${data_service_path}/service/config/src/model/global_config.cpp", - "${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/user_delegate.cpp", - "${data_service_path}/service/permission/src/permission_validator.cpp", - "${data_service_path}/service/permission/src/permit_delegate.cpp", - "${data_service_path}/service/rdb/cache_cursor.cpp", - "${data_service_path}/service/rdb/rdb_asset_loader.cpp", - "${data_service_path}/service/rdb/rdb_cloud.cpp", - "${data_service_path}/service/rdb/rdb_cursor.cpp", - "${data_service_path}/service/rdb/rdb_general_store.cpp", - "${data_service_path}/service/rdb/rdb_hiview_adapter.cpp", - "${data_service_path}/service/rdb/rdb_notifier_proxy.cpp", - "${data_service_path}/service/rdb/rdb_query.cpp", - "${data_service_path}/service/rdb/rdb_result_set_impl.cpp", - "${data_service_path}/service/rdb/rdb_result_set_stub.cpp", - "${data_service_path}/service/rdb/rdb_schema_config.cpp", - "${data_service_path}/service/rdb/rdb_service_impl.cpp", - "${data_service_path}/service/rdb/rdb_service_stub.cpp", - "${data_service_path}/service/rdb/rdb_watcher.cpp", "cloudservicestub_fuzzer.cpp", ] @@ -116,7 +73,10 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", - "${data_service_path}/service:distributeddatasvc", + "${data_service_path}/service/bootstrap:distributeddata_bootstrap", + "${data_service_path}/service/cloud:distributeddata_cloud", + "${data_service_path}/service/common:distributeddata_common", + "${data_service_path}/service/rdb:distributeddata_rdb", "${kv_store_distributeddb_path}:distributeddb", ] diff --git a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn index e9d34a5d4..6eb31a8dd 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn @@ -64,38 +64,6 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { sources = [ "${data_service_path}/app/src/checker/bundle_checker.cpp", "${data_service_path}/app/src/checker/system_checker.cpp", - "${data_service_path}/service/backup/src/backup_manager.cpp", - "${data_service_path}/service/bootstrap/src/bootstrap.cpp", - "${data_service_path}/service/common/value_proxy.cpp", - "${data_service_path}/service/common/xcollie.cpp", - "${data_service_path}/service/config/src/config_factory.cpp", - "${data_service_path}/service/config/src/model/app_id_mapping_config.cpp", - "${data_service_path}/service/config/src/model/backup_config.cpp", - "${data_service_path}/service/config/src/model/checker_config.cpp", - "${data_service_path}/service/config/src/model/cloud_config.cpp", - "${data_service_path}/service/config/src/model/component_config.cpp", - "${data_service_path}/service/config/src/model/datashare_config.cpp", - "${data_service_path}/service/config/src/model/device_sync_app_white_list_config.cpp", - "${data_service_path}/service/config/src/model/directory_config.cpp", - "${data_service_path}/service/config/src/model/global_config.cpp", - "${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/rdb/cache_cursor.cpp", - "${data_service_path}/service/rdb/rdb_asset_loader.cpp", - "${data_service_path}/service/rdb/rdb_cloud.cpp", - "${data_service_path}/service/rdb/rdb_cursor.cpp", - "${data_service_path}/service/rdb/rdb_general_store.cpp", - "${data_service_path}/service/rdb/rdb_hiview_adapter.cpp", - "${data_service_path}/service/rdb/rdb_notifier_proxy.cpp", - "${data_service_path}/service/rdb/rdb_query.cpp", - "${data_service_path}/service/rdb/rdb_result_set_impl.cpp", - "${data_service_path}/service/rdb/rdb_result_set_stub.cpp", - "${data_service_path}/service/rdb/rdb_schema_config.cpp", - "${data_service_path}/service/rdb/rdb_service_impl.cpp", - "${data_service_path}/service/rdb/rdb_service_stub.cpp", - "${data_service_path}/service/rdb/rdb_watcher.cpp", "rdbservicestub_fuzzer.cpp", ] @@ -103,9 +71,11 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", - "${data_service_path}/service:distributeddatasvc", + "${data_service_path}/service/bootstrap:distributeddata_bootstrap", + "${data_service_path}/service/cloud:distributeddata_cloud", + "${data_service_path}/service/common:distributeddata_common", + "${data_service_path}/service/rdb:distributeddata_rdb", "${kv_store_distributeddb_path}:distributeddb", - "${relational_store_inner_api_path}:native_rdb_static", ] external_deps = [ -- Gitee From 9823f668e07745b7dc9da4bf361dea93e7415256 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Tue, 6 May 2025 15:51:28 +0800 Subject: [PATCH 3/4] Delete redundant code and fix gn Signed-off-by: htt1997 --- .../account/src/account_delegate_impl.h | 2 +- .../adapter/bundle_mgr/bundle_mgr_adapter.cpp | 70 ------------------- .../adapter/bundle_mgr/bundle_mgr_adapter.h | 27 ------- .../unittest/distributeddata_dfx_mst_test.cpp | 2 +- .../unittest/distributeddata_dfx_ut_test.cpp | 2 +- .../test/unittest/hiview_adapter_dfx_test.cpp | 4 +- .../app/src/kvstore_account_observer.h | 2 +- .../app/src/kvstore_data_service.cpp | 2 +- .../app/src/kvstore_data_service.h | 8 +-- .../app/src/kvstore_meta_manager.cpp | 3 +- .../src/session_manager/upgrade_manager.cpp | 4 +- .../distributeddataservice/framework/BUILD.gn | 3 - .../framework/account/account_delegate.cpp | 2 +- .../framework/network/network_delegate.cpp | 2 +- .../framework/store/auto_cache.cpp | 2 +- .../service/cloud/cloud_service_impl.cpp | 7 +- .../service/cloud/cloud_service_impl.h | 2 +- .../service/cloud/sync_manager.cpp | 4 +- .../service/cloud/sync_manager.h | 2 +- .../service/data_share/common/db_delegate.cpp | 2 +- .../data_share/data_share_service_impl.h | 4 +- .../service/kvdb/kvdb_exporter.cpp | 2 +- .../service/kvdb/kvdb_general_store.cpp | 4 +- .../service/rdb/rdb_service_impl.cpp | 18 ++--- .../service/test/BUILD.gn | 35 ++++++---- .../service/test/cloud_data_test.cpp | 2 +- .../service/test/cloud_service_impl_test.cpp | 2 +- .../fuzztest/cloudservicestub_fuzzer/BUILD.gn | 29 +------- .../fuzztest/rdbservicestub_fuzzer/BUILD.gn | 2 +- .../service/test/kvdb_service_impl_test.cpp | 2 +- .../service/test/mock/account_delegate_mock.h | 2 +- .../service/test/mock/network_delegate_mock.h | 2 +- .../udmf/store/store_account_observer.h | 2 +- .../service/udmf/udmf_service_impl.cpp | 2 +- 34 files changed, 69 insertions(+), 191 deletions(-) diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h index e8fc5d5c3..86874e0e1 100644 --- a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h +++ b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h @@ -19,7 +19,7 @@ #include #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "concurrent_map.h" #include "log_print.h" diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp index c501bbd4a..8e2340f58 100644 --- a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp +++ b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp @@ -19,47 +19,6 @@ #include "log_print.h" using namespace OHOS::AppExecFwk; namespace OHOS::DistributedData { -BundleFlag Convert(int32_t type) -{ - switch (type) { - case BundleMgrAdapter::BUNDLE_DEFAULT: - return GET_BUNDLE_DEFAULT; - case BundleMgrAdapter::BUNDLE_WITH_ABILITIES: - return GET_BUNDLE_WITH_ABILITIES; - case BundleMgrAdapter::BUNDLE_WITH_REQUESTED_PERMISSION: - return GET_BUNDLE_WITH_REQUESTED_PERMISSION; - case BundleMgrAdapter::BUNDLE_WITH_EXTENSION_INFO: - return GET_BUNDLE_WITH_EXTENSION_INFO; - case BundleMgrAdapter::BUNDLE_WITH_HASH_VALUE: - return GET_BUNDLE_WITH_HASH_VALUE; - case BundleMgrAdapter::BUNDLE_WITH_MENU: - return GET_BUNDLE_WITH_MENU; - case BundleMgrAdapter::BUNDLE_WITH_ROUTER_MAP: - return GET_BUNDLE_WITH_ROUTER_MAP; - case BundleMgrAdapter::BUNDLE_WITH_SKILL: - return GET_BUNDLE_WITH_SKILL; - } - ZLOGW("invalid type:%{public}d", type); - return GET_BUNDLE_DEFAULT; -} - -BundleMgrAdapter::HapModuleInfo Convert(AppExecFwk::HapModuleInfo &&info) -{ - BundleMgrAdapter::HapModuleInfo res; - res.hapPath = std::move(info.hapPath); - return res; -} - -BundleMgrAdapter::BundleInfo Convert(AppExecFwk::BundleInfo &&info) -{ - BundleMgrAdapter::BundleInfo res; - res.moduleDirs = info.moduleDirs; - res.hapModuleInfos.reserve(info.hapModuleInfos.size()); - for (auto &moduleInfo : info.hapModuleInfos) { - res.hapModuleInfos.push_back(Convert(std::move(moduleInfo))); - } - return res; -} BundleMgrAdapter &BundleMgrAdapter::GetInstance() { @@ -67,19 +26,6 @@ BundleMgrAdapter &BundleMgrAdapter::GetInstance() return instance; } -std::pair BundleMgrAdapter::GetBundleInfo(const std::string &bundleName, - BundleType type, int32_t user) -{ - AppExecFwk::BundleInfo info; - BundleMgrClient client; - bool res = client.GetBundleInfo(bundleName, Convert(type), info, user == 0 ? Constants::UNSPECIFIED_USERID : user); - if (!res) { - return { res, {} }; - } - BundleInfo bundleInfo = Convert(std::move(info)); - return { res, bundleInfo }; -} - std::string BundleMgrAdapter::GetBundleName(int32_t uid) { BundleMgrClient client; @@ -91,20 +37,4 @@ std::string BundleMgrAdapter::GetBundleName(int32_t uid) } return bundleName; } - -std::string BundleMgrAdapter::GetAppId(int32_t user, const std::string &bundleName) -{ - if (bundleName.empty()) { - ZLOGE("invalid args. user:%{public}d, bundleName:%{public}s", user, bundleName.c_str()); - return ""; - } - AppExecFwk::BundleInfo info; - BundleMgrClient client; - auto code = client.GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, info, - user == 0 ? Constants::UNSPECIFIED_USERID : user); - if (code != 0) { - ZLOGE("failed. user:%{public}d, bundleName:%{public}s", user, bundleName.c_str()); - } - return info.appId; -} } // namespace OHOS::DistributedData \ No newline at end of file diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h index fa0d4b955..e955a6fba 100644 --- a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h +++ b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h @@ -23,35 +23,8 @@ namespace OHOS { namespace DistributedData { class API_EXPORT BundleMgrAdapter { public: - struct HapModuleInfo { - std::string hapPath; - }; - struct BundleInfo { - std::vector hapModuleInfos; - std::vector moduleDirs; - }; - enum BundleType { - // get bundle info except abilityInfos - BUNDLE_DEFAULT = 0x00000000, - // get bundle info include abilityInfos - BUNDLE_WITH_ABILITIES = 0x00000001, - // get bundle info include request permissions - BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, - // get bundle info include extension info - BUNDLE_WITH_EXTENSION_INFO = 0x00000020, - // get bundle info include hash value - BUNDLE_WITH_HASH_VALUE = 0x00000030, - // get bundle info include menu, only for dump usage - BUNDLE_WITH_MENU = 0x00000040, - // get bundle info include router map, only for dump usage - BUNDLE_WITH_ROUTER_MAP = 0x00000080, - // get bundle info include skill info - BUNDLE_WITH_SKILL = 0x00000800, - }; static BundleMgrAdapter &GetInstance(); - std::pair GetBundleInfo(const std::string &bundleName, BundleType type, int32_t user = 0); std::string GetBundleName(int32_t uid); - std::string GetAppId(int32_t user, const std::string &bundleName); }; } // namespace DistributedData } // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp b/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp index c5a67afe6..5c0065d8e 100644 --- a/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp +++ b/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp @@ -15,7 +15,7 @@ #include #include -#include "reporter.h" +#include "dfx/reporter.h" using namespace testing::ext; using namespace OHOS::DistributedDataDfx; diff --git a/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_ut_test.cpp b/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_ut_test.cpp index d7fed644c..4530a0032 100644 --- a/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_ut_test.cpp +++ b/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_ut_test.cpp @@ -15,7 +15,7 @@ #include #include -#include "reporter.h" +#include "dfx/reporter.h" #include "fake_hiview.h" #include "value_hash.h" diff --git a/services/distributeddataservice/adapter/dfx/test/unittest/hiview_adapter_dfx_test.cpp b/services/distributeddataservice/adapter/dfx/test/unittest/hiview_adapter_dfx_test.cpp index 1d2ebaf86..7ac97e392 100644 --- a/services/distributeddataservice/adapter/dfx/test/unittest/hiview_adapter_dfx_test.cpp +++ b/services/distributeddataservice/adapter/dfx/test/unittest/hiview_adapter_dfx_test.cpp @@ -15,11 +15,11 @@ #define LOG_TAG "HiViewAdapterDfxTest" #include "device_manager_adapter.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" +#include "dfx/radar_reporter.h" #include "gtest/gtest.h" #include "hiview_adapter.h" #include "log_print.h" -#include "radar_reporter.h" using namespace OHOS; using namespace testing; diff --git a/services/distributeddataservice/app/src/kvstore_account_observer.h b/services/distributeddataservice/app/src/kvstore_account_observer.h index d8ea3d153..bbc535088 100644 --- a/services/distributeddataservice/app/src/kvstore_account_observer.h +++ b/services/distributeddataservice/app/src/kvstore_account_observer.h @@ -18,7 +18,7 @@ #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "executor_pool.h" namespace OHOS { diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 03cae1122..673af00a5 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -37,6 +37,7 @@ #include "db_info_handle_impl.h" #include "device_manager_adapter.h" #include "device_matrix.h" +#include "dfx/reporter.h" #include "dump/dump_manager.h" #include "dump_helper.h" #include "eventcenter/event_center.h" @@ -54,7 +55,6 @@ #include "permission_validator.h" #include "permit_delegate.h" #include "process_communicator_impl.h" -#include "reporter.h" #include "route_head_handler_impl.h" #include "runtime_config.h" #include "store/auto_cache.h" diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index 8dea8bb49..d54836867 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -21,23 +21,23 @@ #include #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "clone/clone_backup_info.h" #include "clone/secret_key_backup_data.h" +#include "dfx/reporter.h" +#include "executor_pool.h" #include "feature_stub_impl.h" #include "ikvstore_data_service.h" #include "ithread_pool.h" +#include "kvstore_data_service_stub.h" #include "kvstore_device_listener.h" #include "kvstore_meta_manager.h" -#include "kvstore_data_service_stub.h" #include "metadata/secret_key_meta_data.h" #include "metadata/store_meta_data.h" -#include "reporter.h" #include "runtime_config.h" #include "screen/screen_manager.h" #include "security/security.h" #include "system_ability.h" -#include "executor_pool.h" #include "types.h" #include "unique_fd.h" diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp index 304048400..9c8013f8b 100644 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp @@ -20,9 +20,8 @@ #include #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "bootstrap.h" -#include "cloud/change_event.h" #include "communication_provider.h" #include "crypto_manager.h" #include "device_manager_adapter.h" diff --git a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp index 4055f30f1..2276159fa 100644 --- a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp +++ b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp @@ -17,13 +17,11 @@ #include "upgrade_manager.h" #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "device_manager_adapter.h" #include "log_print.h" #include "metadata/meta_data_manager.h" #include "utils/anonymous.h" -#include "utils/constant.h" -#include "app_id_mapping/app_id_mapping_config_manager.h" namespace OHOS::DistributedData { using namespace OHOS::DistributedKv; diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index a99bba56a..53b402127 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -34,9 +34,6 @@ config("module_public_config") { visibility = [ ":*" ] include_dirs = [ "include", - "${data_service_path}/framework/include/account", - "${data_service_path}/framework/include/dfx", - "${data_service_path}/framework/include/network", "${kv_store_common_path}", ] } diff --git a/services/distributeddataservice/framework/account/account_delegate.cpp b/services/distributeddataservice/framework/account/account_delegate.cpp index 2b77557d4..6ef959548 100644 --- a/services/distributeddataservice/framework/account/account_delegate.cpp +++ b/services/distributeddataservice/framework/account/account_delegate.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "account_delegate.h" +#include "account/account_delegate.h" namespace OHOS { namespace DistributedData { diff --git a/services/distributeddataservice/framework/network/network_delegate.cpp b/services/distributeddataservice/framework/network/network_delegate.cpp index 368fb1598..37326525a 100644 --- a/services/distributeddataservice/framework/network/network_delegate.cpp +++ b/services/distributeddataservice/framework/network/network_delegate.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "network_delegate.h" +#include "network/network_delegate.h" namespace OHOS { namespace DistributedData { diff --git a/services/distributeddataservice/framework/store/auto_cache.cpp b/services/distributeddataservice/framework/store/auto_cache.cpp index ee8aa7342..b6343164e 100644 --- a/services/distributeddataservice/framework/store/auto_cache.cpp +++ b/services/distributeddataservice/framework/store/auto_cache.cpp @@ -17,7 +17,7 @@ #include -#include "account_delegate.h" +#include "account/account_delegate.h" #include "changeevent/remote_change_event.h" #include "eventcenter/event_center.h" #include "log_print.h" diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index fe9aa097b..f566532a7 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -32,18 +32,18 @@ #include "cloud_data_translate.h" #include "cloud_value_util.h" #include "device_manager_adapter.h" -#include "radar_reporter.h" +#include "dfx/radar_reporter.h" +#include "dfx/reporter.h" #include "eventcenter/event_center.h" +#include "get_schema_helper.h" #include "hap_token_info.h" #include "ipc_skeleton.h" #include "log_print.h" #include "metadata/meta_data_manager.h" #include "network/network_delegate.h" #include "rdb_types.h" -#include "reporter.h" #include "relational_store_manager.h" #include "runtime_config.h" -#include "get_schema_helper.h" #include "store/auto_cache.h" #include "sync_manager.h" #include "sync_strategies/network_sync_strategy.h" @@ -51,7 +51,6 @@ #include "values_bucket.h" #include "xcollie.h" - namespace OHOS::CloudData { using namespace DistributedData; using namespace std::chrono; diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index 21283817f..d0242197b 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -26,7 +26,7 @@ #include "cloud/sharing_center.h" #include "cloud/subscription.h" #include "cloud_service_stub.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" #include "feature/static_acts.h" #include "store/general_store.h" #include "sync_manager.h" diff --git a/services/distributeddataservice/service/cloud/sync_manager.cpp b/services/distributeddataservice/service/cloud/sync_manager.cpp index adb7e9e53..f949d37c7 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -26,12 +26,12 @@ #include "cloud/schema_meta.h" #include "cloud_value_util.h" #include "device_manager_adapter.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" +#include "dfx/reporter.h" #include "eventcenter/event_center.h" #include "log_print.h" #include "metadata/meta_data_manager.h" #include "network/network_delegate.h" -#include "reporter.h" #include "screen/screen_manager.h" #include "sync_strategies/network_sync_strategy.h" #include "user_delegate.h" diff --git a/services/distributeddataservice/service/cloud/sync_manager.h b/services/distributeddataservice/service/cloud/sync_manager.h index bc19b107b..0769c4ea4 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.h +++ b/services/distributeddataservice/service/cloud/sync_manager.h @@ -23,6 +23,7 @@ #include "cloud_types.h" #include "cloud/sync_event.h" #include "concurrent_map.h" +#include "dfx/radar_reporter.h" #include "eventcenter/event.h" #include "executor_pool.h" #include "metadata/store_meta_data_local.h" @@ -30,7 +31,6 @@ #include "store/general_store.h" #include "store/general_value.h" #include "utils/ref_count.h" -#include "radar_reporter.h" namespace OHOS::CloudData { class SyncManager { diff --git a/services/distributeddataservice/service/data_share/common/db_delegate.cpp b/services/distributeddataservice/service/data_share/common/db_delegate.cpp index 50196297b..765d69b5c 100644 --- a/services/distributeddataservice/service/data_share/common/db_delegate.cpp +++ b/services/distributeddataservice/service/data_share/common/db_delegate.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "DBAdaptor" #include "db_delegate.h" -#include "account_delegate.h" +#include "account/account_delegate.h" #include "kv_delegate.h" #include "log_print.h" #include "rdb_delegate.h" diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.h b/services/distributeddataservice/service/data_share/data_share_service_impl.h index 90ee77d4a..3baf32251 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.h +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.h @@ -22,11 +22,11 @@ #include "accesstoken_kit.h" #include "bundle_mgr_proxy.h" +#include "changeevent/remote_change_event.h" #include "common_event_subscribe_info.h" #include "common_event_subscriber.h" -#include "changeevent/remote_change_event.h" -#include "data_proxy_observer.h" #include "data_provider_config.h" +#include "data_proxy_observer.h" #include "data_share_db_config.h" #include "data_share_service_stub.h" #include "data_share_silent_config.h" diff --git a/services/distributeddataservice/service/kvdb/kvdb_exporter.cpp b/services/distributeddataservice/service/kvdb/kvdb_exporter.cpp index 3b41e3442..11016183d 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_exporter.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_exporter.cpp @@ -16,10 +16,10 @@ #include "kvdb_exporter.h" #include "backup_manager.h" +#include "dfx/reporter.h" #include "directory/directory_manager.h" #include "kvdb_general_store.h" #include "log_print.h" -#include "reporter.h" namespace OHOS::DistributedKv { using namespace OHOS::DistributedData; using namespace OHOS::DistributedDataDfx; diff --git a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp index 05a49cda2..b2fab36ce 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp @@ -25,7 +25,8 @@ #include "crypto_manager.h" #include "device_manager_adapter.h" #include "device_matrix.h" -#include "dfx_types.h" +#include "dfx/dfx_types.h" +#include "dfx/reporter.h" #include "directory/directory_manager.h" #include "eventcenter/event_center.h" #include "kvdb_query.h" @@ -35,7 +36,6 @@ #include "metadata/store_meta_data_local.h" #include "query_helper.h" #include "rdb_cloud.h" -#include "reporter.h" #include "snapshot/bind_event.h" #include "types.h" #include "user_delegate.h" diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 82802f597..d5e50f754 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -234,21 +234,17 @@ bool RdbServiceImpl::CheckAccess(const std::string& bundleName, const std::strin std::string RdbServiceImpl::ObtainDistributedTableName(const std::string &device, const std::string &table) { - ZLOGI("device=%{public}s table=%{public}s", Anonymous::Change(device).c_str(), table.c_str()); - auto tokenId = IPCSkeleton::GetCallingTokenID(); + ZLOGI("device=%{public}s table=%{public}s", Anonymous::Change(device).c_str(), Anonymous::Change(table).c_str()); auto uid = IPCSkeleton::GetCallingUid(); - std::string appId = ""; - if (AccessTokenKit::GetTokenTypeFlag(tokenId) == Security::AccessToken::TOKEN_HAP) { - auto bundleName = BundleMgrAdapter::GetInstance().GetBundleName(uid); - auto [instanceId, user] = GetInstIndexAndUser(tokenId, bundleName); - appId = BundleMgrAdapter::GetInstance().GetAppId(user, bundleName); - } - auto uuid = DmAdapter::GetInstance().CalcClientUuid(appId, device); + auto bundleName = BundleMgrAdapter::GetInstance().GetBundleName(uid); + auto tokenId = IPCSkeleton::GetCallingTokenID(); + auto appId = CheckerManager::GetInstance().GetAppId({ uid, tokenId, bundleName }); + auto uuid = DmAdapter::GetInstance().CalcClientUuid(appId, DmAdapter::GetInstance().ToUUID(device)); if (uuid.empty()) { - ZLOGE("get uuid failed"); + ZLOGE("get uuid failed, bundle:%{public}s, deviceId:%{public}s, table:%{public}s", bundleName.c_str(), + Anonymous::Change(device).c_str(), Anonymous::Change(table).c_str()); return ""; } - ZLOGI("uuid=%{public}s appId=%{public}s", uuid.c_str(), appId.c_str()); return DistributedDB::RelationalStoreManager::GetDistributedTableName(uuid, table); } diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index 8ec28f6e6..76f1f983d 100644 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -67,6 +67,13 @@ ohos_unittest("CloudDataTest") { } module_out_path = module_output_path sources = [ + "${data_service_path}/service/cloud/cloud_data_translate.cpp", + "${data_service_path}/service/cloud/cloud_service_impl.cpp", + "${data_service_path}/service/cloud/cloud_service_stub.cpp", + "${data_service_path}/service/cloud/cloud_types_util.cpp", + "${data_service_path}/service/cloud/cloud_value_util.cpp", + "${data_service_path}/service/cloud/sync_manager.cpp", + "${data_service_path}/service/cloud/sync_strategies/network_sync_strategy.cpp", "${data_service_path}/service/test/mock/checker_mock.cpp", "cloud_data_test.cpp", ] @@ -78,6 +85,7 @@ ohos_unittest("CloudDataTest") { "access_token:libtoken_setproc", "access_token:libtokenid_sdk", "c_utils:utils", + "hicollie:libhicollie", "json:nlohmann_json_static", "kv_store:distributeddata_inner", "kv_store:distributeddb", @@ -90,7 +98,6 @@ ohos_unittest("CloudDataTest") { "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", - "${data_service_path}/service/cloud:distributeddata_cloud", "${data_service_path}/service/common:distributeddata_common", "${data_service_path}/service/rdb:distributeddata_rdb", "${data_service_path}/framework:distributeddatasvcfwk", @@ -113,6 +120,13 @@ ohos_unittest("CloudServiceImplTest") { } module_out_path = module_output_path sources = [ + "${data_service_path}/service/cloud/cloud_data_translate.cpp", + "${data_service_path}/service/cloud/cloud_service_impl.cpp", + "${data_service_path}/service/cloud/cloud_service_stub.cpp", + "${data_service_path}/service/cloud/cloud_types_util.cpp", + "${data_service_path}/service/cloud/cloud_value_util.cpp", + "${data_service_path}/service/cloud/sync_manager.cpp", + "${data_service_path}/service/cloud/sync_strategies/network_sync_strategy.cpp", "${data_service_path}/service/test/mock/checker_mock.cpp", "cloud_service_impl_test.cpp", ] @@ -123,7 +137,7 @@ ohos_unittest("CloudServiceImplTest") { "access_token:libaccesstoken_sdk", "access_token:libtoken_setproc", "c_utils:utils", - "hilog:libhilog", + "hicollie:libhicollie", "json:nlohmann_json_static", "kv_store:distributeddata_inner", "kv_store:distributeddb", @@ -136,10 +150,9 @@ ohos_unittest("CloudServiceImplTest") { "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", - "${data_service_path}/service/cloud:distributeddata_cloud", "${data_service_path}/service/common:distributeddata_common", "${data_service_path}/service/rdb:distributeddata_rdb", - "../../framework:distributeddatasvcfwk", + "${data_service_path}/framework:distributeddatasvcfwk", "mock:distributeddata_mock_static", "//third_party/googletest:gtest_main", ] @@ -746,13 +759,13 @@ ohos_unittest("ObjectManagerTest") { ] include_dirs = [ - "${dataobject_path}/frameworks/innerkitsimpl/include", + "${data_service_path}/adapter/include/utils", "${data_service_path}/app/src", "${data_service_path}/service/common", - "${dataobject_path}/frameworks/innerkitsimpl/include/common", - "${dataobject_path}/interfaces/innerkits", - "${data_service_path}/adapter/include/utils", "${data_service_path}/service/test/mock", + "${dataobject_path}/interfaces/innerkits", + "${dataobject_path}/frameworks/innerkitsimpl/include", + "${dataobject_path}/frameworks/innerkitsimpl/include/common", ] configs = [ ":module_private_config" ] @@ -889,9 +902,6 @@ ohos_unittest("UdmfRunTimeStoreTest") { "${data_service_path}/service/udmf", "${data_service_path}/service/udmf/store", "${data_service_path}/service/udmf/preprocess", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", - "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", ] configs = [ ":module_private_config" ] @@ -917,7 +927,6 @@ ohos_unittest("UdmfRunTimeStoreTest") { ] deps = [ - "${data_service_path}/adapter/communicator:distributeddata_communicator", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service:distributeddatasvc", "${data_service_path}/service/udmf:udmf_server", @@ -1609,7 +1618,7 @@ ohos_unittest("BootStrapMockTest") { deps = [ "${data_service_path}/adapter/communicator:distributeddata_communicator", "${data_service_path}/service/backup:distributeddata_backup", - "../../framework:distributeddatasvcfwk", + "${data_service_path}/framework:distributeddatasvcfwk", ] cflags = [ diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index c73a92d27..f62d10e4d 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -45,7 +45,7 @@ #include "metadata/store_meta_data_local.h" #include "mock/db_store_mock.h" #include "mock/general_store_mock.h" -#include "network_delegate.h" +#include "network/network_delegate.h" #include "network_delegate_mock.h" #include "rdb_query.h" #include "rdb_service.h" diff --git a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp index 7f1ca2f0f..0a501550d 100644 --- a/services/distributeddataservice/service/test/cloud_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/cloud_service_impl_test.cpp @@ -42,7 +42,7 @@ #include "mock/db_store_mock.h" #include "mock/general_store_mock.h" #include "model/component_config.h" -#include "network_delegate.h" +#include "network/network_delegate.h" #include "network_delegate_mock.h" #include "rdb_query.h" #include "rdb_service.h" diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index 266963ec3..55b263a74 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -20,11 +20,6 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { module_out_path = "datamgr_service/datamgr_service" include_dirs = [ - "${data_service_path}/adapter/include", - "${data_service_path}/app/src", - "${data_service_path}/framework/include", - "${data_service_path}/service/backup/include", - "${data_service_path}/service/bootstrap/include", "${data_service_path}/service/cloud", "${data_service_path}/service/common", "${data_service_path}/service/config/include", @@ -35,24 +30,9 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "${data_service_path}/service/object", "${data_service_path}/service/permission/include", "${data_service_path}/service/rdb", - "${kv_store_common_path}", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include", - "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include", - "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include", - "${kv_store_distributeddb_path}", - "${kv_store_distributeddb_path}/include/", - "${kv_store_distributeddb_path}/interfaces/include/", - "${kv_store_distributeddb_path}/interfaces/include/relational", - "${dataobject_path}/frameworks/innerkitsimpl/include", - "${relational_store_path}/interfaces/inner_api/cloud_data/include", - "${relational_store_path}/interfaces/inner_api/rdb/include", - "${relational_store_path}/interfaces/inner_api/common_type/include", - "//third_party/json/single_include", - "${data_service_path}/adapter/include/communicator", ] - fuzz_config_file = - "${data_service_path}/service/test/fuzztest/cloudservicestub_fuzzer" + fuzz_config_file = "${data_service_path}/service/test/fuzztest/cloudservicestub_fuzzer" cflags = [ "-g", @@ -69,6 +49,7 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", + "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/network:distributeddata_network", "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "${data_service_path}/adapter/utils:distributeddata_utils", @@ -81,10 +62,6 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { ] external_deps = [ - "ability_base:want", - "ability_base:zuri", - "ability_runtime:ability_manager", - "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtoken_setproc", "access_token:libtokenid_sdk", @@ -95,9 +72,9 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "device_manager:devicemanagersdk", "hicollie:libhicollie", "hilog:libhilog", - "hisysevent:libhisysevent", "huks:libhukssdk", "ipc:ipc_core", + "kv_store:datamgr_common", "kv_store:distributeddata_inner", "kv_store:distributeddata_mgr", "relational_store:native_rdb", diff --git a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn index 6eb31a8dd..d8f90d832 100644 --- a/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/rdbservicestub_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", + "${data_service_path}/adapter/dfx:distributeddata_dfx", "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", @@ -92,7 +93,6 @@ ohos_fuzztest("RdbServiceStubFuzzTest") { "device_manager:devicemanagersdk", "hicollie:libhicollie", "hilog:libhilog", - "hisysevent:libhisysevent", "huks:libhukssdk", "ipc:ipc_core", "kv_store:distributeddata_inner", diff --git a/services/distributeddataservice/service/test/kvdb_service_impl_test.cpp b/services/distributeddataservice/service/test/kvdb_service_impl_test.cpp index 7b7d7382e..778bff23b 100644 --- a/services/distributeddataservice/service/test/kvdb_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/kvdb_service_impl_test.cpp @@ -37,7 +37,7 @@ #include "mock/access_token_mock.h" #include "mock/meta_data_manager_mock.h" #include "nativetoken_kit.h" -#include "network_delegate.h" +#include "network/network_delegate.h" #include "network_delegate_mock.h" #include "token_setproc.h" #include "types.h" diff --git a/services/distributeddataservice/service/test/mock/account_delegate_mock.h b/services/distributeddataservice/service/test/mock/account_delegate_mock.h index fe8af6baf..1207f6392 100644 --- a/services/distributeddataservice/service/test/mock/account_delegate_mock.h +++ b/services/distributeddataservice/service/test/mock/account_delegate_mock.h @@ -18,7 +18,7 @@ #include #include -#include "account_delegate.h" +#include "account/account_delegate.h" namespace OHOS { namespace DistributedData { class AccountDelegateMock : public AccountDelegate { diff --git a/services/distributeddataservice/service/test/mock/network_delegate_mock.h b/services/distributeddataservice/service/test/mock/network_delegate_mock.h index 5e199efbe..0fcea3d28 100644 --- a/services/distributeddataservice/service/test/mock/network_delegate_mock.h +++ b/services/distributeddataservice/service/test/mock/network_delegate_mock.h @@ -15,7 +15,7 @@ #ifndef OHOS_NETWORK_DELEGATE_MOCK_H #define OHOS_NETWORK_DELEGATE_MOCK_H -#include "network_delegate.h" +#include "network/network_delegate.h" namespace OHOS { namespace DistributedData { diff --git a/services/distributeddataservice/service/udmf/store/store_account_observer.h b/services/distributeddataservice/service/udmf/store/store_account_observer.h index f7ebd8f7c..3d50570b9 100644 --- a/services/distributeddataservice/service/udmf/store/store_account_observer.h +++ b/services/distributeddataservice/service/udmf/store/store_account_observer.h @@ -15,7 +15,7 @@ #ifndef STORE_ACCOUNT_OBSERVER_H #define STORE_ACCOUNT_OBSERVER_H -#include "account_delegate.h" +#include "account/account_delegate.h" namespace OHOS { namespace UDMF { class RuntimeStoreAccountObserver : public DistributedData::AccountDelegate::Observer { diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 42ef97a5d..45fb4f7ee 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -32,7 +32,7 @@ #include "metadata/store_meta_data.h" #include "metadata/meta_data_manager.h" #include "preprocess_utils.h" -#include "reporter.h" +#include "dfx/reporter.h" #include "store_account_observer.h" #include "system_ability_definition.h" #include "uri_permission_manager.h" -- Gitee From 16301f78730b5623e56bacae3115a5ec26259da9 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Thu, 8 May 2025 17:26:37 +0800 Subject: [PATCH 4/4] fix Signed-off-by: htt1997 --- .../adapter/bundle_mgr/BUILD.gn | 58 ------------------- .../adapter/bundle_mgr/bundle_mgr_adapter.cpp | 40 ------------- .../adapter/bundle_mgr/bundle_mgr_adapter.h | 31 ---------- .../service/rdb/BUILD.gn | 1 - .../service/rdb/rdb_service_impl.cpp | 19 +++--- .../service/rdb/rdb_service_impl.h | 3 +- .../service/rdb/rdb_service_stub.cpp | 5 +- .../service/test/rdb_service_impl_test.cpp | 6 +- 8 files changed, 21 insertions(+), 142 deletions(-) delete mode 100644 services/distributeddataservice/adapter/bundle_mgr/BUILD.gn delete mode 100644 services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp delete mode 100644 services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h diff --git a/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn b/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn deleted file mode 100644 index 3ea018ef3..000000000 --- a/services/distributeddataservice/adapter/bundle_mgr/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# 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. -import("//build/ohos.gni") -import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") - -config("module_public_config") { - visibility = [ ":*" ] - include_dirs = [ "${data_service_path}/adapter" ] -} - -ohos_source_set("distributeddata_bundle_mgr") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - boundary_sanitize = true - ubsan = true - } - sources = [] - cflags_cc = [ - "-fvisibility=hidden", - "-Oz", - "-fstack-protector-strong", - ] - - public_configs = [ ":module_public_config" ] - cflags = [ - "-fdata-sections", - "-ffunction-sections", - "-Werror", - "-Wno-multichar", - "-Wno-c99-designator", - "-D_LIBCPP_HAS_COND_CLOCKWAIT", - "-Oz", - "-fstack-protector-strong", - ] - - external_deps = [ "kv_store:datamgr_common" ] - sources += [ "bundle_mgr_adapter.cpp" ] - external_deps += [ - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "hilog:libhilog", - ] - subsystem_name = "distributeddatamgr" - part_name = "datamgr_service" -} diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp deleted file mode 100644 index 8e2340f58..000000000 --- a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - */ - -#define LOG_TAG "bundle_mgr_adapter" -#include "bundle_mgr/bundle_mgr_adapter.h" -#include "bundle_mgr_client.h" -#include "log_print.h" -using namespace OHOS::AppExecFwk; -namespace OHOS::DistributedData { - -BundleMgrAdapter &BundleMgrAdapter::GetInstance() -{ - static BundleMgrAdapter instance; - return instance; -} - -std::string BundleMgrAdapter::GetBundleName(int32_t uid) -{ - BundleMgrClient client; - std::string bundleName; - auto code = client.GetNameForUid(uid, bundleName); - if (code != 0) { - ZLOGE("failed. uid:%{public}d, code:%{public}d", uid, code); - return ""; - } - return bundleName; -} -} // namespace OHOS::DistributedData \ No newline at end of file diff --git a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h b/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h deleted file mode 100644 index e955a6fba..000000000 --- a/services/distributeddataservice/adapter/bundle_mgr/bundle_mgr_adapter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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_DATAMGR_BUNDLE_MANAGER_ADAPTER_H -#define DISTRIBUTEDDATAMGR_DATAMGR_BUNDLE_MANAGER_ADAPTER_H - -#include -#include -#include "visibility.h" - -namespace OHOS { -namespace DistributedData { -class API_EXPORT BundleMgrAdapter { -public: - static BundleMgrAdapter &GetInstance(); - std::string GetBundleName(int32_t uid); -}; -} // namespace DistributedData -} // namespace OHOS -#endif //DISTRIBUTEDDATAMGR_DATAMGR_BUNDLE_MANAGER_ADAPTER_H diff --git a/services/distributeddataservice/service/rdb/BUILD.gn b/services/distributeddataservice/service/rdb/BUILD.gn index db6465e9b..9c126c795 100644 --- a/services/distributeddataservice/service/rdb/BUILD.gn +++ b/services/distributeddataservice/service/rdb/BUILD.gn @@ -66,7 +66,6 @@ ohos_source_set("distributeddata_rdb") { ] deps = [ - "${data_service_path}/adapter/bundle_mgr:distributeddata_bundle_mgr", "${data_service_path}/service/bootstrap:distributeddata_bootstrap", "${data_service_path}/service/common:distributeddata_common", "${data_service_path}/service/crypto:distributeddata_crypto", diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index d5e50f754..5dc157893 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -18,7 +18,6 @@ #include "abs_rdb_predicates.h" #include "accesstoken_kit.h" #include "account/account_delegate.h" -#include "bundle_mgr/bundle_mgr_adapter.h" #include "changeevent/remote_change_event.h" #include "checker/checker_manager.h" #include "cloud/change_event.h" @@ -232,16 +231,22 @@ bool RdbServiceImpl::CheckAccess(const std::string& bundleName, const std::strin return !CheckerManager::GetInstance().GetAppId(storeInfo).empty(); } -std::string RdbServiceImpl::ObtainDistributedTableName(const std::string &device, const std::string &table) +std::string RdbServiceImpl::ObtainDistributedTableName(const RdbSyncerParam ¶m, const std::string &device, + const std::string &table) { - ZLOGI("device=%{public}s table=%{public}s", Anonymous::Change(device).c_str(), Anonymous::Change(table).c_str()); - auto uid = IPCSkeleton::GetCallingUid(); - auto bundleName = BundleMgrAdapter::GetInstance().GetBundleName(uid); + if (!CheckAccess(param.bundleName_, "")) { + ZLOGE("bundleName:%{public}s. Permission error", param.bundleName_.c_str()); + return ""; + } auto tokenId = IPCSkeleton::GetCallingTokenID(); - auto appId = CheckerManager::GetInstance().GetAppId({ uid, tokenId, bundleName }); + std::string appId = " "; + if (AccessTokenKit::GetTokenTypeFlag(tokenId) == Security::AccessToken::TOKEN_HAP) { + auto uid = IPCSkeleton::GetCallingUid(); + appId = CheckerManager::GetInstance().GetAppId({ uid, tokenId, param.bundleName_ }); + } auto uuid = DmAdapter::GetInstance().CalcClientUuid(appId, DmAdapter::GetInstance().ToUUID(device)); if (uuid.empty()) { - ZLOGE("get uuid failed, bundle:%{public}s, deviceId:%{public}s, table:%{public}s", bundleName.c_str(), + ZLOGE("get uuid failed, bundle:%{public}s, deviceId:%{public}s, table:%{public}s", param.bundleName_.c_str(), Anonymous::Change(device).c_str(), Anonymous::Change(table).c_str()); return ""; } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index e58c6618f..901833eef 100755 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -53,7 +53,8 @@ public: virtual ~RdbServiceImpl(); /* IPC interface */ - std::string ObtainDistributedTableName(const std::string& device, const std::string& table) override; + std::string ObtainDistributedTableName(const RdbSyncerParam ¶m, const std::string &device, + const std::string &table) override; int32_t InitNotifier(const RdbSyncerParam ¶m, sptr notifier) override; diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index fd7ee6ee4..f52549c1f 100755 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -28,14 +28,15 @@ namespace OHOS::DistributedRdb { using Anonymous = DistributedData::Anonymous; int32_t RdbServiceStub::OnRemoteObtainDistributedTableName(MessageParcel &data, MessageParcel &reply) { + RdbSyncerParam param; std::string device; std::string table; - if (!ITypesUtil::Unmarshal(data, device, table)) { + if (!ITypesUtil::Unmarshal(data, param, device, table)) { ZLOGE("Unmarshal device:%{public}s table:%{public}s", Anonymous::Change(device).c_str(), table.c_str()); return IPC_STUB_INVALID_DATA_ERR; } - std::string distributedTableName = ObtainDistributedTableName(device, table); + std::string distributedTableName = ObtainDistributedTableName(param, device, table); int32_t status = distributedTableName.empty() ? RDB_ERROR : RDB_OK; if (!ITypesUtil::Marshal(reply, status, distributedTableName)) { ZLOGE("Marshal distributedTableName:%{public}s", distributedTableName.c_str()); diff --git a/services/distributeddataservice/service/test/rdb_service_impl_test.cpp b/services/distributeddataservice/service/test/rdb_service_impl_test.cpp index 7d6416dcb..07a173554 100644 --- a/services/distributeddataservice/service/test/rdb_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/rdb_service_impl_test.cpp @@ -239,7 +239,8 @@ HWTEST_F(RdbServiceImplTest, ResolveAutoLaunch006, TestSize.Level0) EXPECT_EQ(MetaDataManager::GetInstance().SaveMeta(metaData_.GetKey(), metaData_, false), true); RdbServiceImpl service; auto deviceId = DmAdapter::GetInstance().GetLocalDevice().uuid; - auto ret = service.ObtainDistributedTableName(deviceId, TEST_STORE); + RdbSyncerParam param; + auto ret = service.ObtainDistributedTableName(param, deviceId, TEST_STORE); EXPECT_GT(ret.length(), 0); EXPECT_EQ(MetaDataManager::GetInstance().DelMeta(metaData_.GetKey(), false), true); } @@ -255,7 +256,8 @@ HWTEST_F(RdbServiceImplTest, ObtainDistributedTableName001, TestSize.Level0) { EXPECT_EQ(MetaDataManager::GetInstance().SaveMeta(metaData_.GetKey(), metaData_, false), true); RdbServiceImpl service; - auto ret = service.ObtainDistributedTableName("invalid_device_id", TEST_STORE); + RdbSyncerParam param; + auto ret = service.ObtainDistributedTableName(param, "invalid_device_id", TEST_STORE); EXPECT_EQ(ret.length(), 0); EXPECT_EQ(MetaDataManager::GetInstance().DelMeta(metaData_.GetKey(), false), true); } -- Gitee