From 3fc5f17b0604f10c2fc87a30c01e9d52618c88cc Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Tue, 9 Sep 2025 10:43:50 +0800 Subject: [PATCH 1/2] fix: Remove redundant code Signed-off-by: weishaoxiong --- .../adapter/dfx/BUILD.gn | 9 - .../adapter/dfx/src/dfx_code_constant.h | 32 +- .../dfx/src/fault/cloud_sync_fault_impl.h | 12 - .../src/fault/communication_fault_impl.cpp | 30 -- .../dfx/src/fault/communication_fault_impl.h | 44 -- .../dfx/src/fault/database_fault_impl.cpp | 41 -- .../dfx/src/fault/database_fault_impl.h | 44 -- .../adapter/dfx/src/fault/fault_reporter.cpp | 21 - .../dfx/src/fault/runtime_fault_impl.cpp | 30 -- .../dfx/src/fault/runtime_fault_impl.h | 42 -- .../dfx/src/fault/service_fault_impl.cpp | 30 -- .../dfx/src/fault/service_fault_impl.h | 43 -- .../adapter/dfx/src/hiview_adapter.cpp | 424 ------------------ .../adapter/dfx/src/hiview_adapter.h | 29 -- .../adapter/dfx/src/reporter_impl.cpp | 72 --- .../api_performance_statistic_impl.cpp | 31 -- .../api_performance_statistic_impl.h | 36 -- .../src/statistic/database_statistic_impl.cpp | 30 -- .../src/statistic/database_statistic_impl.h | 35 -- .../dfx/src/statistic/statistic_reporter.cpp | 21 - .../src/statistic/traffic_statistic_impl.cpp | 30 -- .../src/statistic/traffic_statistic_impl.h | 35 -- .../src/statistic/visit_statistic_impl.cpp | 30 -- .../dfx/src/statistic/visit_statistic_impl.h | 35 -- .../fake/hiview/include/fake_hiview.h | 2 +- .../adapter/include/dfx/reporter_impl.h | 10 - .../adapter/schema_helper/BUILD.gn | 1 - services/distributeddataservice/app/BUILD.gn | 1 - .../include/dfx/behaviour_reporter.h | 1 + .../include/dfx/db_meta_callback_delegate.h | 41 -- .../framework/include/dfx/dfx_types.h | 141 +----- .../framework/include/dfx/fault_reporter.h | 4 +- .../framework/include/dfx/reporter.h | 9 - .../service/cloud/sync_manager.h | 2 +- .../service/data_share/BUILD.gn | 1 - .../service/rdb/BUILD.gn | 1 - .../service/rdb/rdb_service_impl.h | 8 +- .../service/udmf/BUILD.gn | 1 - 38 files changed, 30 insertions(+), 1379 deletions(-) delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp delete mode 100644 services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h delete mode 100644 services/distributeddataservice/framework/include/dfx/db_meta_callback_delegate.h diff --git a/services/distributeddataservice/adapter/dfx/BUILD.gn b/services/distributeddataservice/adapter/dfx/BUILD.gn index 1b2cc6e71..007569699 100644 --- a/services/distributeddataservice/adapter/dfx/BUILD.gn +++ b/services/distributeddataservice/adapter/dfx/BUILD.gn @@ -25,23 +25,14 @@ ohos_source_set("distributeddata_dfx") { sources = [ "src/behaviour/behaviour_reporter_impl.cpp", "src/fault/cloud_sync_fault_impl.cpp", - "src/fault/communication_fault_impl.cpp", - "src/fault/database_fault_impl.cpp", - "src/fault/runtime_fault_impl.cpp", - "src/fault/service_fault_impl.cpp", "src/hiview_adapter.cpp", "src/radar_reporter.cpp", "src/reporter_impl.cpp", - "src/statistic/api_performance_statistic_impl.cpp", - "src/statistic/database_statistic_impl.cpp", - "src/statistic/traffic_statistic_impl.cpp", - "src/statistic/visit_statistic_impl.cpp", ] include_dirs = [ "./src", "./src/fault", - "./src/statistic", "../include/dfx", ] diff --git a/services/distributeddataservice/adapter/dfx/src/dfx_code_constant.h b/services/distributeddataservice/adapter/dfx/src/dfx_code_constant.h index 1ab832141..7d42166d9 100644 --- a/services/distributeddataservice/adapter/dfx/src/dfx_code_constant.h +++ b/services/distributeddataservice/adapter/dfx/src/dfx_code_constant.h @@ -18,21 +18,21 @@ class DfxCodeConstant { public: - static inline const int SERVICE_FAULT = 950001100; - static inline const int RUNTIME_FAULT = 950001101; - static inline const int DATABASE_FAULT = 950001102; - static inline const int COMMUNICATION_FAULT = 950001103; - static inline const int DATABASE_STATISTIC = 950001104; - static inline const int VISIT_STATISTIC = 950001105; - static inline const int TRAFFIC_STATISTIC = 950001106; - static inline const int DATABASE_PERFORMANCE_STATISTIC = 950001107; - static inline const int API_PERFORMANCE_STATISTIC = 950001110; - static inline const int API_PERFORMANCE_INTERFACE = 950001111; - static inline const int DATABASE_SYNC_FAILED = 950001112; - static inline const int DATABASE_CORRUPTED_FAILED = 950001113; - static inline const int DATABASE_REKEY_FAILED = 950001114; - static inline const int DATABASE_BEHAVIOUR = 950001115; - static inline const int UDMF_DATA_BEHAVIOR = 950001116; - static inline const int ARKDATA_CLOUD_SYNC_FAULT = 950001117; + static const int SERVICE_FAULT = 950001100; + static const int RUNTIME_FAULT = 950001101; + static const int DATABASE_FAULT = 950001102; + static const int COMMUNICATION_FAULT = 950001103; + static const int DATABASE_STATISTIC = 950001104; + static const int VISIT_STATISTIC = 950001105; + static const int TRAFFIC_STATISTIC = 950001106; + static const int DATABASE_PERFORMANCE_STATISTIC = 950001107; + static const int API_PERFORMANCE_STATISTIC = 950001110; + static const int API_PERFORMANCE_INTERFACE = 950001111; + static const int DATABASE_SYNC_FAILED = 950001112; + static const int DATABASE_CORRUPTED_FAILED = 950001113; + static const int DATABASE_REKEY_FAILED = 950001114; + static const int DATABASE_BEHAVIOUR = 950001115; + static const int UDMF_DATA_BEHAVIOR = 950001116; + static const int ARKDATA_CLOUD_SYNC_FAULT = 950001117; }; #endif // DISTRIBUTEDDATAMGR_DFX_CODE_CONSTANT_H 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 54e6b60b1..9eb320007 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 @@ -25,18 +25,6 @@ namespace DistributedDataDfx { class CloudSyncFaultImpl : public FaultReporter { public: virtual ~CloudSyncFaultImpl() {} - ReportStatus Report(const FaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const DBFaultMsg &ms) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const struct CommFaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; ReportStatus Report(const ArkDataFaultMsg &msg) override; void SetThreadPool(std::shared_ptr executors); diff --git a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp deleted file mode 100644 index ea5b488f5..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "communication_fault_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus CommunicationFaultImpl::Report(const CommFaultMsg &msg) -{ - HiViewAdapter::ReportCommFault(DfxCodeConstant::DATABASE_SYNC_FAILED, msg, executors_); - return ReportStatus::SUCCESS; -} -void CommunicationFaultImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h deleted file mode 100644 index 19673336e..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 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_COMMUNICATION_FAULT_IMPL_H -#define DISTRIBUTEDDATAMGR_COMMUNICATION_FAULT_IMPL_H - -#include "dfx/dfx_types.h" -#include "dfx/fault_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class CommunicationFaultImpl : public FaultReporter { -public: - virtual ~CommunicationFaultImpl() {} - ReportStatus Report(const FaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const DBFaultMsg &ms) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const struct CommFaultMsg &msg) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_COMMUNICATION_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp deleted file mode 100644 index 9369a31b5..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "database_fault_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus DatabaseFaultImpl::Report(const DBFaultMsg &msg) -{ - int eventID; - if (msg.errorType == Fault::DF_DB_CORRUPTED) { - eventID = DfxCodeConstant::DATABASE_CORRUPTED_FAILED; - } else if (msg.errorType == Fault::DF_DB_REKEY_FAILED) { - eventID = DfxCodeConstant::DATABASE_REKEY_FAILED; - } else if (msg.errorType == Fault::DF_DB_DAMAGE) { - eventID = DfxCodeConstant::DATABASE_FAULT; - } else { - return ReportStatus::ERROR; - } - - HiViewAdapter::ReportDBFault(eventID, msg, executors_); - return ReportStatus::SUCCESS; -} -void DatabaseFaultImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h deleted file mode 100644 index 1185dce0e..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 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_DATABASE_FAULT_IMPL_H -#define DISTRIBUTEDDATAMGR_DATABASE_FAULT_IMPL_H - -#include "dfx/fault_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class DatabaseFaultImpl : public FaultReporter { -public: - virtual ~DatabaseFaultImpl() {} - ReportStatus Report(const FaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const CommFaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const DBFaultMsg &msg) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // 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 deleted file mode 100644 index 1a7a35fd0..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dfx/fault_reporter.h" - -namespace OHOS { -namespace DistributedDataDfx { -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp deleted file mode 100644 index 3e2dae52d..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "runtime_fault_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus RuntimeFaultImpl::Report(const FaultMsg &msg) -{ - HiViewAdapter::ReportFault(DfxCodeConstant::RUNTIME_FAULT, msg, executors_); - return ReportStatus::SUCCESS; -} -void RuntimeFaultImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h deleted file mode 100644 index ae7f1a3e8..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021 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_RUNTIME_FAULT_IMPL_H -#define DISTRIBUTEDDATAMGR_RUNTIME_FAULT_IMPL_H -#include "dfx/fault_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class RuntimeFaultImpl : public FaultReporter { -public: - virtual ~RuntimeFaultImpl() {} - ReportStatus Report(const CommFaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const DBFaultMsg &ms) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const FaultMsg &msg) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_RUNTIME_FAULT_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp deleted file mode 100644 index b1eb464ff..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "service_fault_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus ServiceFaultImpl::Report(const OHOS::DistributedDataDfx::FaultMsg &msg) -{ - HiViewAdapter::ReportFault(DfxCodeConstant::SERVICE_FAULT, msg, executors_); - return ReportStatus::SUCCESS; -} -void ServiceFaultImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h deleted file mode 100644 index df665d0c2..000000000 --- a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 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_SERVICE_FAULT_IMPL_H -#define DISTRIBUTEDDATAMGR_SERVICE_FAULT_IMPL_H - -#include "dfx/fault_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class ServiceFaultImpl : public FaultReporter { -public: - virtual ~ServiceFaultImpl() {} - ReportStatus Report(const CommFaultMsg &msg) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const DBFaultMsg &ms) override - { - return ReportStatus::SUCCESS; - }; - ReportStatus Report(const FaultMsg &msg) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // 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 35e0ceaff..4b7184a5d 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp @@ -30,26 +30,11 @@ using Anonymous = DistributedData::Anonymous; namespace { constexpr const char *DATAMGR_DOMAIN = "DISTDATAMGR"; // fault key -constexpr const char *FAULT_TYPE = "FAULT_TYPE"; -constexpr const char *MODULE_NAME = "MODULE_NAME"; -constexpr const char *INTERFACE_NAME = "INTERFACE_NAME"; -constexpr const char *ERROR_TYPE = "ERROR_TYPE"; constexpr const char *SYNC_ERROR_INFO = "SYNC_ERROR_INFO"; // Database statistic constexpr const char *USER_ID = "ANONYMOUS_UID"; constexpr const char *APP_ID = "APP_ID"; constexpr const char *STORE_ID = "STORE_ID"; -constexpr const char *DB_SIZE = "DB_SIZE"; -// interface visit statistic -constexpr const char *TIMES = "TIMES"; -constexpr const char *DEVICE_ID = "ANONYMOUS_DID"; -constexpr const char *SEND_SIZE = "SEND_SIZE"; -constexpr const char *RECEIVED_SIZE = "RECEIVED_SIZE"; -constexpr const char *AVERAGE_TIMES = "AVERAGE_TIME"; -constexpr const char *WORST_TIMES = "WORST_TIME"; -constexpr const char *INTERFACES = "INTERFACES"; -constexpr const char *TAG = "TAG"; -constexpr const char *POWERSTATS = "PowerStats"; // behaviour key constexpr const char *BEHAVIOUR_INFO = "BEHAVIOUR_INFO"; constexpr const char *CHANNEL = "CHANNEL"; @@ -77,137 +62,6 @@ const std::map EVENT_COVERT_TABLE = { { DfxCodeConstant::ARKDATA_CLOUD_SYNC_FAULT, "ARKDATA_CLOUD_SYNC_FAULT" }, }; } -std::mutex HiViewAdapter::visitMutex_; -std::map> HiViewAdapter::visitStat_; - -std::mutex HiViewAdapter::trafficMutex_; -std::map> HiViewAdapter::trafficStat_; - -std::mutex HiViewAdapter::dbMutex_; -std::map> HiViewAdapter::dbStat_; - -std::mutex HiViewAdapter::apiPerformanceMutex_; -std::map> HiViewAdapter::apiPerformanceStat_; - -bool HiViewAdapter::running_ = false; -std::mutex HiViewAdapter::runMutex_; - -void HiViewAdapter::ReportFault(int dfxCode, const FaultMsg &msg, std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, msg]() { - struct HiSysEventParam params[] = { - { .name = { *FAULT_TYPE }, - .t = HISYSEVENT_INT32, - .v = { .i32 = static_cast(msg.faultType) }, - .arraySize = 0 }, - { .name = { *MODULE_NAME }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.moduleName.c_str()) }, - .arraySize = 0 }, - { .name = { *INTERFACE_NAME }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.interfaceName.c_str()) }, - .arraySize = 0 }, - { .name = { *ERROR_TYPE }, - .t = HISYSEVENT_INT32, - .v = { .i32 = static_cast(msg.errorType) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(dfxCode).c_str(), - HISYSEVENT_FAULT, - params, - sizeof(params) / sizeof(params[0]) - ); - }); - executors->Execute(std::move(task)); -} - -void HiViewAdapter::ReportDBFault(int dfxCode, const DBFaultMsg &msg, std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, msg]() { - std::string storeId = Anonymous::Change(msg.storeId); - struct HiSysEventParam params[] = { - { .name = { *APP_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.appId.c_str()) }, - .arraySize = 0 }, - { .name = { *STORE_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(storeId.c_str()) }, - .arraySize = 0 }, - { .name = { *MODULE_NAME }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.moduleName.c_str()) }, - .arraySize = 0 }, - { .name = { *ERROR_TYPE }, - .t = HISYSEVENT_INT32, - .v = { .i32 = static_cast(msg.errorType) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(dfxCode).c_str(), - HISYSEVENT_FAULT, - params, - sizeof(params) / sizeof(params[0]) - ); - }); - executors->Execute(std::move(task)); -} - -void HiViewAdapter::ReportCommFault(int dfxCode, const CommFaultMsg &msg, std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool ::Task task([dfxCode, msg]() { - std::string message; - std::string storeId = Anonymous::Change(msg.storeId); - for (size_t i = 0; i < msg.deviceId.size(); i++) { - message.append("No: ").append(std::to_string(i)) - .append(" sync to device: ").append(msg.deviceId[i]) - .append(" has error, errCode:").append(std::to_string(msg.errorCode[i])).append(". "); - } - struct HiSysEventParam params[] = { - { .name = { *USER_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.userId.c_str()) }, - .arraySize = 0 }, - { .name = { *APP_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(msg.appId.c_str()) }, - .arraySize = 0 }, - { .name = { *STORE_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(storeId.c_str()) }, - .arraySize = 0 }, - { .name = { *SYNC_ERROR_INFO }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(message.c_str()) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(dfxCode).c_str(), - HISYSEVENT_FAULT, - params, - sizeof(params) / sizeof(params[0]) - ); - }); - executors->Execute(std::move(task)); -} - void HiViewAdapter::ReportArkDataFault(int dfxCode, const ArkDataFaultMsg &msg, std::shared_ptr executors) { if (executors == nullptr) { @@ -278,228 +132,6 @@ void HiViewAdapter::ReportBehaviour(int dfxCode, const BehaviourMsg &msg, std::s executors->Execute(std::move(task)); } -void HiViewAdapter::ReportDatabaseStatistic(int dfxCode, const DbStat &stat, std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, stat]() { - std::lock_guard lock(dbMutex_); - if (!dbStat_.count(stat.GetKey())) { - dbStat_.insert({stat.GetKey(), {stat, 0, dfxCode}}); - } - }); - executors->Execute(std::move(task)); - StartTimerThread(executors); -} - -void HiViewAdapter::ReportDbSize(const StatisticWrap &stat) -{ - uint64_t dbSize; - if (!stat.val.delegate->GetKvStoreDiskSize(stat.val.storeId, dbSize)) { - return; - } - - ValueHash vh; - std::string userId; - if (!vh.CalcValueHash(stat.val.userId, userId)) { - return; - } - std::string storeId = Anonymous::Change(stat.val.storeId); - struct HiSysEventParam params[] = { - { .name = { *USER_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(userId.c_str()) }, - .arraySize = 0 }, - { .name = { *APP_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(stat.val.appId.c_str()) }, - .arraySize = 0 }, - { .name = { *STORE_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(storeId.c_str()) }, - .arraySize = 0 }, - { .name = { *DB_SIZE }, .t = HISYSEVENT_UINT64, .v = { .ui64 = dbSize }, .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(stat.code).c_str(), - HISYSEVENT_STATISTIC, - params, - sizeof(params) / sizeof(params[0]) - ); -} - -void HiViewAdapter::InvokeDbSize() -{ - std::lock_guard lock(dbMutex_); - for (auto const &kv : dbStat_) { - if (kv.second.val.delegate == nullptr) { - continue; - } - // device coordinate for single version database - if (!kv.second.val.storeId.empty()) { - ReportDbSize(kv.second); - continue; - } - // below codes for multiple version database - std::vector storeInfos; - kv.second.val.delegate->GetKvStoreKeys(storeInfos); - if (storeInfos.empty()) { - continue; - } - for (auto const &storeInfo : storeInfos) { - ReportDbSize({{storeInfo.userId, storeInfo.appId, storeInfo.storeId, 0, - kv.second.val.delegate}, 0, kv.second.code}); - } - } - dbStat_.clear(); -} - -void HiViewAdapter::ReportTrafficStatistic(int dfxCode, const TrafficStat &stat, - std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, stat]() { - std::lock_guard lock(trafficMutex_); - auto it = trafficStat_.find(stat.GetKey()); - if (it != trafficStat_.end()) { - it->second.val.receivedSize += stat.receivedSize; - it->second.val.sendSize += stat.sendSize; - } else { - trafficStat_.insert({stat.GetKey(), {stat, 0, dfxCode}}); - } - }); - executors->Execute(std::move(task)); - StartTimerThread(executors); -} - -void HiViewAdapter::InvokeTraffic() -{ - std::lock_guard lock(trafficMutex_); - ValueHash vh; - for (auto const &kv : trafficStat_) { - std::string deviceId; - if (!vh.CalcValueHash(kv.second.val.deviceId, deviceId)) { - continue; - } - std::string devId = Anonymous::Change(deviceId); - struct HiSysEventParam params[] = { - { .name = { *TAG }, .t = HISYSEVENT_STRING, .v = { .s = const_cast(POWERSTATS) }, .arraySize = 0 }, - { .name = { *APP_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(kv.second.val.appId.c_str()) }, - .arraySize = 0 }, - { .name = { *DEVICE_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(devId.c_str()) }, - .arraySize = 0 }, - { .name = { *SEND_SIZE }, - .t = HISYSEVENT_INT64, - .v = { .i64 = static_cast(kv.second.val.sendSize) }, - .arraySize = 0 }, - { .name = { *RECEIVED_SIZE }, - .t = HISYSEVENT_INT64, - .v = { .i64 = static_cast(kv.second.val.receivedSize) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(kv.second.code).c_str(), - HISYSEVENT_STATISTIC, - params, - sizeof(params) / sizeof(params[0]) - ); - } - trafficStat_.clear(); -} - -void HiViewAdapter::ReportVisitStatistic(int dfxCode, const VisitStat &stat, std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, stat]() { - std::lock_guard lock(visitMutex_); - auto it = visitStat_.find(stat.GetKey()); - if (it == visitStat_.end()) { - visitStat_.insert({stat.GetKey(), {stat, 1, dfxCode}}); - } else { - it->second.times++; - } - }); - executors->Execute(std::move(task)); - StartTimerThread(executors); -} - -void HiViewAdapter::InvokeVisit() -{ - std::lock_guard lock(visitMutex_); - for (auto const &kv : visitStat_) { - struct HiSysEventParam params[] = { - { .name = { *TAG }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(POWERSTATS) }, - .arraySize = 0 }, - { .name = { *APP_ID }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(kv.second.val.appId.c_str()) }, - .arraySize = 0 }, - { .name = { *INTERFACE_NAME }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(kv.second.val.interfaceName.c_str()) }, - .arraySize = 0 }, - { .name = { *BEHAVIOUR_INFO }, - .t = HISYSEVENT_INT64, - .v = { .i64 = static_cast(kv.second.times) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(kv.second.code).c_str(), - HISYSEVENT_STATISTIC, - params, - sizeof(params) / sizeof(params[0]) - ); - } - visitStat_.clear(); -} - -void HiViewAdapter::ReportApiPerformanceStatistic(int dfxCode, const ApiPerformanceStat &stat, - std::shared_ptr executors) -{ - if (executors == nullptr) { - ZLOGW("executors is nullptr!"); - return; - } - ExecutorPool::Task task([dfxCode, stat]() { - std::lock_guard lock(apiPerformanceMutex_); - auto it = apiPerformanceStat_.find(stat.GetKey()); - if (it == apiPerformanceStat_.end()) { - apiPerformanceStat_.insert({stat.GetKey(), {stat, 1, dfxCode}}); // the init value of times is 1 - } else { - it->second.times++; - it->second.val.costTime = stat.costTime; - if (it->second.times > 0) { - it->second.val.averageTime = - (it->second.val.averageTime * static_cast(it->second.times - 1) + stat.costTime) - / it->second.times; - } - if (stat.costTime > it->second.val.worstTime) { - it->second.val.worstTime = stat.costTime; - } - } - }); - - executors->Execute(std::move(task)); - StartTimerThread(executors); -} - void HiViewAdapter::ReportUdmfBehaviour( int dfxCode, const UdmfBehaviourMsg &msg, std::shared_ptr executors) { @@ -545,62 +177,6 @@ void HiViewAdapter::ReportUdmfBehaviour( executors->Execute(std::move(task)); } -void HiViewAdapter::InvokeApiPerformance() -{ - std::string message; - message.append("["); - std::lock_guard lock(apiPerformanceMutex_); - for (auto const &kv : apiPerformanceStat_) { - message.append("{\"CODE\":\"").append(std::to_string(kv.second.code)).append("\",") - .append("\"").append(INTERFACE_NAME).append("\":\"").append(kv.second.val.interfaceName).append("\",") - .append("\"").append(TIMES).append("\":").append(std::to_string(kv.second.times)).append(",") - .append("\"").append(AVERAGE_TIMES).append("\":").append(std::to_string(kv.second.val.averageTime)) - .append(",").append("\"").append(WORST_TIMES).append("\":").append(std::to_string(kv.second.val.worstTime)) - .append("}"); - } - message.append("]"); - struct HiSysEventParam params[] = { - { .name = { *INTERFACES }, - .t = HISYSEVENT_STRING, - .v = { .s = const_cast(message.c_str()) }, - .arraySize = 0 }, - }; - OH_HiSysEvent_Write( - DATAMGR_DOMAIN, - CoverEventID(DfxCodeConstant::API_PERFORMANCE_STATISTIC).c_str(), - HISYSEVENT_STATISTIC, - params, - sizeof(params) / sizeof(params[0]) - ); - apiPerformanceStat_.clear(); - ZLOGI("DdsTrace interface: clean"); -} - -void HiViewAdapter::StartTimerThread(std::shared_ptr executors) -{ - if (running_) { - return; - } - std::lock_guard lock(runMutex_); - if (running_) { - return; - } - running_ = true; - auto interval = std::chrono::seconds(WAIT_TIME); - auto fun = []() { - time_t current = time(nullptr); - tm localTime = { 0 }; - tm *result = localtime_r(¤t, &localTime); - if ((result != nullptr) && (localTime.tm_hour == DAILY_REPORT_TIME)) { - InvokeDbSize(); - InvokeApiPerformance(); - } - InvokeTraffic(); - InvokeVisit(); - }; - executors->Schedule(fun, interval); -} - std::string HiViewAdapter::CoverEventID(int dfxCode) { std::string sysEventID; diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h index f54703866..b8f21b304 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h @@ -37,41 +37,12 @@ struct StatisticWrap { class HiViewAdapter { public: ~HiViewAdapter(); - static void ReportFault(int dfxCode, const FaultMsg &msg, std::shared_ptr executors); - static void ReportDBFault(int dfxCode, const DBFaultMsg &msg, std::shared_ptr executors); - static void ReportCommFault(int dfxCode, const CommFaultMsg &msg, std::shared_ptr executors); static void ReportArkDataFault(int dfxCode, const ArkDataFaultMsg &msg, std::shared_ptr executors); - static void ReportVisitStatistic(int dfxCode, const VisitStat &stat, std::shared_ptr executors); - static void ReportTrafficStatistic(int dfxCode, const TrafficStat &stat, std::shared_ptr executors); - static void ReportDatabaseStatistic(int dfxCode, const DbStat &stat, std::shared_ptr executors); - static void ReportApiPerformanceStatistic(int dfxCode, const ApiPerformanceStat &stat, - std::shared_ptr executors); static void ReportBehaviour(int dfxCode, const BehaviourMsg &msg, std::shared_ptr executors); static void ReportUdmfBehaviour(int dfxCode, const UdmfBehaviourMsg &msg, std::shared_ptr executors); - static void StartTimerThread(std::shared_ptr executors); private: - static std::mutex visitMutex_; - static std::map> visitStat_; - static void InvokeVisit(); - - static std::mutex trafficMutex_; - static std::map> trafficStat_; - static void InvokeTraffic(); - - static std::mutex dbMutex_; - static std::map> dbStat_; - static void InvokeDbSize(); - static void ReportDbSize(const StatisticWrap &stat); - - static std::mutex apiPerformanceMutex_; - static std::map> apiPerformanceStat_; - static void InvokeApiPerformance(); - static std::string CoverEventID(int dfxCode); -private: - static std::mutex runMutex_; - static bool running_; static const inline int DAILY_REPORT_TIME = 23; static const inline int WAIT_TIME = 1 * 60 * 60; // 1 hours }; diff --git a/services/distributeddataservice/adapter/dfx/src/reporter_impl.cpp b/services/distributeddataservice/adapter/dfx/src/reporter_impl.cpp index a8b142fa7..3fc479723 100644 --- a/services/distributeddataservice/adapter/dfx/src/reporter_impl.cpp +++ b/services/distributeddataservice/adapter/dfx/src/reporter_impl.cpp @@ -17,14 +17,6 @@ #include "behaviour/behaviour_reporter_impl.h" #include "fault/cloud_sync_fault_impl.h" -#include "fault/communication_fault_impl.h" -#include "fault/database_fault_impl.h" -#include "fault/runtime_fault_impl.h" -#include "fault/service_fault_impl.h" -#include "statistic/api_performance_statistic_impl.h" -#include "statistic/database_statistic_impl.h" -#include "statistic/traffic_statistic_impl.h" -#include "statistic/visit_statistic_impl.h" namespace OHOS { namespace DistributedDataDfx { @@ -39,27 +31,6 @@ bool ReporterImpl::Init() return true; } -FaultReporter* ReporterImpl::CommunicationFault() -{ - static CommunicationFaultImpl communicationFault; - communicationFault.SetThreadPool(executors_); - return &communicationFault; -} - -FaultReporter* ReporterImpl::DatabaseFault() -{ - static DatabaseFaultImpl databaseFault; - databaseFault.SetThreadPool(executors_); - return &databaseFault; -} - -FaultReporter* ReporterImpl::RuntimeFault() -{ - static RuntimeFaultImpl runtimeFault; - runtimeFault.SetThreadPool(executors_); - return &runtimeFault; -} - FaultReporter* ReporterImpl::CloudSyncFault() { static CloudSyncFaultImpl cloudSyncFault; @@ -67,41 +38,6 @@ FaultReporter* ReporterImpl::CloudSyncFault() return &cloudSyncFault; } -FaultReporter* ReporterImpl::ServiceFault() -{ - static ServiceFaultImpl serviceFault; - serviceFault.SetThreadPool(executors_); - return &serviceFault; -} - -StatisticReporter* ReporterImpl::TrafficStatistic() -{ - static TrafficStatisticImpl trafficStatistic; - trafficStatistic.SetThreadPool(executors_); - return &trafficStatistic; -} - -StatisticReporter* ReporterImpl::VisitStatistic() -{ - static VisitStatisticImpl visitStatistic; - visitStatistic.SetThreadPool(executors_); - return &visitStatistic; -} - -StatisticReporter* ReporterImpl::DatabaseStatistic() -{ - static DatabaseStatisticImpl databaseStatistic; - databaseStatistic.SetThreadPool(executors_); - return &databaseStatistic; -} - -StatisticReporter* ReporterImpl::ApiPerformanceStatistic() -{ - static ApiPerformanceStatisticImpl apiPerformanceStat; - apiPerformanceStat.SetThreadPool(executors_); - return &apiPerformanceStat; -} - BehaviourReporter* ReporterImpl::GetBehaviourReporter() { static BehaviourReporterImpl behaviourReporterImpl; @@ -113,15 +49,7 @@ void ReporterImpl::SetThreadPool(std::shared_ptr executors) { executors_ = executors; if (executors != nullptr) { - ServiceFault(); - RuntimeFault(); - DatabaseFault(); CloudSyncFault(); - CommunicationFault(); - DatabaseStatistic(); - VisitStatistic(); - TrafficStatistic(); - ApiPerformanceStatistic(); GetBehaviourReporter(); } } diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp deleted file mode 100644 index 0bf922a10..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "api_performance_statistic_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus ApiPerformanceStatisticImpl::Report(const ApiPerformanceStat &stat) -{ - HiViewAdapter::ReportApiPerformanceStatistic(DfxCodeConstant::API_PERFORMANCE_INTERFACE, stat, executors_); - return ReportStatus::SUCCESS; -} -void ApiPerformanceStatisticImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS - 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 deleted file mode 100644 index f5cdff361..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 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_API_PERFORMANCE_STATISTIC_IMPL_H -#define DISTRIBUTEDDATAMGR_API_PERFORMANCE_STATISTIC_IMPL_H - -#include "dfx/dfx_types.h" -#include "dfx/statistic_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class ApiPerformanceStatisticImpl : public StatisticReporter { -public: - virtual ~ApiPerformanceStatisticImpl() {} - ReportStatus Report(const ApiPerformanceStat &stat) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_API_PERFORMANCE_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp deleted file mode 100644 index 070e1828d..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "database_statistic_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus DatabaseStatisticImpl::Report(const DbStat &stat) -{ - HiViewAdapter::ReportDatabaseStatistic(DfxCodeConstant::DATABASE_STATISTIC, stat, executors_); - return ReportStatus::SUCCESS; -} -void DatabaseStatisticImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h deleted file mode 100644 index 453cd3dd4..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 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_DATABASE_STATISTIC_IMPL_H -#define DISTRIBUTEDDATAMGR_DATABASE_STATISTIC_IMPL_H - -#include "dfx/statistic_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class DatabaseStatisticImpl : public StatisticReporter { -public: - virtual ~DatabaseStatisticImpl() {} - ReportStatus Report(const DbStat &stat) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_DATABASE_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp deleted file mode 100644 index e611e4411..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dfx/statistic_reporter.h" - -namespace OHOS { -namespace DistributedDataDfx { -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp deleted file mode 100644 index 0ee80df40..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "traffic_statistic_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus TrafficStatisticImpl::Report(const TrafficStat &stat) -{ - HiViewAdapter::ReportTrafficStatistic(DfxCodeConstant::TRAFFIC_STATISTIC, stat, executors_); - return ReportStatus::SUCCESS; -} -void TrafficStatisticImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h deleted file mode 100644 index 85238d9db..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 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_TRAFFIC_STATISTIC_IMPL_H -#define DISTRIBUTEDDATAMGR_TRAFFIC_STATISTIC_IMPL_H - -#include "dfx/statistic_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class TrafficStatisticImpl : public StatisticReporter { -public: - virtual ~TrafficStatisticImpl() {} - ReportStatus Report(const TrafficStat &stat) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_TRAFFIC_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp deleted file mode 100644 index 99536be80..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "visit_statistic_impl.h" - -namespace OHOS { -namespace DistributedDataDfx { -ReportStatus VisitStatisticImpl::Report(const VisitStat &stat) -{ - HiViewAdapter::ReportVisitStatistic(DfxCodeConstant::VISIT_STATISTIC, stat, executors_); - return ReportStatus::SUCCESS; -} -void VisitStatisticImpl::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} -} // namespace DistributedDataDfx -} // namespace OHOS diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h deleted file mode 100644 index 9898ad546..000000000 --- a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 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_VISIT_STATISTIC_IMPL_H -#define DISTRIBUTEDDATAMGR_VISIT_STATISTIC_IMPL_H - -#include "dfx/statistic_reporter.h" -#include "hiview_adapter.h" - -namespace OHOS { -namespace DistributedDataDfx { -class VisitStatisticImpl : public StatisticReporter { -public: - virtual ~VisitStatisticImpl() {} - ReportStatus Report(const VisitStat &stat) override; - void SetThreadPool(std::shared_ptr executors); - -private: - std::shared_ptr executors_; -}; -} // namespace DistributedDataDfx -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_VISIT_STATISTIC_IMPL_H diff --git a/services/distributeddataservice/adapter/dfx/test/unittest/fake/hiview/include/fake_hiview.h b/services/distributeddataservice/adapter/dfx/test/unittest/fake/hiview/include/fake_hiview.h index 5cd962ba4..ac56c3303 100644 --- a/services/distributeddataservice/adapter/dfx/test/unittest/fake/hiview/include/fake_hiview.h +++ b/services/distributeddataservice/adapter/dfx/test/unittest/fake/hiview/include/fake_hiview.h @@ -53,7 +53,7 @@ public: private: static std::map fakeCache_; - static const inline int INTERNAL = 1000; + static const int INTERNAL = 1000; }; #endif // DISTRIBUTEDDATAMGR_HIVIEW_MGR_H diff --git a/services/distributeddataservice/adapter/include/dfx/reporter_impl.h b/services/distributeddataservice/adapter/include/dfx/reporter_impl.h index c5e9f1f22..2c2c42659 100644 --- a/services/distributeddataservice/adapter/include/dfx/reporter_impl.h +++ b/services/distributeddataservice/adapter/include/dfx/reporter_impl.h @@ -31,17 +31,7 @@ namespace DistributedDataDfx { class ReporterImpl : public Reporter { public: static bool Init(); - FaultReporter* ServiceFault() override; - FaultReporter* RuntimeFault() override; - FaultReporter* DatabaseFault() override; - FaultReporter* CommunicationFault() override; FaultReporter* CloudSyncFault() override; - - StatisticReporter* DatabaseStatistic() override; - StatisticReporter* VisitStatistic() override; - StatisticReporter* TrafficStatistic() override; - StatisticReporter* ApiPerformanceStatistic() override; - BehaviourReporter* GetBehaviourReporter() override; void SetThreadPool(std::shared_ptr executors) override; diff --git a/services/distributeddataservice/adapter/schema_helper/BUILD.gn b/services/distributeddataservice/adapter/schema_helper/BUILD.gn index 4bdf79b0c..58ebfd46b 100644 --- a/services/distributeddataservice/adapter/schema_helper/BUILD.gn +++ b/services/distributeddataservice/adapter/schema_helper/BUILD.gn @@ -36,7 +36,6 @@ ohos_source_set("distributeddata_schema_helper") { public_configs = [ ":module_public_config" ] external_deps = [ "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hilog:libhilog", "ipc:ipc_single", "kv_store:datamgr_common", diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn index 2415418df..df60b3659 100644 --- a/services/distributeddataservice/app/BUILD.gn +++ b/services/distributeddataservice/app/BUILD.gn @@ -132,7 +132,6 @@ ohos_shared_library("distributeddataservice") { "ability_base:want", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", "dataclassification:data_transit_mgr", "device_manager:devicemanagersdk", diff --git a/services/distributeddataservice/framework/include/dfx/behaviour_reporter.h b/services/distributeddataservice/framework/include/dfx/behaviour_reporter.h index 709d9be6d..875119a0d 100644 --- a/services/distributeddataservice/framework/include/dfx/behaviour_reporter.h +++ b/services/distributeddataservice/framework/include/dfx/behaviour_reporter.h @@ -17,6 +17,7 @@ #define DISTRIBUTEDDATAMGR_BEHAVIOUR_REPORTER_H #include "dfx_types.h" +#include "visibility.h" namespace OHOS { namespace DistributedDataDfx { diff --git a/services/distributeddataservice/framework/include/dfx/db_meta_callback_delegate.h b/services/distributeddataservice/framework/include/dfx/db_meta_callback_delegate.h deleted file mode 100644 index ca6447374..000000000 --- a/services/distributeddataservice/framework/include/dfx/db_meta_callback_delegate.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 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_CAL_DATABASE_SIZE_H -#define DISTRIBUTEDDATAMGR_CAL_DATABASE_SIZE_H - -#include -#include "visibility.h" - -namespace OHOS { -namespace DistributedKv { -struct StoreInfo { - std::string userId; - std::string appId; - std::string storeId; - std::string GetKey() - { - return userId + appId + storeId; - } -}; -class DbMetaCallbackDelegate { -public: - API_EXPORT virtual ~DbMetaCallbackDelegate() {} - API_EXPORT virtual bool GetKvStoreDiskSize(const std::string &storeId, uint64_t &size) = 0; - API_EXPORT virtual void GetKvStoreKeys(std::vector &entries) = 0; -}; -} // namespace DistributedKv -} // namespace OHOS -#endif // DISTRIBUTEDDATAMGR_CAL_DATABASE_SIZE_H diff --git a/services/distributeddataservice/framework/include/dfx/dfx_types.h b/services/distributeddataservice/framework/include/dfx/dfx_types.h index a83fd2529..4b8c9b7b9 100644 --- a/services/distributeddataservice/framework/include/dfx/dfx_types.h +++ b/services/distributeddataservice/framework/include/dfx/dfx_types.h @@ -25,53 +25,15 @@ namespace OHOS { namespace DistributedDataDfx { struct ModuleName { - static const inline std::string DEVICE = "DEVICE"; - static const inline std::string USER = "USER"; - static const inline std::string RDB_STORE = "RDB_STORE"; - static const inline std::string KV_STORE = "KV_STORE"; - static const inline std::string CLOUD_SERVER = "CLOUD_SERVER"; - static const inline std::string CLOUD_SYNC_CALLBACK = "CLOUD_SYNC_CALLBACK"; + static constexpr const char *DEVICE = "DEVICE"; + static constexpr const char *USER = "USER"; + static constexpr const char *RDB_STORE = "RDB_STORE"; + static constexpr const char *KV_STORE = "KV_STORE"; + static constexpr const char *CLOUD_SERVER = "CLOUD_SERVER"; + static constexpr const char *CLOUD_SYNC_CALLBACK = "CLOUD_SYNC_CALLBACK"; }; enum class Fault { - // Service Fault - SF_SERVICE_PUBLISH = 0, - SF_GET_SERVICE = 1, - SF_CREATE_DIR = 2, - SF_DATABASE_CONFIG = 3, - SF_PROCESS_LABEL = 4, - SF_INIT_DELEGATE = 5, - - // Runtime Fault - RF_OPEN_DB = 20, - RF_CLOSE_DB = 21, - RF_DELETE_DB = 22, - RF_DATA_SUBSCRIBE = 23, - RF_DATA_UNSUBSCRIBE = 24, - RF_CREATE_SNAPSHOT = 25, - RF_RELEASE_SNAPSHOT = 26, - RF_KEY_STORE_DAMAGE = 27, - RF_KEY_STORE_LOST = 28, - RF_DB_ROM = 29, - RF_GET_DB = 30, - RF_SUBCRIBE = 31, - RF_UNSUBCRIBE = 32, - RF_REPORT_THERAD_ERROR = 33, - - // Communication Fault - CF_CREATE_SESSION = 40, - CF_CREATE_PIPE = 41, - CF_SEND_PIPE_BROKEN = 42, - CF_REV_PIPE_BROKEN = 43, - CF_SERVICE_DIED = 44, - CF_CREATE_ZDN = 45, - CF_QUERY_ZDN = 46, - - // Database Fault - DF_DB_DAMAGE = 60, - DF_DB_REKEY_FAILED = 61, - DF_DB_CORRUPTED = 62, - // Cloud Sync Fault CSF_CLOUD_INFO = 70, CSF_SUBSCRIBE = 71, @@ -110,28 +72,6 @@ enum class SecurityInfo { SENSITIVE_LEVEL_FAILE = 3, }; -struct FaultMsg { - FaultType faultType; - std::string moduleName; - std::string interfaceName; - Fault errorType; -}; - -struct DBFaultMsg { - std::string appId; - std::string storeId; - std::string moduleName; - Fault errorType; -}; - -struct CommFaultMsg { - std::string userId; - std::string appId; - std::string storeId; - std::vector deviceId; - std::vector errorCode; -}; - struct ArkDataFaultMsg { std::string faultType; std::string bundleName; @@ -142,21 +82,6 @@ struct ArkDataFaultMsg { std::string appendixMsg; }; -struct SecurityPermissionsMsg { - std::string userId; - std::string appId; - std::string storeId; - std::string deviceId; - SecurityInfo securityInfo; -}; - -struct SecuritySensitiveLevelMsg { - std::string deviceId; - int deviceSensitiveLevel; - int optionSensitiveLevel; - SecurityInfo securityInfo; -}; - struct BehaviourMsg { std::string userId; std::string appId; @@ -174,60 +99,6 @@ struct UdmfBehaviourMsg { std::string result; }; -struct VisitStat { - std::string appId; - std::string interfaceName; - API_EXPORT std::string GetKey() const - { - return appId + interfaceName; - } -}; - -struct TrafficStat { - std::string appId; - std::string deviceId; - int sendSize; - int receivedSize; - API_EXPORT std::string GetKey() const - { - return appId + deviceId; - } -}; - -struct DbStat { - std::string userId; - std::string appId; - std::string storeId; - int dbSize; - std::shared_ptr delegate; - - API_EXPORT std::string GetKey() const - { - return userId + appId + storeId; - } -}; - -struct DbPerformanceStat { - std::string appId; - std::string storeId; - uint64_t currentTime; - uint64_t completeTime; - int size; - std::string srcDevId; - std::string dstDevId; -}; - -struct ApiPerformanceStat { - std::string interfaceName; - uint64_t costTime; - uint64_t averageTime; - uint64_t worstTime; - API_EXPORT std::string GetKey() const - { - return interfaceName; - } -}; - enum class ReportStatus { SUCCESS = 0, ERROR = 1, diff --git a/services/distributeddataservice/framework/include/dfx/fault_reporter.h b/services/distributeddataservice/framework/include/dfx/fault_reporter.h index a9dcdfb90..a1c96ade6 100644 --- a/services/distributeddataservice/framework/include/dfx/fault_reporter.h +++ b/services/distributeddataservice/framework/include/dfx/fault_reporter.h @@ -17,14 +17,12 @@ #define DISTRIBUTEDDATAMGR_FAULT_REPORTER_H #include "dfx_types.h" +#include "visibility.h" namespace OHOS { namespace DistributedDataDfx { class FaultReporter { public: - API_EXPORT virtual ReportStatus Report(const FaultMsg &msg) = 0; - API_EXPORT virtual ReportStatus Report(const CommFaultMsg &msg) = 0; - API_EXPORT virtual ReportStatus Report(const DBFaultMsg &ms) = 0; API_EXPORT virtual ReportStatus Report(const ArkDataFaultMsg &msg){ return ReportStatus::SUCCESS; }; API_EXPORT virtual ~FaultReporter() {} }; diff --git a/services/distributeddataservice/framework/include/dfx/reporter.h b/services/distributeddataservice/framework/include/dfx/reporter.h index 3288980dd..7fe081eb9 100644 --- a/services/distributeddataservice/framework/include/dfx/reporter.h +++ b/services/distributeddataservice/framework/include/dfx/reporter.h @@ -20,7 +20,6 @@ #include "dfx_types.h" #include "executor_pool.h" #include "fault_reporter.h" -#include "statistic_reporter.h" namespace OHOS { namespace DistributedDataDfx { @@ -29,15 +28,7 @@ public: API_EXPORT virtual ~Reporter() = default; API_EXPORT static bool RegisterReporterInstance(Reporter *reporter); API_EXPORT static Reporter* GetInstance(); - API_EXPORT virtual FaultReporter* ServiceFault() = 0; - API_EXPORT virtual FaultReporter* RuntimeFault() = 0; - API_EXPORT virtual FaultReporter* DatabaseFault() = 0; - API_EXPORT virtual FaultReporter* CommunicationFault() = 0; API_EXPORT virtual FaultReporter* CloudSyncFault() = 0; - API_EXPORT virtual StatisticReporter* DatabaseStatistic() = 0; - API_EXPORT virtual StatisticReporter* VisitStatistic() = 0; - API_EXPORT virtual StatisticReporter* TrafficStatistic() = 0; - API_EXPORT virtual StatisticReporter* ApiPerformanceStatistic() = 0; API_EXPORT virtual BehaviourReporter* GetBehaviourReporter() = 0; API_EXPORT virtual void SetThreadPool(std::shared_ptr executors) = 0; diff --git a/services/distributeddataservice/service/cloud/sync_manager.h b/services/distributeddataservice/service/cloud/sync_manager.h index 1e152ca10..9899b197d 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.h +++ b/services/distributeddataservice/service/cloud/sync_manager.h @@ -75,7 +75,7 @@ public: void SetPrepareTraceId(const std::string &prepareTraceId); std::shared_ptr GenerateQuery(const std::string &store, const Tables &tables); bool Contains(const std::string &storeName); - inline static constexpr const char *DEFAULT_ID = "default"; + static constexpr const char *DEFAULT_ID = "default"; private: friend SyncManager; diff --git a/services/distributeddataservice/service/data_share/BUILD.gn b/services/distributeddataservice/service/data_share/BUILD.gn index f39ed7a35..3c2f5096b 100644 --- a/services/distributeddataservice/service/data_share/BUILD.gn +++ b/services/distributeddataservice/service/data_share/BUILD.gn @@ -122,7 +122,6 @@ ohos_source_set("data_share_service") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", "data_share:datashare_common", "data_share:datashare_common_lite", diff --git a/services/distributeddataservice/service/rdb/BUILD.gn b/services/distributeddataservice/service/rdb/BUILD.gn index 69c3a7b4c..56f3a0afc 100644 --- a/services/distributeddataservice/service/rdb/BUILD.gn +++ b/services/distributeddataservice/service/rdb/BUILD.gn @@ -81,7 +81,6 @@ ohos_source_set("distributeddata_rdb") { "c_utils:utils", "device_auth:deviceauth_sdk", "device_manager:devicemanagersdk", - "dmsfwk:distributed_sdk", "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.h b/services/distributeddataservice/service/rdb/rdb_service_impl.h index bfb2ffbb2..dc2c7f57d 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.h +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.h @@ -153,7 +153,7 @@ private: int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) override; int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId) override; private: - static constexpr inline int32_t INVALID_TOKENID = 0; + static constexpr int32_t INVALID_TOKENID = 0; int32_t CloseStore(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId = INVALID_TOKENID) const; }; @@ -167,9 +167,9 @@ private: std::shared_ptr staticActs_; }; - static constexpr inline uint32_t WAIT_TIME = 30 * 1000; - static constexpr inline uint32_t SHARE_WAIT_TIME = 60; // seconds - static constexpr inline uint32_t SAVE_CHANNEL_INTERVAL = 5; // minutes + static constexpr uint32_t WAIT_TIME = 30 * 1000; + static constexpr uint32_t SHARE_WAIT_TIME = 60; // seconds + static constexpr uint32_t SAVE_CHANNEL_INTERVAL = 5; // minutes void RegisterRdbServiceInfo(); diff --git a/services/distributeddataservice/service/udmf/BUILD.gn b/services/distributeddataservice/service/udmf/BUILD.gn index 6ac317304..da4030e44 100644 --- a/services/distributeddataservice/service/udmf/BUILD.gn +++ b/services/distributeddataservice/service/udmf/BUILD.gn @@ -75,7 +75,6 @@ ohos_source_set("udmf_server") { "access_token:libtokenid_sdk", "app_file_service:remote_file_share_native", "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "device_manager:devicemanagersdk", "dfs_service:distributed_file_daemon_kit_inner", "hilog:libhilog", -- Gitee From f591e7aacbbcfbc9938917200f38604d40dabb9f Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Tue, 9 Sep 2025 11:46:51 +0800 Subject: [PATCH 2/2] fix: Signed-off-by: weishaoxiong --- .../adapter/dfx/src/hiview_adapter.cpp | 2 - .../adapter/dfx/test/BUILD.gn | 34 -- .../unittest/distributeddata_dfx_mst_test.cpp | 96 ---- .../unittest/distributeddata_dfx_ut_test.cpp | 410 +----------------- .../test/unittest/hiview_adapter_dfx_test.cpp | 112 ----- .../adapter/schema_helper/BUILD.gn | 1 + .../framework/include/dfx/dfx_types.h | 2 - .../service/udmf/BUILD.gn | 1 + 8 files changed, 5 insertions(+), 653 deletions(-) delete mode 100644 services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp index 4b7184a5d..ff1d19ec2 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp @@ -29,8 +29,6 @@ using namespace DistributedKv; using Anonymous = DistributedData::Anonymous; namespace { constexpr const char *DATAMGR_DOMAIN = "DISTDATAMGR"; -// fault key -constexpr const char *SYNC_ERROR_INFO = "SYNC_ERROR_INFO"; // Database statistic constexpr const char *USER_ID = "ANONYMOUS_UID"; constexpr const char *APP_ID = "APP_ID"; diff --git a/services/distributeddataservice/adapter/dfx/test/BUILD.gn b/services/distributeddataservice/adapter/dfx/test/BUILD.gn index 67f11fddb..202529acd 100755 --- a/services/distributeddataservice/adapter/dfx/test/BUILD.gn +++ b/services/distributeddataservice/adapter/dfx/test/BUILD.gn @@ -15,39 +15,6 @@ import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") module_output_path = "datamgr_service/datamgr_service/distributeddatafwk" -############################################################################### -config("module_dfx_mst_config") { - visibility = [ ":*" ] - - include_dirs = [ - "../src", - "../src/fault", - "../src/statistic", - ] -} - -ohos_unittest("DistributeddataDfxMSTTest") { - module_out_path = module_output_path - - sources = [ "./unittest/distributeddata_dfx_mst_test.cpp" ] - - configs = [ ":module_dfx_mst_config" ] - - external_deps = [ - "c_utils:utils", - "datamgr_service:distributeddatasvcfwk", - "googletest:gtest_main", - "hilog:libhilog", - "hisysevent:libhisysevent", - "hitrace:hitrace_meter", - "kv_store:distributeddata_inner", - "openssl:libcrypto_shared", - ] - ldflags = [ "-Wl,--exclude-libs,ALL" ] - deps = [ "${data_service_path}/adapter/dfx:distributeddata_dfx" ] - defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] -} - ############################################################################### config("module_dfx_config") { visibility = [ ":*" ] @@ -126,7 +93,6 @@ group("unittest") { deps = [] deps += [ - ":DistributeddataDfxMSTTest", ":DistributeddataDfxUTTest", ":HiViewAdapterDfxTest", ] 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 deleted file mode 100644 index 5c0065d8e..000000000 --- a/services/distributeddataservice/adapter/dfx/test/unittest/distributeddata_dfx_mst_test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "dfx/reporter.h" - -using namespace testing::ext; -using namespace OHOS::DistributedDataDfx; - -class DistributedataDfxMSTTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); - static Reporter* reporter_; -}; -Reporter* DistributedataDfxMSTTest::reporter_ = nullptr; - -void DistributedataDfxMSTTest::SetUpTestCase() -{ - size_t max = 12; - size_t min = 5; - reporter_ = Reporter::GetInstance(); - ASSERT_NE(nullptr, reporter_); - reporter_->SetThreadPool(std::make_shared(max, min)); -} - -void DistributedataDfxMSTTest::TearDownTestCase() -{ - reporter_->SetThreadPool(nullptr); - reporter_ = nullptr; -} - -void DistributedataDfxMSTTest::SetUp() {} - -void DistributedataDfxMSTTest::TearDown() {} - -/** - * @tc.name: Dfx001 - * @tc.desc: send data to 1 device, then check reporter message. - * @tc.type: send data - * @tc.require: AR000CQE1L - * @tc.author: hongbo - */ -HWTEST_F(DistributedataDfxMSTTest, Dfx001, TestSize.Level0) -{ - /** - * @tc.steps: step1. getcommunicationFault instance - * @tc.expected: step1. Expect instance is not null. - */ - auto comFault = reporter_->CommunicationFault(); - EXPECT_NE(nullptr, comFault); - struct CommFaultMsg msg{.userId = "user001", .appId = "myApp", .storeId = "storeTest"}; - msg.deviceId.push_back("device001"); - msg.errorCode.push_back(001); - msg.deviceId.push_back("device002"); - msg.errorCode.push_back(002); - - auto repStatus = comFault->Report(msg); - EXPECT_TRUE(repStatus == ReportStatus::SUCCESS); - - std::string myuid = "203230afadj020003"; - std::vector value(myuid.begin(), myuid.end()); - std::vector result; - - SHA256_CTX *context = new (std::nothrow) SHA256_CTX; - if (context == nullptr || !SHA256_Init(context)) { - delete context; - return; - } - - if (!SHA256_Update(context, value.data(), value.size())) { - delete context; - return; - } - result.resize(SHA256_DIGEST_LENGTH); - SHA256_Final(result.data(), context); - delete context; -} 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 4530a0032..15dd91e0f 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 @@ -61,231 +61,9 @@ void DistributeddataDfxUTTest::TearDown() {} * @tc.name: Dfx001 * @tc.desc: send data to 1 device, then check reporter message. * @tc.type: send data - * @tc.require: AR000CQE1L SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx001, TestSize.Level0) -{ - /** - * @tc.steps: step1. getcommunicationFault instance - * @tc.expected: step1. Expect instance is not null. - */ - auto comFault = reporter_->CommunicationFault(); - EXPECT_NE(nullptr, comFault); - struct CommFaultMsg msg{.userId = "user001", .appId = "myApp", .storeId = "storeTest"}; - msg.deviceId.push_back("device001"); - msg.errorCode.push_back(001); - msg.deviceId.push_back("device002"); - msg.errorCode.push_back(002); - - auto repStatus = comFault->Report(msg); - EXPECT_TRUE(repStatus == ReportStatus::SUCCESS); - /** - * @tc.steps:step2. check dfx reporter. - * @tc.expected: step2. Expect report message success. - */ - std::string val = FakeHivew::GetString("ANONYMOUS_UID"); - if (!val.empty()) { - EXPECT_STREQ(val.c_str(), string("user001").c_str()); - } - val = FakeHivew::GetString("APP_ID"); - if (!val.empty()) { - EXPECT_STREQ(val.c_str(), string("myApp").c_str()); - } - val = FakeHivew::GetString("STORE_ID"); - if (!val.empty()) { - EXPECT_STREQ(val.c_str(), string("storeTest").c_str()); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx002 - * @tc.desc: check database dfx report - * @tc.type: get kvStore - * @tc.require: AR000CQE1L AR000CQE1K SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx002, TestSize.Level0) -{ - FakeHivew::Clear(); - /** - * @tc.steps: step1. get database fault report instance - * @tc.expected: step1. Expect get instance success. - */ - auto dbFault = reporter_->DatabaseFault(); - EXPECT_NE(nullptr, dbFault); - struct DBFaultMsg msg {.appId = "MyApp", .storeId = "MyDatabase", - .moduleName = "database", .errorType = Fault::DF_DB_DAMAGE}; - - auto repStatus = dbFault->Report(msg); - /** - * @tc.steps: step2. check fault reporter. - * @tc.expected: step2. Expect report has bad report message. - */ - EXPECT_TRUE(repStatus == ReportStatus::SUCCESS); - auto val = FakeHivew::GetString("MODULE_NAME"); - if (!val.empty()) { - EXPECT_STREQ(string("database").c_str(), val.c_str()); - } - auto typeVal = FakeHivew::GetInt("ERROR_TYPE"); - if (typeVal > 0) { - EXPECT_EQ(static_cast(Fault::DF_DB_DAMAGE), typeVal); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx003 - * @tc.desc: Database file size statistic. - * @tc.type: check database file size. - * @tc.require: AR000CQE1O SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx003, TestSize.Level0) -{ - /** - * @tc.steps: step1. get database reporter instance. - * @tc.expected: step1. Expect get success. - */ - auto dbs = reporter_->DatabaseStatistic(); - EXPECT_NE(nullptr, dbs); - DbStat ds = {"uid", "appid", "storeId001", 100}; - auto dbsRet = dbs->Report(ds); - /** - * @tc.steps:step2. check reporter. - * @tc.expected: step2. Expect statistic database size is 100. - */ - EXPECT_TRUE(dbsRet == ReportStatus::SUCCESS); - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx004 - * @tc.desc: Set invalid information, call getKvStore, expect return INVALID_ARGS. - * @tc.type: CreateKvStore test - * @tc.require: AR000CQE1L SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx004, TestSize.Level0) -{ - /** - * @tc.steps: step1. Get runtime fault instance. - * @tc.expected: step1. Expect get runtime fault instance success. - */ - auto rtFault = reporter_->RuntimeFault(); - auto rtFault2 = reporter_->RuntimeFault(); - EXPECT_NE(nullptr, rtFault); - EXPECT_EQ(rtFault, rtFault2); - - struct FaultMsg rfMsg{FaultType::SERVICE_FAULT, "database", "closeKvStore", - Fault::RF_CLOSE_DB}; - auto rfReportRet = rtFault->Report(rfMsg); - /** - * @tc.steps:step2. check report message. - * @tc.expected: step2. Expected reported message. - */ - EXPECT_TRUE(rfReportRet == ReportStatus::SUCCESS); - auto val = FakeHivew::GetString("INTERFACE_NAME"); - if (!val.empty()) { - EXPECT_STREQ(string("closeKvStore").c_str(), val.c_str()); - } - auto typeVal = FakeHivew::GetInt("ERROR_TYPE"); - if (typeVal > 0) { - EXPECT_EQ(static_cast(Fault::RF_CLOSE_DB), typeVal); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx005 - * @tc.desc: send data to 1 device, then check send size. - * @tc.type: send data - * @tc.require: AR000CQE1P SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx005, TestSize.Level0) -{ - /** - * @tc.steps:step1. send data to 1 device - * @tc.expected: step1. Expect put success. - */ - auto ts = reporter_->TrafficStatistic(); - EXPECT_NE(nullptr, ts); - struct TrafficStat tss = {"appId001", "deviceId001", 100, 200}; - auto tsRet = ts->Report(tss); - /** - * @tc.steps:step2. check dfx reporter. - * @tc.expected: step2. Expect report has same size. - */ - EXPECT_TRUE(tsRet == ReportStatus::SUCCESS); - - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx006 - * @tc.desc: call interface statistic. - * @tc.type: statistic - * @tc.require: AR000CQE1N SR000CQE1J - * @tc.author: hongbo - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx006, TestSize.Level0) -{ - /** - * @tc.steps:step1. create call interface statistic instance - * @tc.expected: step1. Expect get instance success. - */ - auto vs = reporter_->VisitStatistic(); - EXPECT_NE(nullptr, vs); - struct VisitStat vss = {"appid001", "Put"}; - auto vsRet = vs->Report(vss); - /** - * @tc.steps:step2. check dfx reporter. - * @tc.expected: step2. Expect report has same information. - */ - EXPECT_TRUE(vsRet == ReportStatus::SUCCESS); - - FakeHivew::Clear(); - std::string myuid = "203230afadj020003"; - std::string result; - ValueHash vh; - vh.CalcValueHash(myuid, result); -} - -/** - * @tc.name: Dfx007 - * @tc.desc: call api performance statistic. - * @tc.type: statistic - * @tc.require: AR000DPVGP SR000DPVGH - * @tc.author: liwei - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx007, TestSize.Level0) -{ - /** - * @tc.steps:step1. create call api perforamnce statistic instance - * @tc.expected: step1. Expect get instance success. - */ - auto ap = reporter_->ApiPerformanceStatistic(); - EXPECT_NE(nullptr, ap); - struct ApiPerformanceStat aps = { "interface", 10000, 5000, 20000 }; - auto apRet = ap->Report(aps); - /** - * @tc.steps:step2. check dfx reporter return value. - * @tc.expected: step2. Expect report has same information. - */ - EXPECT_TRUE(apRet == ReportStatus::SUCCESS); - - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx008 - * @tc.desc: send data to 1 device, then check reporter message. - * @tc.type: send data * @tc.author: nhj */ -HWTEST_F(DistributeddataDfxUTTest, Dfx008, TestSize.Level0) +HWTEST_F(DistributeddataDfxUTTest, Dfx001, TestSize.Level0) { /** * @tc.steps: step1. get database fault report instance @@ -318,80 +96,12 @@ HWTEST_F(DistributeddataDfxUTTest, Dfx008, TestSize.Level0) } /** - * @tc.name: Dfx009 - * @tc.desc: Set invalid information, call getKvStore, expect return INVALID_ARGS. - * @tc.type: CreateKvStore test - * @tc.author: nhj - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx009, TestSize.Level0) -{ - /** - * @tc.steps: step1. Get runtime fault instance. - * @tc.expected: step1. Expect get runtime fault instance success. - */ - auto svFault = reporter_->ServiceFault(); - auto svFault2 = reporter_->ServiceFault(); - EXPECT_NE(nullptr, svFault); - EXPECT_EQ(svFault, svFault2); - - struct FaultMsg svMsg{FaultType::SERVICE_FAULT, "myData", "createKvStore", - Fault::SF_CREATE_DIR}; - auto rfReportRet = svFault->Report(svMsg); - /** - * @tc.steps:step2. check report message. - * @tc.expected: step2. Expected reported message. - */ - EXPECT_TRUE(rfReportRet == ReportStatus::SUCCESS); - auto val = FakeHivew::GetString("INTERFACE_NAME"); - if (!val.empty()) { - EXPECT_STREQ(string("createKvStore").c_str(), val.c_str()); - } - auto typeVal = FakeHivew::GetInt("ERROR_TYPE"); - if (typeVal > 0) { - EXPECT_EQ(static_cast(Fault::SF_CREATE_DIR), typeVal); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx010 - * @tc.desc: Database file size statistic. - * @tc.type: check database file size. - * @tc.author: nhj - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx010, TestSize.Level0) -{ - /** - * @tc.steps: step1. get database reporter instance. - * @tc.expected: step1. Expect get success. - */ - auto dbs = reporter_->DatabaseStatistic(); - EXPECT_NE(nullptr, dbs); - DbStat ds = {"uid", "appid", "storeId002", 100}; - auto dbsRet = dbs->Report(ds); - /** - * @tc.steps:step2. check reporter. - * @tc.expected: step2. Expect statistic database size is 100. - */ - EXPECT_TRUE(dbsRet == ReportStatus::SUCCESS); - auto val = FakeHivew::GetString("STORE_ID"); - if (!val.empty()) { - EXPECT_STREQ(string("storeId002").c_str(), val.c_str()); - } - auto typeVal = FakeHivew::GetInt("DB_SIZE"); - if (typeVal > 0) { - EXPECT_EQ(100, typeVal); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx011 + * @tc.name: Dfx002 * @tc.desc: Send UdmfBehaviourMsg * @tc.type: Send data * @tc.author: nhj */ -HWTEST_F(DistributeddataDfxUTTest, Dfx011, TestSize.Level0) +HWTEST_F(DistributeddataDfxUTTest, Dfx002, TestSize.Level0) { /** * @tc.steps: step1. get database fault report instance @@ -427,118 +137,4 @@ HWTEST_F(DistributeddataDfxUTTest, Dfx011, TestSize.Level0) EXPECT_EQ(200, val04); } FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx012 - * @tc.desc: send data to 1 device, then check send size. - * @tc.type: send data - * @tc.author: nhj - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx012, TestSize.Level0) -{ - /** - * @tc.steps:step1. send data to 1 device - * @tc.expected: step1. Expect put success. - */ - auto ts = reporter_->TrafficStatistic(); - EXPECT_NE(nullptr, ts); - struct TrafficStat tss = {"appId001", "deviceId001", 100, 200}; - auto tsRet = ts->Report(tss); - /** - * @tc.steps:step2. check dfx reporter. - * @tc.expected: step2. Expect report has same size. - */ - EXPECT_TRUE(tsRet == ReportStatus::SUCCESS); - std::string myuid = "cjsdblvdfbfss11"; - std::string result; - ValueHash vh; - vh.CalcValueHash(myuid, result); - - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx013 - * @tc.desc: call api performance statistic. - * @tc.type: - * @tc.author: nhj - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx013, TestSize.Level0) -{ - /** - * @tc.steps:step1. create call api perforamnce statistic instance - * @tc.expected: step1. Expect get instance success. - */ - auto ap = reporter_->ApiPerformanceStatistic(); - EXPECT_NE(nullptr, ap); - struct ApiPerformanceStat aps = { "interface", 2000, 500, 1000 }; - auto apRet = ap->Report(aps); - /** - * @tc.steps:step2. check dfx reporter return value. - * @tc.expected: step2. Expect report has same information. - */ - EXPECT_TRUE(apRet == ReportStatus::SUCCESS); - auto val = FakeHivew::GetString("INTERFACE_NAME"); - if (!val.empty()) { - EXPECT_STREQ(string("interface").c_str(), val.c_str()); - } - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx014 - * @tc.desc: test msg.errorType equals to Fault::DF_DB_CORRUPTED. - * @tc.type: FUNC - * @tc.require: - * @tc.author: caozhijun - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx014, TestSize.Level0) -{ - FakeHivew::Clear(); - auto dbFault = reporter_->DatabaseFault(); - ASSERT_NE(nullptr, dbFault); - struct DBFaultMsg msg {.appId = "mYApp", .storeId = "mYDatabase", - .moduleName = "dataBase", .errorType = Fault::DF_DB_CORRUPTED}; - auto repStatus = dbFault->Report(msg); - EXPECT_TRUE(repStatus == ReportStatus::SUCCESS); - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx015 - * @tc.desc: test msg.errorType equals to Fault::DF_DB_REKEY_FAILED. - * @tc.type: FUNC - * @tc.require: - * @tc.author: caozhijun - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx015, TestSize.Level0) -{ - FakeHivew::Clear(); - auto dbFault = reporter_->DatabaseFault(); - ASSERT_NE(nullptr, dbFault); - struct DBFaultMsg msg {.appId = "MyApp", .storeId = "mYDatabase", - .moduleName = "DataBase", .errorType = Fault::DF_DB_REKEY_FAILED}; - auto repStatus = dbFault->Report(msg); - EXPECT_TRUE(repStatus == ReportStatus::SUCCESS); - FakeHivew::Clear(); -} - -/** - * @tc.name: Dfx016 - * @tc.desc: test other error scenario. - * @tc.type: FUNC - * @tc.require: - * @tc.author: caozhijun - */ -HWTEST_F(DistributeddataDfxUTTest, Dfx016, TestSize.Level0) -{ - FakeHivew::Clear(); - auto dbFault = reporter_->DatabaseFault(); - ASSERT_NE(nullptr, dbFault); - struct DBFaultMsg msg {.appId = "MyApp", .storeId = "mYDatabase", - .moduleName = "DataBase", .errorType = Fault::SF_SERVICE_PUBLISH}; - auto repStatus = dbFault->Report(msg); - EXPECT_TRUE(repStatus == ReportStatus::ERROR); - FakeHivew::Clear(); } \ No newline at end of file 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 7ac97e392..2b36484d6 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 @@ -42,54 +42,6 @@ public: void TearDown(){}; }; -/** -* @tc.name: ReportFault001 -* @tc.desc: ReportFault function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportFault001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::FaultMsg msg; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportFault(dfxCode, msg, executors)); -} - -/** -* @tc.name: ReportDBFault001 -* @tc.desc: ReportDBFault function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportDBFault001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::DBFaultMsg msg; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportDBFault(dfxCode, msg, executors)); -} - -/** -* @tc.name: ReportCommFault001 -* @tc.desc: ReportCommFault function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportCommFault001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::CommFaultMsg msg; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportCommFault(dfxCode, msg, executors)); -} - /** * @tc.name: ReportArkDataFault001 * @tc.desc: ReportArkDataFault function error test. @@ -122,70 +74,6 @@ HWTEST_F(HiViewAdapterDfxTest, ReportBehaviour001, TestSize.Level0) DistributedDataDfx::HiViewAdapter::ReportBehaviour(dfxCode, msg, executors)); } -/** -* @tc.name: ReportDatabaseStatistic001 -* @tc.desc: ReportDatabaseStatistic function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportDatabaseStatistic001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::DbStat stat; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportDatabaseStatistic(dfxCode, stat, executors)); -} - -/** -* @tc.name: ReportTrafficStatistic001 -* @tc.desc: ReportTrafficStatistic function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportTrafficStatistic001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::TrafficStat stat; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportTrafficStatistic(dfxCode, stat, executors)); -} - -/** -* @tc.name: ReportVisitStatistic001 -* @tc.desc: ReportVisitStatistic function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportVisitStatistic001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::VisitStat stat; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportVisitStatistic(dfxCode, stat, executors)); -} - -/** -* @tc.name: ReportApiPerformanceStatistic001 -* @tc.desc: ReportApiPerformanceStatistic function error test. -* @tc.type: FUNC -* @tc.require: -* @tc.author: SQL -*/ -HWTEST_F(HiViewAdapterDfxTest, ReportApiPerformanceStatistic001, TestSize.Level0) -{ - int dfxCode = 0; - DistributedDataDfx::ApiPerformanceStat stat; - std::shared_ptr executors = nullptr; - EXPECT_NO_FATAL_FAILURE( - DistributedDataDfx::HiViewAdapter::ReportApiPerformanceStatistic(dfxCode, stat, executors)); -} - /** * @tc.name: ReportUdmfBehaviour001 * @tc.desc: ReportUdmfBehaviour function error test. diff --git a/services/distributeddataservice/adapter/schema_helper/BUILD.gn b/services/distributeddataservice/adapter/schema_helper/BUILD.gn index 58ebfd46b..4bdf79b0c 100644 --- a/services/distributeddataservice/adapter/schema_helper/BUILD.gn +++ b/services/distributeddataservice/adapter/schema_helper/BUILD.gn @@ -36,6 +36,7 @@ ohos_source_set("distributeddata_schema_helper") { public_configs = [ ":module_public_config" ] external_deps = [ "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", "hilog:libhilog", "ipc:ipc_single", "kv_store:datamgr_common", diff --git a/services/distributeddataservice/framework/include/dfx/dfx_types.h b/services/distributeddataservice/framework/include/dfx/dfx_types.h index 4b8c9b7b9..ae9f838a6 100644 --- a/services/distributeddataservice/framework/include/dfx/dfx_types.h +++ b/services/distributeddataservice/framework/include/dfx/dfx_types.h @@ -20,8 +20,6 @@ #include #include -#include "db_meta_callback_delegate.h" - namespace OHOS { namespace DistributedDataDfx { struct ModuleName { diff --git a/services/distributeddataservice/service/udmf/BUILD.gn b/services/distributeddataservice/service/udmf/BUILD.gn index da4030e44..6ac317304 100644 --- a/services/distributeddataservice/service/udmf/BUILD.gn +++ b/services/distributeddataservice/service/udmf/BUILD.gn @@ -75,6 +75,7 @@ ohos_source_set("udmf_server") { "access_token:libtokenid_sdk", "app_file_service:remote_file_share_native", "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", "device_manager:devicemanagersdk", "dfs_service:distributed_file_daemon_kit_inner", "hilog:libhilog", -- Gitee