From 3cc5bbf16bddbfa8d2cc15a3fd615f421a68a365 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 15:56:43 +0800 Subject: [PATCH 01/55] add hisysevent Signed-off-by: wanderer-dl122 --- bundle.json | 3 ++ hisysevent.yaml | 46 +++++++++++++++++++ .../distributedhardwarefwkservice/BUILD.gn | 1 + .../src/distributed_hardware_service.cpp | 16 +++++++ 4 files changed, 66 insertions(+) create mode 100644 hisysevent.yaml diff --git a/bundle.json b/bundle.json index 08a4998a..8982e12a 100644 --- a/bundle.json +++ b/bundle.json @@ -23,6 +23,9 @@ ], "rom": "128K", "ram": "6M", + "hisysevent_config": [ + "//foundation/distributedhardware/distributedhardwarefwk/hisysevent.yaml" + ], "deps": { "components": [ "appexecfwk_base", diff --git a/hisysevent.yaml b/hisysevent.yaml new file mode 100644 index 00000000..772ecdc3 --- /dev/null +++ b/hisysevent.yaml @@ -0,0 +1,46 @@ +# Copyright (c) 2022 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. + +##################################################### +# below is the format of defining event # +##################################################### +#domain: domain name. [Only one domain name can be defined at the top] +# +#author: the author name who defined this event. +#date: the date when this event was defined, format is YYYY-MM-DD. +#logged: source file which refer to this event. +#usage: the usage of this event. +#//Define event name and event properties. +#@EVENT_NAME: the event definition part begin. +# // __BASE is used for defining the basic info of the event. +# // "type" optional values are: FAULT, STATISTICS, SECURITY, BEHAVIOR. +# // "level" optional values are: CRITICAL, MINOR. +# // "tag" set tags with may used by subscriber of this event, multiple tags devided by space. +# // "desc" full description of this event. +# @PARAMETER: {type: parameter type, arrsize: array length(optional), desc: parameter description}. +# // follow the __BASE block, each line defines a parameter of this event. +# // "type" optional values are: INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, STRING. +# // "arrsize" of the parameter is an array, set a non-zero value. +# // "desc" full description of this parameter. + +##################################################### +# Example of some hiviewdfx events definition # +##################################################### + +domain: DHFWK + +DHFWK_SA_START: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start on demand} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk sa start} diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 3fd69ff7..08d32b6e 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -57,6 +57,7 @@ ohos_shared_library("distributedhardwarefwksvr") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 6c130aa7..285fa99d 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -15,6 +15,10 @@ #include "distributed_hardware_service.h" +#include + +#include "hisysevent.h" + #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "ipc_types.h" @@ -38,6 +42,18 @@ DistributedHardwareService::DistributedHardwareService(int32_t saId, bool runOnC void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_START", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa start on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); return; -- Gitee From fcdd817e786b31b81785dd30eb9549bfa052e8cc Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 18:33:33 +0800 Subject: [PATCH 02/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 7f801b21..db93b82b 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -17,6 +17,9 @@ #include #include +#include + +#include "hisysevent.h" #include "anonymous_string.h" #include "constants.h" @@ -74,6 +77,18 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_STOP", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa stop on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + exit(0); } -- Gitee From f518fbd962c66ad70e25f07e7789c63c5f4ad644 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 19:09:09 +0800 Subject: [PATCH 03/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index db93b82b..0d34a413 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -17,9 +17,6 @@ #include #include -#include - -#include "hisysevent.h" #include "anonymous_string.h" #include "constants.h" @@ -78,17 +75,6 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_STOP", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa stop on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - exit(0); } -- Gitee From 82147ff5c1a09cea64b42639212cfd9a8d5a7cff Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 19:11:12 +0800 Subject: [PATCH 04/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 6 ++++++ .../src/distributed_hardware_manager_factory.cpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hisysevent.yaml b/hisysevent.yaml index 772ecdc3..c08013fb 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -44,3 +44,9 @@ DHFWK_SA_START: PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk sa start} + +DHFWK_SA_STOP: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk sa stop} diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 0d34a413..db93b82b 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -17,6 +17,9 @@ #include #include +#include + +#include "hisysevent.h" #include "anonymous_string.h" #include "constants.h" @@ -75,6 +78,17 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_STOP", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa stop on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + exit(0); } -- Gitee From a21246827bf97c658234b2b0ba02d7ad59cb523f Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 19:29:20 +0800 Subject: [PATCH 05/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 6 +++--- .../src/distributed_hardware_manager_factory.cpp | 12 ------------ .../src/componentloader/component_loader.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index c08013fb..34c005c0 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -45,8 +45,8 @@ DHFWK_SA_START: UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk sa start} -DHFWK_SA_STOP: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} +COMP_LOAD: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk load all components} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} - MSG: {type: STRING, desc: dhfwk sa stop} + MSG: {type: STRING, desc: dhfwk load all components} \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index db93b82b..f5188e22 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -77,18 +77,6 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_STOP", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa stop on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - exit(0); } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 86a00f59..be65bc96 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -242,6 +242,18 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_LOAD", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk load all components."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); -- Gitee From a9e02413edb9d9cfc9b2b59fc3ab5f66e5688a8a Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 19:43:13 +0800 Subject: [PATCH 06/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index be65bc96..08b21602 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -18,7 +18,9 @@ #include #include #include +#include +#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" -- Gitee From f29f765d3efc673abf0e78966f8d485001f311f7 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 20:09:04 +0800 Subject: [PATCH 07/55] add hisysevent Signed-off-by: wanderer-dl122 --- common/utils/include/constants.h | 2 ++ .../src/distributed_hardware_manager_factory.cpp | 2 -- .../src/componentloader/component_loader.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/common/utils/include/constants.h b/common/utils/include/constants.h index 37b1dfa6..88c2b1cb 100644 --- a/common/utils/include/constants.h +++ b/common/utils/include/constants.h @@ -19,6 +19,8 @@ #include #include +#include "hisysevent.h" + namespace OHOS { namespace DistributedHardware { constexpr int32_t LOG_MAX_LEN = 4096; diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index f5188e22..2ad44851 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,8 +19,6 @@ #include #include -#include "hisysevent.h" - #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 08b21602..564026fe 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -20,7 +20,6 @@ #include #include -#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" -- Gitee From 937ac2c7ff01e3060d7678c77690c7bc560e1da3 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 11:00:06 +0800 Subject: [PATCH 08/55] add hisysevent Signed-off-by: wanderer-dl122 --- common/utils/include/constants.h | 2 -- .../src/distributed_hardware_manager_factory.cpp | 2 ++ .../src/componentloader/component_loader.cpp | 12 +----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/common/utils/include/constants.h b/common/utils/include/constants.h index 88c2b1cb..37b1dfa6 100644 --- a/common/utils/include/constants.h +++ b/common/utils/include/constants.h @@ -19,8 +19,6 @@ #include #include -#include "hisysevent.h" - namespace OHOS { namespace DistributedHardware { constexpr int32_t LOG_MAX_LEN = 4096; diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 2ad44851..f5188e22 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,6 +19,8 @@ #include #include +#include "hisysevent.h" + #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 564026fe..d15445fa 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -20,6 +20,7 @@ #include #include +#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" @@ -244,17 +245,6 @@ int32_t ComponentLoader::ParseConfig() int32_t ret; DHLOGI("ParseConfig start"); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_LOAD", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk load all components."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); -- Gitee From 3d02fa16b10365b2c868cf4cadaf638d826618e8 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 11:24:57 +0800 Subject: [PATCH 09/55] add hisysevent Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkservice/BUILD.gn | 1 + services/distributedhardwarefwkserviceimpl/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 08d32b6e..328dfc5c 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -18,6 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr") { include_dirs = [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" "//utils/native/base/include", "//utils/system/safwk/native/include", "include", diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a20..eb317337 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -18,6 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr_impl") { include_dirs = [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" "//utils/native/base/include", "//utils/system/safwk/native/include", "//third_party/json/include", -- Gitee From 3d2e56db72f7e3b349cab35c7ddcd2ea14cea969 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 11:31:53 +0800 Subject: [PATCH 10/55] add hisysevent Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkservice/BUILD.gn | 2 +- services/distributedhardwarefwkserviceimpl/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 328dfc5c..a05f6f89 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -18,7 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "include", diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index eb317337..e0475836 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -18,7 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr_impl") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "//third_party/json/include", -- Gitee From 4229cdcff9b98e8e8e5a36a677f5d4b1cbaff530 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 15:20:47 +0800 Subject: [PATCH 11/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 2 -- .../src/componentloader/component_loader.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index f5188e22..2ad44851 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,8 +19,6 @@ #include #include -#include "hisysevent.h" - #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index d15445fa..8f446e58 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -20,7 +20,6 @@ #include #include -#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" -- Gitee From 8212883f6fa3f45758f67a80b189c55bc8a45bbb Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 15:54:41 +0800 Subject: [PATCH 12/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 14 ++++++++++++++ .../distributedhardwarefwkserviceimpl/BUILD.gn | 1 + 2 files changed, 15 insertions(+) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 2ad44851..db93b82b 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,6 +19,8 @@ #include #include +#include "hisysevent.h" + #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" @@ -75,6 +77,18 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_STOP", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa stop on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + exit(0); } diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index e0475836..806b4cb8 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -84,6 +84,7 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", -- Gitee From 49f64490ba35584da464ebca03602d9fb652afa3 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 18:03:05 +0800 Subject: [PATCH 13/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../distributed_hardware_manager_factory.cpp | 25 +++++++------ .../src/distributed_hardware_service.cpp | 27 +++++++------- utils/BUILD.gn | 1 + utils/include/dh_utils_hisysevent.h | 32 +++++++++++++++++ utils/src/dh_utils_hisysevent.cpp | 36 +++++++++++++++++++ 5 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 utils/include/dh_utils_hisysevent.h create mode 100644 utils/src/dh_utils_hisysevent.cpp diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index db93b82b..94bf9103 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,12 +19,11 @@ #include #include -#include "hisysevent.h" - #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" #include "dh_utils_tool.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -77,17 +76,17 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_STOP", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa stop on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWrite("DHFWK_SA_STOP", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa stop on demand."); + // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + // "DHFWK_SA_STOP", + // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + // "PID", getpid(), + // "UID", getuid(), + // "MSG", "dhfwk sa stop on demand."); + // if (res != DH_FWK_SUCCESS) { + // DHLOGE("Write HiSysEvent error, res:%d", res); + // } exit(0); } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 285fa99d..bb3a17c0 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -15,10 +15,6 @@ #include "distributed_hardware_service.h" -#include - -#include "hisysevent.h" - #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "ipc_types.h" @@ -29,6 +25,7 @@ #include "access_manager.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" +#include "dh_utils_hisysevent.h" namespace OHOS { namespace DistributedHardware { @@ -43,16 +40,18 @@ void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_START", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa start on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWrite("DHFWK_SA_START", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); + + // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + // "DHFWK_SA_START", + // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + // "PID", getpid(), + // "UID", getuid(), + // "MSG", "dhfwk sa start on demand."); + // if (res != DH_FWK_SUCCESS) { + // DHLOGE("Write HiSysEvent error, res:%d", res); + // } if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 27018ede..caaebd35 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -29,6 +29,7 @@ ohos_shared_library("distributedhardwareutils") { sources = [ "src/anonymous_string.cpp", + "src/dh_utils_hisysevent.cpp", "src/dh_utils_tool.cpp", "src/log/dh_log.cpp", ] diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h new file mode 100644 index 00000000..f3b97bf0 --- /dev/null +++ b/utils/include/dh_utils_hisysevent.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H +#define OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H + +#include +#include + +#include "hisysevent.h" + +namespace OHOS { +namespace DistributedHardware { +const std::string DHFWK_SA_START = "DHFWK_SA_START"; +const std::string DHFWK_SA_STOP = "DHFWK_SA_STOP"; + +void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp new file mode 100644 index 00000000..5ea3ef0a --- /dev/null +++ b/utils/src/dh_utils_hisysevent.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022 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 "anonymous_string.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +void HiSysEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + eventName, + eventType, + "PID", getpid(), + "UID", getuid(), + "MSG", msg); + if (res != SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file -- Gitee From 21264b50d87ff47a5f3d670bc927debd67d559fb Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 18:05:43 +0800 Subject: [PATCH 14/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 6 ++++++ services/distributedhardwarefwkservice/BUILD.gn | 2 -- services/distributedhardwarefwkserviceimpl/BUILD.gn | 1 - utils/BUILD.gn | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 34c005c0..c7e94bed 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -45,6 +45,12 @@ DHFWK_SA_START: UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk sa start} +DHFWK_SA_STOP: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk sa stop} + COMP_LOAD: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk load all components} PID: {type: INT32, desc: dhfwk pid} diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index a05f6f89..3fd69ff7 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -18,7 +18,6 @@ import( ohos_shared_library("distributedhardwarefwksvr") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "include", @@ -58,7 +57,6 @@ ohos_shared_library("distributedhardwarefwksvr") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 806b4cb8..9553b9c8 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -18,7 +18,6 @@ import( ohos_shared_library("distributedhardwarefwksvr_impl") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "//third_party/json/include", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index caaebd35..7d437213 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -17,6 +17,7 @@ import( ohos_shared_library("distributedhardwareutils") { include_dirs = [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/openssl:libcrypto_static", "//utils/native/base/include", "//utils/system/safwk/native/include", @@ -51,6 +52,7 @@ ohos_shared_library("distributedhardwareutils") { "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", + "hisysevent_native:libhisysevent", ] subsystem_name = "distributedhardware" -- Gitee From d47b1976a20ee9c6a252dcb2c54e67db22a3a1d8 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 18:06:31 +0800 Subject: [PATCH 15/55] add hisysevent Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkserviceimpl/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 9553b9c8..6e3b3a20 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,7 +83,6 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", -- Gitee From 17c77a57db9a63f0b6b6834a84c332e0d8b88107 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 19:11:21 +0800 Subject: [PATCH 16/55] add hisysevent Signed-off-by: wanderer-dl122 --- utils/src/dh_utils_hisysevent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index 5ea3ef0a..bc81a681 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -15,6 +15,7 @@ #include "anonymous_string.h" #include "distributed_hardware_log.h" +#include "dh_utils_hisysevent.h" namespace OHOS { namespace DistributedHardware { @@ -32,5 +33,4 @@ void HiSysEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventTy } } } // namespace DistributedHardware -} // namespace OHOS -#endif \ No newline at end of file +} // namespace OHOS\ \ No newline at end of file -- Gitee From a9714e0f8aebf5653271c9c49f4e4d9a8b489cc0 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 19:23:41 +0800 Subject: [PATCH 17/55] add hisysevent Signed-off-by: wanderer-dl122 --- utils/src/dh_utils_hisysevent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index bc81a681..93cae9be 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -14,8 +14,9 @@ */ #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dh_utils_hisysevent.h" +#include "distributed_hardware_log.h" +#include "distributed_hardware_errno.h" namespace OHOS { namespace DistributedHardware { @@ -28,7 +29,7 @@ void HiSysEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventTy "PID", getpid(), "UID", getuid(), "MSG", msg); - if (res != SUCCESS) { + if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } -- Gitee From 535009aef5d5fb8ecd20e7c1dc804bc066b6a3e1 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 19:46:31 +0800 Subject: [PATCH 18/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../distributed_hardware_manager_factory.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 94bf9103..2f5d8356 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -23,7 +23,6 @@ #include "constants.h" #include "device_manager.h" #include "dh_utils_tool.h" -#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -76,17 +75,17 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - HiSysEventWrite("DHFWK_SA_STOP", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa stop on demand."); - // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - // "DHFWK_SA_STOP", - // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - // "PID", getpid(), - // "UID", getuid(), - // "MSG", "dhfwk sa stop on demand."); - // if (res != DH_FWK_SUCCESS) { - // DHLOGE("Write HiSysEvent error, res:%d", res); - // } + // HiSysEventWrite("DHFWK_SA_STOP", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa stop on demand."); + // // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + // // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + // // "DHFWK_SA_STOP", + // // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + // // "PID", getpid(), + // // "UID", getuid(), + // // "MSG", "dhfwk sa stop on demand."); + // // if (res != DH_FWK_SUCCESS) { + // // DHLOGE("Write HiSysEvent error, res:%d", res); + // // } exit(0); } -- Gitee From 0ef46c71115fd223705bffaa8a7be11080ebf2d7 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 20:55:57 +0800 Subject: [PATCH 19/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../distributedhardwarefwkservice/BUILD.gn | 2 ++ .../distributed_hardware_manager_factory.cpp | 22 +++++++------ .../src/distributed_hardware_service.cpp | 32 +++++++++++-------- .../BUILD.gn | 2 ++ .../src/componentloader/component_loader.cpp | 1 - 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 3fd69ff7..a05f6f89 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -18,6 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr") { include_dirs = [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "include", @@ -57,6 +58,7 @@ ohos_shared_library("distributedhardwarefwksvr") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 2f5d8356..6c3fedb9 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -19,6 +19,8 @@ #include #include +#include "hisysevent.h" + #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" @@ -76,16 +78,16 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); // HiSysEventWrite("DHFWK_SA_STOP", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa stop on demand."); - // // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - // // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - // // "DHFWK_SA_STOP", - // // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - // // "PID", getpid(), - // // "UID", getuid(), - // // "MSG", "dhfwk sa stop on demand."); - // // if (res != DH_FWK_SUCCESS) { - // // DHLOGE("Write HiSysEvent error, res:%d", res); - // // } + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_STOP", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa stop on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } exit(0); } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index bb3a17c0..658f2405 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -15,6 +15,11 @@ #include "distributed_hardware_service.h" + +#include + + +#include "hisysevent.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "ipc_types.h" @@ -25,7 +30,8 @@ #include "access_manager.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -#include "dh_utils_hisysevent.h" +// #include "dh_utils_hisysevent.h" + namespace OHOS { namespace DistributedHardware { @@ -40,18 +46,18 @@ void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); - HiSysEventWrite("DHFWK_SA_START", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); - - // int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - // OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - // "DHFWK_SA_START", - // OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - // "PID", getpid(), - // "UID", getuid(), - // "MSG", "dhfwk sa start on demand."); - // if (res != DH_FWK_SUCCESS) { - // DHLOGE("Write HiSysEvent error, res:%d", res); - // } + // HiSysEventWrite("DHFWK_SA_START", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DHFWK_SA_START", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk sa start on demand."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a20..e736e219 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -18,6 +18,7 @@ import( ohos_shared_library("distributedhardwarefwksvr_impl") { include_dirs = [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "//third_party/json/include", @@ -84,6 +85,7 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", + "hisysevent_native:libhisysevent", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 8f446e58..322f2c7d 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -243,7 +243,6 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); -- Gitee From 32a692be552a6f763527f65120f8f3cc9121d45e Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 10:57:16 +0800 Subject: [PATCH 20/55] add hisysevent Signed-off-by: wanderer-dl122 --- bundle.json | 2 +- .../fuzztest/accessmanager_fuzzer/BUILD.gn | 1 + .../unittest/common/accessmanager/BUILD.gn | 1 + .../BUILD.gn | 1 + .../fuzztest/componentmanager_fuzzer/BUILD.gn | 5 ++- .../fuzztest/resourcemanager_fuzzer/BUILD.gn | 1 + utils/BUILD.gn | 3 -- utils/include/dh_utils_hisysevent.h | 32 ---------------- utils/src/dh_utils_hisysevent.cpp | 37 ------------------- 9 files changed, 9 insertions(+), 74 deletions(-) delete mode 100644 utils/include/dh_utils_hisysevent.h delete mode 100644 utils/src/dh_utils_hisysevent.cpp diff --git a/bundle.json b/bundle.json index 8982e12a..242d05a3 100644 --- a/bundle.json +++ b/bundle.json @@ -24,7 +24,7 @@ "rom": "128K", "ram": "6M", "hisysevent_config": [ - "//foundation/distributedhardware/distributedhardwarefwk/hisysevent.yaml" + "//foundation/distributedhardware/distributedhardwarefwk/hisysevent.yaml" ], "deps": { "components": [ diff --git a/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn index 53d89fa2..4ecb1bd9 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("AccessmanagerFuzzTest") { external_deps = [ "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "hisysevent_native:libhisysevent", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn index 5fc00a80..3068a1cf 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("AccessManagerTest") { external_deps = [ "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "hisysevent_native:libhisysevent", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index e736e219..24d15373 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -84,6 +84,7 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "hisysevent_native:libhisysevent", "ipc:ipc_core", diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index 5314afb0..51a348dc 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn @@ -51,7 +51,10 @@ ohos_fuzztest("ComponentmanagerFuzzTest") { "LOG_DOMAIN=0xD004100", ] - external_deps = [ "ipc:ipc_core" ] + external_deps = [ + "ipc:ipc_core", + "hisysevent_native:libhisysevent", + ] } ############################################################################### diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn index 4ff5522b..38726e6f 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn @@ -61,6 +61,7 @@ ohos_fuzztest("ResourcemanagerFuzzTest") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 7d437213..27018ede 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -17,7 +17,6 @@ import( ohos_shared_library("distributedhardwareutils") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/openssl:libcrypto_static", "//utils/native/base/include", "//utils/system/safwk/native/include", @@ -30,7 +29,6 @@ ohos_shared_library("distributedhardwareutils") { sources = [ "src/anonymous_string.cpp", - "src/dh_utils_hisysevent.cpp", "src/dh_utils_tool.cpp", "src/log/dh_log.cpp", ] @@ -52,7 +50,6 @@ ohos_shared_library("distributedhardwareutils") { "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", - "hisysevent_native:libhisysevent", ] subsystem_name = "distributedhardware" diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h deleted file mode 100644 index f3b97bf0..00000000 --- a/utils/include/dh_utils_hisysevent.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H -#define OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H - -#include -#include - -#include "hisysevent.h" - -namespace OHOS { -namespace DistributedHardware { -const std::string DHFWK_SA_START = "DHFWK_SA_START"; -const std::string DHFWK_SA_STOP = "DHFWK_SA_STOP"; - -void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); -} // namespace DistributedHardware -} // namespace OHOS -#endif diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp deleted file mode 100644 index 93cae9be..00000000 --- a/utils/src/dh_utils_hisysevent.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 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 "anonymous_string.h" -#include "dh_utils_hisysevent.h" -#include "distributed_hardware_log.h" -#include "distributed_hardware_errno.h" - -namespace OHOS { -namespace DistributedHardware { -void HiSysEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - eventName, - eventType, - "PID", getpid(), - "UID", getuid(), - "MSG", msg); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } -} -} // namespace DistributedHardware -} // namespace OHOS\ \ No newline at end of file -- Gitee From 5332575b9e0e0eb5db6fd2fab37e991648ca7d71 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 11:38:07 +0800 Subject: [PATCH 21/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 80 +++++++++++++++++- .../distributedhardwarefwkservice/BUILD.gn | 1 - .../distributed_hardware_manager_factory.cpp | 2 +- .../src/distributed_hardware_service.cpp | 6 -- .../BUILD.gn | 1 - .../src/componentloader/component_loader.cpp | 81 +++++++++++++++++++ .../componentmanager/component_disable.cpp | 30 +++++++ .../src/componentmanager/component_enable.cpp | 30 +++++++ .../src/distributed_hardware_manager.cpp | 27 +++++++ .../capability_info_manager.cpp | 15 ++++ .../src/task/offline_task.cpp | 16 ++++ .../src/task/online_task.cpp | 17 ++++ .../unittest/common/componentloader/BUILD.gn | 2 + .../unittest/common/componentmanager/BUILD.gn | 1 + .../unittest/common/resourcemanager/BUILD.gn | 1 + 15 files changed, 300 insertions(+), 10 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index c7e94bed..86779de9 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -55,4 +55,82 @@ COMP_LOAD: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk load all components} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} - MSG: {type: STRING, desc: dhfwk load all components} \ No newline at end of file + MSG: {type: STRING, desc: dhfwk load all components} + +FILE_PARSE_ERROR: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + SONAME: {type: STRING, desc: component so name} + MSG: {type: STRING, desc: dhfwk component so config file canonicalization failed} + +COMP_SO_LOAD_ERROR: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + SONAME: {type: STRING, desc: component so name} + MSG: {type: STRING, desc: dhfwk component so open failed} + +COMP_RELEASE: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk all components release} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk all components release} + +COMP_RELEASE_ERROR: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk component dlclose failed} + +ON_LINE_TASK: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create online task} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk create online task} + +OFF_LINE_TASK: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create offline task} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dhfwk create offline task} + +ENABLE_TASK: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create enable task} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + DEVID: {type: STRING, desc: device id} + DHID: {type: STRING, desc: component id} + MSG: {type: STRING, desc: dhfwk create enable task} + +DISENABLE_TASK: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + DEVID: {type: STRING, desc: device id} + DHID: {type: STRING, desc: component id} + MSG: {type: STRING, desc: dhfwk create disable task} + +ENABLE_FAILED: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware enable failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + DHID: {type: STRING, desc: component id} + RESULT: {type: INT32, desc: dhfwk distributed hardware enable result} + MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} + +DISABLE_FAILED: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware disable failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + DHID: {type: STRING, desc: component id} + RESULT: {type: INT32, desc: dhfwk distributed hardware disable result} + MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} + +DB_DATA_NOTIFY: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk Sync full remote device info from DB} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + DEVID: {type: STRING, desc: device id} + DHID: {type: STRING, desc: component id} + MSG: {type: STRING, desc: dhfwk Sync full remote device info from DB} diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index a05f6f89..08d32b6e 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -18,7 +18,6 @@ import( ohos_shared_library("distributedhardwarefwksvr") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "include", diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 6c3fedb9..db93b82b 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -77,7 +77,7 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - // HiSysEventWrite("DHFWK_SA_STOP", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa stop on demand."); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, "DHFWK_SA_STOP", diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 658f2405..eadb2a85 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -15,10 +15,8 @@ #include "distributed_hardware_service.h" - #include - #include "hisysevent.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" @@ -30,8 +28,6 @@ #include "access_manager.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -// #include "dh_utils_hisysevent.h" - namespace OHOS { namespace DistributedHardware { @@ -46,8 +42,6 @@ void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); - // HiSysEventWrite("DHFWK_SA_START", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, "DHFWK_SA_START", diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 24d15373..5b49f06b 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -18,7 +18,6 @@ import( ohos_shared_library("distributedhardwarefwksvr_impl") { include_dirs = [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//utils/native/base/include", "//utils/system/safwk/native/include", "//third_party/json/include", diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 322f2c7d..ca1b4762 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -20,6 +20,7 @@ #include #include +#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" @@ -141,11 +142,37 @@ void *ComponentLoader::GetHandler(const std::string &soName) if (soName.length() == 0 || (LIB_LOAD_PATH.length() + soName.length()) > PATH_MAX || realpath((LIB_LOAD_PATH + soName).c_str(), path) == nullptr) { DHLOGE("File canonicalization failed"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "FILE_PARSE_ERROR", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "SONAME", soName.c_str(), + "MSG", "dhfwk component so config file canonicalization failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return nullptr; } void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { DHLOGE("%s handler load failed.", path); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_SO_LOAD_ERROR", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "SONAME", soName.c_str(), + "MSG", "dhfwk component so open failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return nullptr; } return pHandler; @@ -243,6 +270,18 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_LOAD", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk load all components."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); @@ -271,6 +310,18 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_RELEASE", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk all components release."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); iter != compHandlerMap_.end(); iter++) { @@ -290,6 +341,16 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_RELEASE_ERROR", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk release hardware handler failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } return ret; } @@ -302,6 +363,16 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_RELEASE_ERROR", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk release source failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } return ret; } @@ -314,6 +385,16 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "COMP_RELEASE_ERROR", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk release sink failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 9cb2c82e..d53d0f0d 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -15,6 +15,8 @@ #include "component_disable.h" +#include "hisysevent.h" + #include "anonymous_string.h" #include "constants.h" #include "distributed_hardware_errno.h" @@ -43,6 +45,20 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (ret != DH_FWK_SUCCESS) { DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DISABLE_FAILED", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "DHID", GetAnonyString(dhId).c_str(), + "RESULT", ret, + "MSG", "dhfwk unregister distributed hardware failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -53,6 +69,20 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (!waitStatus) { DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DISABLE_FAILED", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "DHID", GetAnonyString(dhId).c_str(), + "RESULT", ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, + "MSG", "dhfwk distributed hardware disable timeout."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_DISABLE_FAILED; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index ebbf1cbc..d3cb3f33 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -15,6 +15,8 @@ #include "component_enable.h" +#include "hisysevent.h" + #include "anonymous_string.h" #include "constants.h" #include "distributed_hardware_errno.h" @@ -43,6 +45,20 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "ENABLE_FAILED", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "DHID", GetAnonyString(dhId).c_str(), + "RESULT", ret, + "MSG", "dhfwk register distributed hardware failed."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -53,6 +69,20 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (!waitStatus) { DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "ENABLE_FAILED", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "DHID", GetAnonyString(dhId).c_str(), + "RESULT", ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, + "MSG", "dhfwk distributed hardware enable timeout."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_ENABLE_FAILED; diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 17359412..80b8cf36 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -15,6 +15,10 @@ #include "distributed_hardware_manager.h" +#include + +#include "hisysevent.h" + #include "anonymous_string.h" #include "capability_info_manager.h" #include "component_loader.h" @@ -110,6 +114,18 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::ON_LINE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "ON_LINE_TASK", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk create online task."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + DHContext::GetInstance().AddOnlineDevice(uuid, networkId); CapabilityInfoManager::GetInstance()->CreateManualSyncCount(GetDeviceIdByUUID(uuid)); @@ -151,6 +167,17 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI auto task = TaskFactory::GetInstance().CreateTask(TaskType::OFF_LINE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "OFF_LINE_TASK", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "MSG", "dhfwk create offline task."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } + DHContext::GetInstance().RemoveOnlineDevice(realUUID); CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp index 07e05473..2a3f9fdc 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp @@ -15,6 +15,8 @@ #include "capability_info_manager.h" +#include "hisysevent.h" + #include "anonymous_string.h" #include "capability_info_event.h" #include "capability_utils.h" @@ -134,6 +136,19 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() continue; } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DB_DATA_NOTIFY", + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "DEVID", GetAnonyString(capabilityInfo->GetDeviceId()).c_str(), + "DHID", capabilityInfo->GetDHId().c_str(), + "MSG", "Sync full remote device info from DB."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index d73ae1f4..8cb94e5f 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -16,6 +16,9 @@ #include "offline_task.h" #include +#include + +#include "hisysevent.h" #include "anonymous_string.h" #include "capability_info_manager.h" @@ -101,6 +104,19 @@ void OffLineTask::CreateDisableTask() }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "DISENABLE_TASK", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), + "DHID", (iter->GetDHId()).c_str(), + "MSG", "dhfwk dhfwk create disable task."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index a576cabe..11dee8f8 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -15,6 +15,10 @@ #include "online_task.h" +#include + +#include "hisysevent.h" + #include "anonymous_string.h" #include "capability_info_manager.h" #include "dh_utils_tool.h" @@ -102,6 +106,19 @@ void OnLineTask::CreateEnableTask() }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); + + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + "ENABLE_TASK", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), + "DHID", (iter->GetDHId()).c_str(), + "MSG", "dhfwk dhfwk create enable task."); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } } } } // namespace DistributedHardware diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn index e7a4ecf7..b46861bb 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn @@ -44,6 +44,8 @@ ohos_unittest("ComponentLoaderTest") { "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl" ] + external_deps = [ "hisysevent_native:libhisysevent" ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"ComponentLoaderTest\"", diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn index 5b83af89..fa495f7b 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ComponentManagerTest") { external_deps = [ "ipc:ipc_core", + "hisysevent_native:libhisysevent", ] } diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn index 05ce090e..f3bf8ff3 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("ResourceManagerTest") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "distributeddatamgr:distributeddata_inner" ] -- Gitee From 2e380fe7e4514b5b6bb23ca6ca6e6538e6f6e85c Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 12:15:12 +0800 Subject: [PATCH 22/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/unittest/common/accessmanager/BUILD.gn | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn index 3068a1cf..be489786 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") +import( + "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") module_out_path = "distributed_hardware_fwk/access_manager_test" @@ -35,20 +36,20 @@ ohos_unittest("AccessManagerTest") { module_out_path = module_out_path sources = [ - "${services_path}/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp", "${services_path}/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp", + "${services_path}/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp", ] - sources += ["access_manager_test.cpp"] + sources += [ "access_manager_test.cpp" ] - configs = [":module_private_config"] + configs = [ ":module_private_config" ] deps = [ - "//third_party/googletest:gtest_main", "${utils_path}:distributedhardwareutils", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkservice:distributedhardwarefwksvr", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//third_party/googletest:gtest_main", ] defines = [ "HI_LOG_ENABLE", -- Gitee From 1da74c587d4250195f212d1e619c77228986f37e Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 12:41:30 +0800 Subject: [PATCH 23/55] add hisysevent Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkserviceimpl/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 5b49f06b..9553b9c8 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -85,7 +85,6 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "eventhandler:libeventhandler", "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", - "hisysevent_native:libhisysevent", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", -- Gitee From b40601e5919b20f142665787e76c4d79b7f7f537 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 14:27:28 +0800 Subject: [PATCH 24/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/fuzztest/componentmanager_fuzzer/BUILD.gn | 5 +---- .../test/fuzztest/resourcemanager_fuzzer/BUILD.gn | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index 51a348dc..5314afb0 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn @@ -51,10 +51,7 @@ ohos_fuzztest("ComponentmanagerFuzzTest") { "LOG_DOMAIN=0xD004100", ] - external_deps = [ - "ipc:ipc_core", - "hisysevent_native:libhisysevent", - ] + external_deps = [ "ipc:ipc_core" ] } ############################################################################### diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn index 38726e6f..4ff5522b 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn @@ -61,7 +61,6 @@ ohos_fuzztest("ResourcemanagerFuzzTest") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] } -- Gitee From e9c698e6db37f294683c516107252b283eaeb502 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 14:29:54 +0800 Subject: [PATCH 25/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/fuzztest/componentmanager_fuzzer/BUILD.gn | 5 ++++- .../test/fuzztest/resourcemanager_fuzzer/BUILD.gn | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index 5314afb0..dd17237c 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn @@ -51,7 +51,10 @@ ohos_fuzztest("ComponentmanagerFuzzTest") { "LOG_DOMAIN=0xD004100", ] - external_deps = [ "ipc:ipc_core" ] + external_deps = [ + "hisysevent_native:libhisysevent", + "ipc:ipc_core", + ] } ############################################################################### diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn index 4ff5522b..38726e6f 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn @@ -61,6 +61,7 @@ ohos_fuzztest("ResourcemanagerFuzzTest") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] } -- Gitee From d61b35e122478905f5ec72e35ddf22f132873328 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 14:40:24 +0800 Subject: [PATCH 26/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index db93b82b..ef9f29b9 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include "hisysevent.h" -- Gitee From 556f5c3efecdce9dbd96af68862887c539abb513 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 15:48:29 +0800 Subject: [PATCH 27/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 5 ++++- .../src/componentloader/component_loader.cpp | 1 + .../src/distributed_hardware_manager.cpp | 2 ++ .../src/task/offline_task.cpp | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 86779de9..eba51561 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -81,18 +81,21 @@ COMP_RELEASE_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} + RESULT: {type: INT32, desc: dlclose failed result} MSG: {type: STRING, desc: dhfwk component dlclose failed} ON_LINE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create online task} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} + DEVID: {type: STRING, desc: device id} MSG: {type: STRING, desc: dhfwk create online task} OFF_LINE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create offline task} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} + DEVID: {type: STRING, desc: device id} MSG: {type: STRING, desc: dhfwk create offline task} ENABLE_TASK: @@ -103,7 +106,7 @@ ENABLE_TASK: DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk create enable task} -DISENABLE_TASK: +DISABLE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index ca1b4762..7f1943ec 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -347,6 +347,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "PID", getpid(), "UID", getuid(), + "RESULT", ret, "MSG", "dhfwk release hardware handler failed."); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 80b8cf36..2b89ea04 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -121,6 +121,7 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PID", getpid(), "UID", getuid(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), "MSG", "dhfwk create online task."); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); @@ -173,6 +174,7 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PID", getpid(), "UID", getuid(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), "MSG", "dhfwk create offline task."); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 8cb94e5f..55427f42 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -107,7 +107,7 @@ void OffLineTask::CreateDisableTask() int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DISENABLE_TASK", + "DISABLE_TASK", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PID", getpid(), "UID", getuid(), -- Gitee From 6bc6a689340af30b0d1ef99f76e4b41b43a67587 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 15:55:36 +0800 Subject: [PATCH 28/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 2b89ea04..4bcb6c19 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -121,7 +121,7 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PID", getpid(), "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(uuid)).c_str(), "MSG", "dhfwk create online task."); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); @@ -174,7 +174,7 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PID", getpid(), "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), + "DEVID", GetAnonyString(GetDeviceIdByUUID(uuid)).c_str(), "MSG", "dhfwk create offline task."); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); -- Gitee From 199749c09297095be6b7632f76473621ac005596 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 16:04:35 +0800 Subject: [PATCH 29/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/fuzztest/componentmanager_fuzzer/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index dd17237c..55f8ae55 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn @@ -51,7 +51,7 @@ ohos_fuzztest("ComponentmanagerFuzzTest") { "LOG_DOMAIN=0xD004100", ] - external_deps = [ + external_deps = [ "hisysevent_native:libhisysevent", "ipc:ipc_core", ] -- Gitee From 8cb39fb1c69ec4a7adfcfd678b82ca5d5b92d550 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 16:16:35 +0800 Subject: [PATCH 30/55] add hisysevent Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkservice/BUILD.gn | 2 +- .../src/componentmanager/component_disable.cpp | 2 +- .../src/componentmanager/component_enable.cpp | 2 +- .../src/task/offline_task.cpp | 2 +- .../src/task/online_task.cpp | 2 +- .../test/fuzztest/componentmanager_fuzzer/BUILD.gn | 2 +- .../test/unittest/common/componentloader/BUILD.gn | 11 +++++------ 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 08d32b6e..5fe81ae3 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index d53d0f0d..01850e65 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index d3cb3f33..9f9f39a2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 55427f42..298cab2e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index 11dee8f8..85ddf03c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index 55f8ae55..69bf6a89 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn index b46861bb..2bc1b087 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 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 @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") +import( + "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") module_out_path = "distributed_hardware_fwk/component_loader_test" config("module_private_config") { @@ -33,15 +34,13 @@ config("module_private_config") { ohos_unittest("ComponentLoaderTest") { module_out_path = module_out_path - sources = [ - "src/component_loader_test.cpp" - ] + sources = [ "src/component_loader_test.cpp" ] configs = [ ":module_private_config" ] deps = [ + "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", "//third_party/googletest:gtest_main", - "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl" ] external_deps = [ "hisysevent_native:libhisysevent" ] -- Gitee From bd461ec91edb075c72116fb385b2a5ee7c9b0249 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 16:57:52 +0800 Subject: [PATCH 31/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/unittest/common/componentloader/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn index 2bc1b087..8d97bae9 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn @@ -14,6 +14,7 @@ import("//build/test.gni") import( "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") + module_out_path = "distributed_hardware_fwk/component_loader_test" config("module_private_config") { -- Gitee From 3c1bde4df30a12b477993272f4fbb249c97a62be Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 17:29:49 +0800 Subject: [PATCH 32/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../unittest/common/componentmanager/BUILD.gn | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn index fa495f7b..d56a67d2 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") +import( + "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") module_out_path = "distributed_hardware_fwk/component_manager_test" config("module_private_config") { @@ -33,17 +34,15 @@ config("module_private_config") { ohos_unittest("ComponentManagerTest") { module_out_path = module_out_path - sources = [ - "src/component_manager_test.cpp" - ] + sources = [ "src/component_manager_test.cpp" ] configs = [ ":module_private_config" ] deps = [ - "//third_party/googletest:gtest_main", - "//third_party/googletest:gmock_main", + "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", "//foundation/distributedhardware/distributedhardwarefwk/utils:distributedhardwareutils", - "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl" + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", ] defines = [ @@ -53,8 +52,8 @@ ohos_unittest("ComponentManagerTest") { ] external_deps = [ - "ipc:ipc_core", "hisysevent_native:libhisysevent", + "ipc:ipc_core", ] } -- Gitee From c03c6b183cf23a137a0f764ad10e332ae0932378 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 18:38:45 +0800 Subject: [PATCH 33/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 1 + .../src/componentloader/component_loader.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/hisysevent.yaml b/hisysevent.yaml index eba51561..b6463d02 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -81,6 +81,7 @@ COMP_RELEASE_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} PID: {type: INT32, desc: dhfwk pid} UID: {type: INT32, desc: dhfwk uid} + DHTYPE: {type: UINT32, desc: dhtype} RESULT: {type: INT32, desc: dlclose failed result} MSG: {type: STRING, desc: dhfwk component dlclose failed} diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 7f1943ec..fb9760cc 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -347,6 +347,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "PID", getpid(), "UID", getuid(), + "DHTYPE", (uint32_t)dhType, "RESULT", ret, "MSG", "dhfwk release hardware handler failed."); if (res != DH_FWK_SUCCESS) { -- Gitee From 513bee520da94604725ca0bed46d19a2a4bf9f20 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 20:51:35 +0800 Subject: [PATCH 34/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 1 + .../test/unittest/common/componentmanager/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index fb9760cc..27ebcc03 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -341,6 +341,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, "COMP_RELEASE_ERROR", diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn index d56a67d2..fcf5acbf 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn @@ -14,6 +14,7 @@ import("//build/test.gni") import( "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") + module_out_path = "distributed_hardware_fwk/component_manager_test" config("module_private_config") { -- Gitee From 12a616d6d379ff2153c818ad81cb954c59e622c4 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 21:03:23 +0800 Subject: [PATCH 35/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/unittest/common/resourcemanager/BUILD.gn | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn index f3bf8ff3..7ca83856 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 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 @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") +import( + "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") module_out_path = "distributed_hardware_fwk/resource_manager_test" config("module_private_config") { @@ -30,7 +31,7 @@ config("module_private_config") { "//utils/native/base/include", "//third_party/json/include", "//utils/native/base/include", - "//utils/system/safwk/native/include" + "//utils/system/safwk/native/include", ] } -- Gitee From cc81bd77e5b3bfcdf0b7578690bfcd8d3c4ff9f0 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 30 May 2022 10:07:29 +0800 Subject: [PATCH 36/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/unittest/common/resourcemanager/BUILD.gn | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn index 7ca83856..4bf290b8 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn @@ -14,6 +14,7 @@ import("//build/test.gni") import( "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") + module_out_path = "distributed_hardware_fwk/resource_manager_test" config("module_private_config") { @@ -39,26 +40,24 @@ config("module_private_config") { ohos_unittest("ResourceManagerTest") { module_out_path = module_out_path - sources = [ - "src/resource_manager_test.cpp" - ] + sources = [ "src/resource_manager_test.cpp" ] configs = [ ":module_private_config" ] deps = [ + "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "//foundation/distributedhardware/distributedhardwarefwk/utils:distributedhardwareutils", "//third_party/googletest:gtest_main", "//utils/native/base:utils", - "//foundation/distributedhardware/distributedhardwarefwk/utils:distributedhardwareutils", - "//foundation/distributedhardware/distributedhardwarefwk/services/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl" ] external_deps = [ "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", - "distributeddatamgr:distributeddata_inner" ] } -- Gitee From 559e2cfc13eb2e7fdbd59255242cc191eb40e160 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 31 May 2022 16:17:07 +0800 Subject: [PATCH 37/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 32 +--- .../distributed_hardware_manager_factory.cpp | 17 +-- .../src/distributed_hardware_service.cpp | 16 +- .../src/componentloader/component_loader.cpp | 96 ++---------- .../componentmanager/component_disable.cpp | 36 +---- .../src/componentmanager/component_enable.cpp | 36 +---- .../src/distributed_hardware_manager.cpp | 37 +---- .../capability_info_manager.cpp | 18 +-- .../src/task/offline_task.cpp | 19 +-- .../src/task/online_task.cpp | 20 +-- utils/BUILD.gn | 2 + utils/include/dh_utils_hisysevent.h | 58 +++++++ utils/src/dh_utils_hisysevent.cpp | 144 ++++++++++++++++++ 13 files changed, 258 insertions(+), 273 deletions(-) create mode 100644 utils/include/dh_utils_hisysevent.h create mode 100644 utils/src/dh_utils_hisysevent.cpp diff --git a/hisysevent.yaml b/hisysevent.yaml index b6463d02..c411e935 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -41,100 +41,74 @@ domain: DHFWK DHFWK_SA_START: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start on demand} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk sa start} DHFWK_SA_STOP: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk sa stop} COMP_LOAD: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk load all components} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk load all components} FILE_PARSE_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} SONAME: {type: STRING, desc: component so name} MSG: {type: STRING, desc: dhfwk component so config file canonicalization failed} COMP_SO_LOAD_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} SONAME: {type: STRING, desc: component so name} MSG: {type: STRING, desc: dhfwk component so open failed} COMP_RELEASE: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk all components release} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} MSG: {type: STRING, desc: dhfwk all components release} COMP_RELEASE_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} - DHTYPE: {type: UINT32, desc: dhtype} + DHTYPE: {type: STRING, desc: dhtype} RESULT: {type: INT32, desc: dlclose failed result} MSG: {type: STRING, desc: dhfwk component dlclose failed} ON_LINE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create online task} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DEVID: {type: STRING, desc: device id} + UUID: {type: STRING, desc: uuid} MSG: {type: STRING, desc: dhfwk create online task} OFF_LINE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create offline task} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DEVID: {type: STRING, desc: device id} + UUID: {type: STRING, desc: uuid} MSG: {type: STRING, desc: dhfwk create offline task} ENABLE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create enable task} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk create enable task} DISABLE_TASK: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk create disable task} ENABLE_FAILED: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware enable failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DHID: {type: STRING, desc: component id} RESULT: {type: INT32, desc: dhfwk distributed hardware enable result} MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} DISABLE_FAILED: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware disable failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DHID: {type: STRING, desc: component id} RESULT: {type: INT32, desc: dhfwk distributed hardware disable result} MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} DB_DATA_NOTIFY: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk Sync full remote device info from DB} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk Sync full remote device info from DB} diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 248b72c0..d5fe0045 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -18,13 +18,11 @@ #include #include #include -#include - -#include "hisysevent.h" #include "anonymous_string.h" #include "constants.h" #include "device_manager.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -78,17 +76,8 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_STOP", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa stop on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteMsg(DHFWK_SA_STOP, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa stop on demand."); exit(0); } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index eadb2a85..a9fbc295 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -15,9 +15,6 @@ #include "distributed_hardware_service.h" -#include - -#include "hisysevent.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "ipc_types.h" @@ -26,6 +23,7 @@ #include "system_ability_definition.h" #include "access_manager.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -41,17 +39,7 @@ DistributedHardwareService::DistributedHardwareService(int32_t saId, bool runOnC void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DHFWK_SA_START", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk sa start on demand."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteMsg(DHFWK_SA_START, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 27ebcc03..3efb8c4d 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -18,13 +18,12 @@ #include #include #include -#include -#include "hisysevent.h" #include "nlohmann/json.hpp" #include "constants.h" #include "distributed_hardware_log.h" +#include "dh_utils_hisysevent.h" #include "hidump_helper.h" using nlohmann::json; @@ -142,36 +141,16 @@ void *ComponentLoader::GetHandler(const std::string &soName) if (soName.length() == 0 || (LIB_LOAD_PATH.length() + soName.length()) > PATH_MAX || realpath((LIB_LOAD_PATH + soName).c_str(), path) == nullptr) { DHLOGE("File canonicalization failed"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "FILE_PARSE_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "SONAME", soName.c_str(), - "MSG", "dhfwk component so config file canonicalization failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteCompLoadMsg(FILE_PARSE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + soName, "dhfwk component so config file canonicalization failed."); return nullptr; } void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { DHLOGE("%s handler load failed.", path); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_SO_LOAD_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "SONAME", soName.c_str(), - "MSG", "dhfwk component so open failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteCompLoadMsg(COMP_SO_LOAD_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + soName, "dhfwk component so open failed."); return nullptr; } @@ -270,17 +249,8 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_LOAD", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk load all components."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteMsg(COMP_LOAD, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk load all components."); std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { @@ -310,17 +280,8 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_RELEASE", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk all components release."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteMsg(COMP_RELEASE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk all components release."); int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); @@ -341,19 +302,8 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_RELEASE_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DHTYPE", (uint32_t)dhType, - "RESULT", ret, - "MSG", "dhfwk release hardware handler failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + dhType, ret, "dhfwk release hardware handler failed."); } return ret; } @@ -366,16 +316,8 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_RELEASE_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk release source failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + dhType, ret, "dhfwk release source failed."); } return ret; } @@ -388,16 +330,8 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "COMP_RELEASE_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dhfwk release sink failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + dhType, ret, "dhfwk release sink failed."); } return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 01850e65..95b7cce4 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -15,10 +15,9 @@ #include "component_disable.h" -#include "hisysevent.h" - #include "anonymous_string.h" #include "constants.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -45,20 +44,8 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (ret != DH_FWK_SUCCESS) { DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DISABLE_FAILED", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DHID", GetAnonyString(dhId).c_str(), - "RESULT", ret, - "MSG", "dhfwk unregister distributed hardware failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - + HiSysEventWriteAbleFailedMsg(DISABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId).c_str(), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -69,20 +56,9 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (!waitStatus) { DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DISABLE_FAILED", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DHID", GetAnonyString(dhId).c_str(), - "RESULT", ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, - "MSG", "dhfwk distributed hardware disable timeout."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - + HiSysEventWriteAbleFailedMsg(DISABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, + "dhfwk distributed hardware disable timeout."); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_DISABLE_FAILED; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 9f9f39a2..2a1cac35 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -15,10 +15,9 @@ #include "component_enable.h" -#include "hisysevent.h" - #include "anonymous_string.h" #include "constants.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -45,20 +44,8 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "ENABLE_FAILED", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DHID", GetAnonyString(dhId).c_str(), - "RESULT", ret, - "MSG", "dhfwk register distributed hardware failed."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - + HiSysEventWriteAbleFailedMsg(ENABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId).c_str(), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -69,20 +56,9 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (!waitStatus) { DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "ENABLE_FAILED", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DHID", GetAnonyString(dhId).c_str(), - "RESULT", ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, - "MSG", "dhfwk distributed hardware enable timeout."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - + HiSysEventWriteAbleFailedMsg(ENABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, + "dhfwk distributed hardware enable timeout."); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_ENABLE_FAILED; diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 4bcb6c19..7e1f83fc 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -15,15 +15,12 @@ #include "distributed_hardware_manager.h" -#include - -#include "hisysevent.h" - #include "anonymous_string.h" #include "capability_info_manager.h" #include "component_loader.h" #include "component_manager.h" #include "dh_context.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -114,22 +111,12 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::ON_LINE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "ON_LINE_TASK", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(uuid)).c_str(), - "MSG", "dhfwk create online task."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - DHContext::GetInstance().AddOnlineDevice(uuid, networkId); CapabilityInfoManager::GetInstance()->CreateManualSyncCount(GetDeviceIdByUUID(uuid)); + HiSysEventWriteOnOffLineMsg(ON_LINE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(GetDeviceIdByUUID(uuid)), GetAnonyString(uuid), "dhfwk create online task."); + return DH_FWK_SUCCESS; } @@ -167,22 +154,12 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::OFF_LINE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); - - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "OFF_LINE_TASK", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(uuid)).c_str(), - "MSG", "dhfwk create offline task."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } - DHContext::GetInstance().RemoveOnlineDevice(realUUID); CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); + HiSysEventWriteOnOffLineMsg(OFF_LINE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(GetDeviceIdByUUID(realUUID)), GetAnonyString(realUUID), "dhfwk create offline task."); + return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp index 2a3f9fdc..e6b30a37 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp @@ -15,13 +15,12 @@ #include "capability_info_manager.h" -#include "hisysevent.h" - #include "anonymous_string.h" #include "capability_info_event.h" #include "capability_utils.h" #include "constants.h" #include "dh_context.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -137,18 +136,9 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DB_DATA_NOTIFY", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "DEVID", GetAnonyString(capabilityInfo->GetDeviceId()).c_str(), - "DHID", capabilityInfo->GetDHId().c_str(), - "MSG", "Sync full remote device info from DB."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteAbleTaskMsg(DB_DATA_NOTIFY, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(capabilityInfo->GetDeviceId()), GetAnonyString(capabilityInfo->GetDHId()), + "Sync full remote device info from DB."); } return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 298cab2e..35f248b7 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -16,12 +16,10 @@ #include "offline_task.h" #include -#include - -#include "hisysevent.h" #include "anonymous_string.h" #include "capability_info_manager.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -105,18 +103,9 @@ void OffLineTask::CreateDisableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "DISABLE_TASK", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), - "DHID", (iter->GetDHId()).c_str(), - "MSG", "dhfwk dhfwk create disable task."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteAbleTaskMsg(DISABLE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), + "dhfwk create disable task."); } } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index 85ddf03c..45e23ff7 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -15,12 +15,9 @@ #include "online_task.h" -#include - -#include "hisysevent.h" - #include "anonymous_string.h" #include "capability_info_manager.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -107,18 +104,9 @@ void OnLineTask::CreateEnableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - "ENABLE_TASK", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "DEVID", GetAnonyString(GetDeviceIdByUUID(GetUUID())).c_str(), - "DHID", (iter->GetDHId()).c_str(), - "MSG", "dhfwk dhfwk create enable task."); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + HiSysEventWriteAbleTaskMsg(ENABLE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), + "dhfwk create enable task."); } } } // namespace DistributedHardware diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 27018ede..dfd17d9d 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -29,6 +29,7 @@ ohos_shared_library("distributedhardwareutils") { sources = [ "src/anonymous_string.cpp", + "src/dh_utils_hisysevent.cpp", "src/dh_utils_tool.cpp", "src/log/dh_log.cpp", ] @@ -49,6 +50,7 @@ ohos_shared_library("distributedhardwareutils") { "bundle_framework:appexecfwk_core", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h new file mode 100644 index 00000000..7bcb1b0f --- /dev/null +++ b/utils/include/dh_utils_hisysevent.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H +#define OHOS_DISTRIBUTED_HARDWARE_DHUTIL_HISYSEVENT_H + +#include + +#include "hisysevent.h" + +#include "device_type.h" + +namespace OHOS { +namespace DistributedHardware { +const std::string DHFWK_SA_START = "DHFWK_SA_START"; +const std::string DHFWK_SA_STOP = "DHFWK_SA_STOP"; +const std::string COMP_LOAD = "COMP_LOAD"; +const std::string FILE_PARSE_ERROR = "FILE_PARSE_ERROR"; +const std::string COMP_SO_LOAD_ERROR = "COMP_SO_LOAD_ERROR"; +const std::string COMP_RELEASE = "COMP_RELEASE"; +const std::string COMP_RELEASE_ERROR = "COMP_RELEASE_ERROR"; +const std::string ON_LINE_TASK = "ON_LINE_TASK"; +const std::string OFF_LINE_TASK = "OFF_LINE_TASK"; +const std::string ENABLE_TASK = "ENABLE_TASK"; +const std::string DISABLE_TASK = "DISABLE_TASK"; +const std::string ENABLE_FAILED = "ENABLE_FAILED"; +const std::string DISABLE_FAILED = "DISABLE_FAILED"; +const std::string DB_DATA_NOTIFY = "DB_DATA_NOTIFY"; + +void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &msg); +void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &soName, const std::string &msg); +void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const DHType dhType, int32_t ret, const std::string &msg); +void HiSysEventWriteOnOffLineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyUUID, const std::string &msg); +void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); +void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDHId, int32_t ret, const std::string &msg); +void HiSysEventWriteDBDataNotifyMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp new file mode 100644 index 00000000..dfde1f54 --- /dev/null +++ b/utils/src/dh_utils_hisysevent.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 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 "dh_utils_hisysevent.h" + +#include +#include + +#include "anonymous_string.h" +#include "distributed_hardware_errno.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +namespace { +std::unordered_map g_mapDhTypeName = { + { DHType::UNKNOWN, "UNKNOWN" }, + { DHType::CAMERA, "CAMERA" }, + { DHType::MIC, "MIC" }, + { DHType::SPEAKER, "SPEAKER" }, + { DHType::DISPLAY, "DISPLAY" }, + { DHType::GPS, "GPS" }, + { DHType::BUTTON, "BUTTON" }, + { DHType::HFP, "HFP" }, + { DHType::A2D, "A2D" }, + { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, + { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, +}; +} + +void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &msg) +{ + int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "MSG", msg.c_str()); + if (ret != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, ret:%d", ret); + } +} + +void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &soName, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "SONAME", soName.c_str(), + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const DHType dhType, int32_t ret, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DHTYPE", (g_mapDhTypeName[dhType]).c_str(), + "RESULT", ret, + "MSG", (g_mapDhTypeName[dhType] + msg).c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteOnOffLineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyUUID, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DEVID", anonyDevid.c_str(), + "UUID", anonyUUID.c_str(), + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DEVID", anonyDevid.c_str(), + "DHID", anonyDHId.c_str(), + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDHId, int32_t ret, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DHID", anonyDHId.c_str(), + "RESULT", ret, + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteDBDataNotifyMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DEVID", anonyDevid.c_str(), + "DHID", anonyDHId.c_str(), + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file -- Gitee From 7d7d27f1fd5fa852d28e8c095531e165fb4df495 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 31 May 2022 17:20:19 +0800 Subject: [PATCH 38/55] add hisysevent Signed-off-by: wanderer-dl122 --- utils/src/dh_utils_hisysevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index dfde1f54..a34f5cd2 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -75,7 +75,7 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview eventType, "DHTYPE", (g_mapDhTypeName[dhType]).c_str(), "RESULT", ret, - "MSG", (g_mapDhTypeName[dhType] + msg).c_str()); + "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } -- Gitee From bf3b03d07c6ba95a241e828d89b677055407e673 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 31 May 2022 17:28:18 +0800 Subject: [PATCH 39/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/resourcemanager/capability_info_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp index e6b30a37..47d2a0a5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp @@ -136,7 +136,7 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; - HiSysEventWriteAbleTaskMsg(DB_DATA_NOTIFY, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + HiSysEventWriteDBDataNotifyMsg(DB_DATA_NOTIFY, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, GetAnonyString(capabilityInfo->GetDeviceId()), GetAnonyString(capabilityInfo->GetDHId()), "Sync full remote device info from DB."); } -- Gitee From 902e6db3455d1cb945398633bee03a7d3e7ddef8 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 1 Jun 2022 14:25:33 +0800 Subject: [PATCH 40/55] add hisysevent Signed-off-by: wanderer-dl122 --- common/utils/include/device_type.h | 14 +++++++++++ .../src/distributed_hardware_manager.cpp | 1 + utils/src/dh_utils_hisysevent.cpp | 24 ++++++------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/common/utils/include/device_type.h b/common/utils/include/device_type.h index 03a4f819..563fcb2a 100644 --- a/common/utils/include/device_type.h +++ b/common/utils/include/device_type.h @@ -17,6 +17,7 @@ #define OHOS_DISTRIBUTED_HARDWARE_DEVICE_TYPE_H #include +#include namespace OHOS { namespace DistributedHardware { @@ -35,6 +36,19 @@ enum class DHType : uint32_t { MAX_DH = 0x80000000 }; +const std::unordered_map DHTypeStrMap = { + { DHType::CAMERA, "CAMERA" }, + { DHType::MIC, "MIC" }, + { DHType::SPEAKER, "SPEAKER" }, + { DHType::DISPLAY, "DISPLAY" }, + { DHType::GPS, "GPS" }, + { DHType::BUTTON, "BUTTON" }, + { DHType::HFP, "HFP" }, + { DHType::A2D, "A2D" }, + { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, + { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, +}; + struct DeviceInfo { std::string uuid; std::string deviceId; diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 7e1f83fc..7fee5885 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -154,6 +154,7 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::OFF_LINE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); + DHContext::GetInstance().RemoveOnlineDevice(realUUID); CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index a34f5cd2..e793c6b4 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -23,22 +23,6 @@ namespace OHOS { namespace DistributedHardware { -namespace { -std::unordered_map g_mapDhTypeName = { - { DHType::UNKNOWN, "UNKNOWN" }, - { DHType::CAMERA, "CAMERA" }, - { DHType::MIC, "MIC" }, - { DHType::SPEAKER, "SPEAKER" }, - { DHType::DISPLAY, "DISPLAY" }, - { DHType::GPS, "GPS" }, - { DHType::BUTTON, "BUTTON" }, - { DHType::HFP, "HFP" }, - { DHType::A2D, "A2D" }, - { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, - { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, -}; -} - void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &msg) { @@ -69,11 +53,17 @@ void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t ret, const std::string &msg) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(dhType); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, - "DHTYPE", (g_mapDhTypeName[dhType]).c_str(), + "DHTYPE", dhTypeStr.c_str(), "RESULT", ret, "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { -- Gitee From bceff2cf87ab2d93cc1e1d5028879cf4697c9755 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 2 Jun 2022 17:23:56 +0800 Subject: [PATCH 41/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 64 +++++++------------ .../distributed_hardware_manager_factory.cpp | 6 +- .../src/distributed_hardware_service.cpp | 7 +- .../src/componentloader/component_loader.cpp | 14 ++-- .../componentmanager/component_disable.cpp | 4 +- .../src/componentmanager/component_enable.cpp | 4 +- .../src/distributed_hardware_manager.cpp | 6 -- .../src/hidumphelper/enabled_comps_dump.cpp | 4 +- .../capability_info_manager.cpp | 5 -- .../src/task/offline_task.cpp | 2 +- .../src/task/online_task.cpp | 2 +- utils/include/dh_utils_hisysevent.h | 27 ++++---- utils/src/dh_utils_hisysevent.cpp | 20 +----- 13 files changed, 59 insertions(+), 106 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index c411e935..82b82e9e 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -39,76 +39,58 @@ domain: DHFWK -DHFWK_SA_START: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start on demand} - MSG: {type: STRING, desc: dhfwk sa start} +DHFWK_INIT_BEGIN: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start on demand and init} + MSG: {type: STRING, desc: dhfwk sa start init} -DHFWK_SA_STOP: +DHFWK_INIT_END: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa init end} + MSG: {type: STRING, desc: dhfwk sa init end} + +DHFWK_INIT_FAIL: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk sa init failed} + ERR_CODE: {type: INT32, desc: dhfwk sa init failed result} + MSG: {type: STRING, desc: dhfwk sa init failed} + +DHFWK_EXIT_BEGIN: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} MSG: {type: STRING, desc: dhfwk sa stop} -COMP_LOAD: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk load all components} - MSG: {type: STRING, desc: dhfwk load all components} - -FILE_PARSE_ERROR: - __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} - SONAME: {type: STRING, desc: component so name} - MSG: {type: STRING, desc: dhfwk component so config file canonicalization failed} +DHFWK_EXIT_END: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} + MSG: {type: STRING, desc: dhfwk sa stop} -COMP_SO_LOAD_ERROR: +DHFWK_COMP_LOAD_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} SONAME: {type: STRING, desc: component so name} MSG: {type: STRING, desc: dhfwk component so open failed} -COMP_RELEASE: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk all components release} - MSG: {type: STRING, desc: dhfwk all components release} - -COMP_RELEASE_ERROR: +DHFWK_COMP_RELEASE_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} DHTYPE: {type: STRING, desc: dhtype} RESULT: {type: INT32, desc: dlclose failed result} MSG: {type: STRING, desc: dhfwk component dlclose failed} -ON_LINE_TASK: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create online task} - DEVID: {type: STRING, desc: device id} - UUID: {type: STRING, desc: uuid} - MSG: {type: STRING, desc: dhfwk create online task} - -OFF_LINE_TASK: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create offline task} - DEVID: {type: STRING, desc: device id} - UUID: {type: STRING, desc: uuid} - MSG: {type: STRING, desc: dhfwk create offline task} - -ENABLE_TASK: +DHFWK_DEV_ENABLE: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create enable task} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk create enable task} -DISABLE_TASK: +DHFWK_DEV_DISABLE: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} MSG: {type: STRING, desc: dhfwk create disable task} -ENABLE_FAILED: +DHFWK_DH_REGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware enable failed} DHID: {type: STRING, desc: component id} - RESULT: {type: INT32, desc: dhfwk distributed hardware enable result} + RESULT: {type: INT32, desc: dhfwk distributed hardware enable failed result} MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} -DISABLE_FAILED: +DHFWK_DH_UNREGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware disable failed} DHID: {type: STRING, desc: component id} RESULT: {type: INT32, desc: dhfwk distributed hardware disable result} MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} - -DB_DATA_NOTIFY: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk Sync full remote device info from DB} - DEVID: {type: STRING, desc: device id} - DHID: {type: STRING, desc: component id} - MSG: {type: STRING, desc: dhfwk Sync full remote device info from DB} diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index d5fe0045..e52cccb7 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -62,6 +62,8 @@ bool DistributedHardwareManagerFactory::Init() void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); + HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa exit begin."); // release all the resources synchronously distributedHardwareMgrPtr_->Release(); @@ -76,8 +78,8 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() DeviceManager::GetInstance().GetTrustedDeviceList(DH_FWK_PKG_NAME, "", deviceList); if (deviceList.size() == 0) { DHLOGI("DM report devices offline, exit sa process"); - HiSysEventWriteMsg(DHFWK_SA_STOP, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "dhfwk sa stop on demand."); + HiSysEventWriteMsg(DHFWK_EXIT_END, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa exit end."); exit(0); } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index a9fbc295..41606b23 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -39,7 +39,8 @@ DistributedHardwareService::DistributedHardwareService(int32_t saId, bool runOnC void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); - HiSysEventWriteMsg(DHFWK_SA_START, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa start on demand."); + HiSysEventWriteMsg(DHFWK_INIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa start on demand."); if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); @@ -67,9 +68,13 @@ bool DistributedHardwareService::Init() auto ret = AccessManager::GetInstance()->Init(); if (ret != DH_FWK_SUCCESS) { DHLOGI("DistributedHardwareService::Init failed."); + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + ret, "dhfwk sa init fail."); return false; } DHLOGI("DistributedHardwareService::Init init success."); + HiSysEventWriteMsg(DHFWK_INIT_END, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa init end."); return true; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 3efb8c4d..9223af08 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -141,15 +141,13 @@ void *ComponentLoader::GetHandler(const std::string &soName) if (soName.length() == 0 || (LIB_LOAD_PATH.length() + soName.length()) > PATH_MAX || realpath((LIB_LOAD_PATH + soName).c_str(), path) == nullptr) { DHLOGE("File canonicalization failed"); - HiSysEventWriteCompLoadMsg(FILE_PARSE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - soName, "dhfwk component so config file canonicalization failed."); return nullptr; } void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { DHLOGE("%s handler load failed.", path); - HiSysEventWriteCompLoadMsg(COMP_SO_LOAD_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompLoadMsg(DHFWK_COMP_LOAD_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, soName, "dhfwk component so open failed."); return nullptr; @@ -249,8 +247,6 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - HiSysEventWriteMsg(COMP_LOAD, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "dhfwk load all components."); std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { @@ -280,8 +276,6 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); - HiSysEventWriteMsg(COMP_RELEASE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "dhfwk all components release."); int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); @@ -302,7 +296,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release hardware handler failed."); } return ret; @@ -316,7 +310,7 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release source failed."); } return ret; @@ -330,7 +324,7 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(COMP_RELEASE_ERROR, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release sink failed."); } return ret; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 95b7cce4..4adbfef5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -44,7 +44,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (ret != DH_FWK_SUCCESS) { DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DISABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -56,7 +56,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (!waitStatus) { DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DISABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, "dhfwk distributed hardware disable timeout."); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 2a1cac35..310ac075 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -44,7 +44,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(ENABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -56,7 +56,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (!waitStatus) { DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(ENABLE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, "dhfwk distributed hardware enable timeout."); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index 7fee5885..fc7693a9 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -114,9 +114,6 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId DHContext::GetInstance().AddOnlineDevice(uuid, networkId); CapabilityInfoManager::GetInstance()->CreateManualSyncCount(GetDeviceIdByUUID(uuid)); - HiSysEventWriteOnOffLineMsg(ON_LINE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(GetDeviceIdByUUID(uuid)), GetAnonyString(uuid), "dhfwk create online task."); - return DH_FWK_SUCCESS; } @@ -158,9 +155,6 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI DHContext::GetInstance().RemoveOnlineDevice(realUUID); CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); - HiSysEventWriteOnOffLineMsg(OFF_LINE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(GetDeviceIdByUUID(realUUID)), GetAnonyString(realUUID), "dhfwk create offline task."); - return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp index feeb4fe5..054984e1 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp @@ -22,7 +22,7 @@ IMPLEMENT_SINGLE_INSTANCE(EnabledCompsDump); void EnabledCompsDump::DumpEnabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId) { - HidumpCompInfo info (GetDeviceIdByUUID(uuid), dhType, dhId); + HidumpCompInfo info(GetDeviceIdByUUID(uuid), dhType, dhId); std::lock_guard lock(compInfosMutex_); compInfoSet_.emplace(info); @@ -30,7 +30,7 @@ void EnabledCompsDump::DumpEnabledComp(const std::string &uuid, const DHType dhT void EnabledCompsDump::DumpDisabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId) { - HidumpCompInfo info (GetDeviceIdByUUID(uuid), dhType, dhId); + HidumpCompInfo info(GetDeviceIdByUUID(uuid), dhType, dhId); std::lock_guard lock(compInfosMutex_); auto it = compInfoSet_.find(info); diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp index 47d2a0a5..07e05473 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp @@ -20,7 +20,6 @@ #include "capability_utils.h" #include "constants.h" #include "dh_context.h" -#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -135,10 +134,6 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() continue; } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; - - HiSysEventWriteDBDataNotifyMsg(DB_DATA_NOTIFY, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(capabilityInfo->GetDeviceId()), GetAnonyString(capabilityInfo->GetDHId()), - "Sync full remote device info from DB."); } return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 35f248b7..2c0dbc1a 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -103,7 +103,7 @@ void OffLineTask::CreateDisableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - HiSysEventWriteAbleTaskMsg(DISABLE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + HiSysEventWriteAbleTaskMsg(DHFWK_DEV_DISABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), "dhfwk create disable task."); } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index 45e23ff7..e5cd0da3 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -104,7 +104,7 @@ void OnLineTask::CreateEnableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - HiSysEventWriteAbleTaskMsg(ENABLE_TASK, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + HiSysEventWriteAbleTaskMsg(DHFWK_DEV_ENABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), "dhfwk create enable task."); } diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h index 7bcb1b0f..a2b8df17 100644 --- a/utils/include/dh_utils_hisysevent.h +++ b/utils/include/dh_utils_hisysevent.h @@ -24,20 +24,19 @@ namespace OHOS { namespace DistributedHardware { -const std::string DHFWK_SA_START = "DHFWK_SA_START"; -const std::string DHFWK_SA_STOP = "DHFWK_SA_STOP"; +const std::string DHFWK_INIT_BEGIN = "DHFWK_INIT_BEGIN"; +const std::string DHFWK_INIT_END = "DHFWK_INIT_END"; +const std::string DHFWK_INIT_FAIL ="DHFWK_INIT_FAIL"; +const std::string DHFWK_EXIT_BEGIN = "DHFWK_EXIT_BEGIN"; +const std::string DHFWK_EXIT_END = "DHFWK_EXIT_END"; const std::string COMP_LOAD = "COMP_LOAD"; -const std::string FILE_PARSE_ERROR = "FILE_PARSE_ERROR"; -const std::string COMP_SO_LOAD_ERROR = "COMP_SO_LOAD_ERROR"; +const std::string DHFWK_COMP_LOAD_FAIL = "DHFWK_COMP_LOAD_FAIL"; const std::string COMP_RELEASE = "COMP_RELEASE"; -const std::string COMP_RELEASE_ERROR = "COMP_RELEASE_ERROR"; -const std::string ON_LINE_TASK = "ON_LINE_TASK"; -const std::string OFF_LINE_TASK = "OFF_LINE_TASK"; -const std::string ENABLE_TASK = "ENABLE_TASK"; -const std::string DISABLE_TASK = "DISABLE_TASK"; -const std::string ENABLE_FAILED = "ENABLE_FAILED"; -const std::string DISABLE_FAILED = "DISABLE_FAILED"; -const std::string DB_DATA_NOTIFY = "DB_DATA_NOTIFY"; +const std::string DHFWK_COMP_RELEASE_FAIL = "DHFWK_COMP_RELEASE_FAIL"; +const std::string DHFWK_DEV_ENABLE = "DHFWK_DEV_ENABLE"; +const std::string DHFWK_DEV_DISABLE = "DHFWK_DEV_DISABLE"; +const std::string DHFWK_DH_REGISTER_FAIL = "DHFWK_DH_REGISTER_FAIL"; +const std::string DHFWK_DH_UNREGISTER_FAIL = "DHFWK_DH_UNREGISTER_FAIL"; void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &msg); @@ -45,14 +44,10 @@ void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX const std::string &soName, const std::string &msg); void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t ret, const std::string &msg); -void HiSysEventWriteOnOffLineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyUUID, const std::string &msg); void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDHId, int32_t ret, const std::string &msg); -void HiSysEventWriteDBDataNotifyMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index e793c6b4..b509e7ef 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -26,13 +26,13 @@ namespace DistributedHardware { void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &msg) { - int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write( + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, "MSG", msg.c_str()); - if (ret != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, ret:%d", ret); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); } } @@ -71,20 +71,6 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview } } -void HiSysEventWriteOnOffLineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyUUID, const std::string &msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - status.c_str(), - eventType, - "DEVID", anonyDevid.c_str(), - "UUID", anonyUUID.c_str(), - "MSG", msg.c_str()); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } -} void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) -- Gitee From a2daa894459b0ee734da6f0e2c62146c2b7480d0 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 10:46:03 +0800 Subject: [PATCH 42/55] =?UTF-8?q?=E6=B7=BB=E5=8A=A0selinux=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_service.cpp | 4 +- .../src/task/offline_task.cpp | 2 +- .../src/task/online_task.cpp | 2 +- utils/include/dh_utils_hisysevent.h | 10 +++-- utils/src/dh_utils_hisysevent.cpp | 39 +++++++++---------- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 41606b23..0447fbfa 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -68,8 +68,8 @@ bool DistributedHardwareService::Init() auto ret = AccessManager::GetInstance()->Init(); if (ret != DH_FWK_SUCCESS) { DHLOGI("DistributedHardwareService::Init failed."); - HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - ret, "dhfwk sa init fail."); + HiSysEventWriteFailedMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + ret, "dhfwk sa init fail."); return false; } DHLOGI("DistributedHardwareService::Init init success."); diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 2c0dbc1a..6b91a396 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -103,7 +103,7 @@ void OffLineTask::CreateDisableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - HiSysEventWriteAbleTaskMsg(DHFWK_DEV_DISABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + HiSysEventWriteCompAbleMsg(DHFWK_DEV_DISABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), "dhfwk create disable task."); } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index e5cd0da3..7c040ffe 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -104,7 +104,7 @@ void OnLineTask::CreateEnableTask() auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - HiSysEventWriteAbleTaskMsg(DHFWK_DEV_ENABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + HiSysEventWriteCompAbleMsg(DHFWK_DEV_ENABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), "dhfwk create enable task."); } diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h index a2b8df17..0b0f6054 100644 --- a/utils/include/dh_utils_hisysevent.h +++ b/utils/include/dh_utils_hisysevent.h @@ -40,14 +40,16 @@ const std::string DHFWK_DH_UNREGISTER_FAIL = "DHFWK_DH_UNREGISTER_FAIL"; void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &msg); +void HiSysEventWriteFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + int32_t errCode, const std::string &msg); void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &soName, const std::string &msg); void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const DHType dhType, int32_t ret, const std::string &msg); -void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const DHType dhType, int32_t errCode, const std::string &msg); +void HiSysEventWriteCompAbleMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); -void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDHId, int32_t ret, const std::string &msg); +void HiSysEventWriteCompAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDHId, int32_t errCode, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index b509e7ef..fd5ca453 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -36,6 +36,20 @@ void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysE } } +void HiSysEventWriteFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + int32_t errCode, const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "ERR_CODE", errCode + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &soName, const std::string &msg) { @@ -51,7 +65,7 @@ void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX } void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const DHType dhType, int32_t ret, const std::string &msg) + const DHType dhType, int32_t errCode, const std::string &msg) { std::string dhTypeStr = "UNKNOWN"; auto it = DHTypeStrMap.find(dhType); @@ -64,7 +78,7 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview status.c_str(), eventType, "DHTYPE", dhTypeStr.c_str(), - "RESULT", ret, + "RESULT", errCode, "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); @@ -72,7 +86,7 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview } -void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteCompAbleMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( @@ -88,29 +102,14 @@ void HiSysEventWriteAbleTaskMsg(const std::string &status, const OHOS::HiviewDFX } void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDHId, int32_t ret, const std::string &msg) + const std::string &anonyDHId, int32_t errCode, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, "DHID", anonyDHId.c_str(), - "RESULT", ret, - "MSG", msg.c_str()); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } -} - -void HiSysEventWriteDBDataNotifyMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - status.c_str(), - eventType, - "DEVID", anonyDevid.c_str(), - "DHID", anonyDHId.c_str(), + "RESULT", errCode, "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); -- Gitee From 87dd6d28b868d7ab8476cac001cb951abfc6ce26 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 12:10:51 +0800 Subject: [PATCH 43/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 8 +--- .../distributed_hardware_manager_factory.cpp | 2 +- .../src/distributed_hardware_service.cpp | 8 ++-- .../src/componentloader/component_loader.cpp | 5 +-- .../componentmanager/component_disable.cpp | 4 +- .../src/componentmanager/component_enable.cpp | 4 +- .../componentmanager/component_manager.cpp | 5 +++ .../src/distributed_hardware_manager.cpp | 3 ++ .../src/task/offline_task.cpp | 5 --- .../src/task/online_task.cpp | 5 --- utils/include/dh_utils_hisysevent.h | 16 +++----- utils/src/dh_utils_hisysevent.cpp | 37 +++++++++---------- 12 files changed, 44 insertions(+), 58 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 82b82e9e..8032801b 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -71,13 +71,7 @@ DHFWK_COMP_RELEASE_FAIL: RESULT: {type: INT32, desc: dlclose failed result} MSG: {type: STRING, desc: dhfwk component dlclose failed} -DHFWK_DEV_ENABLE: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create enable task} - DEVID: {type: STRING, desc: device id} - DHID: {type: STRING, desc: component id} - MSG: {type: STRING, desc: dhfwk create enable task} - -DHFWK_DEV_DISABLE: +DHFWK_DEV_OFFLINE: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} DEVID: {type: STRING, desc: device id} DHID: {type: STRING, desc: component id} diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index e52cccb7..b50a6fe5 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -63,7 +63,7 @@ void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "dhfwk sa exit begin."); + "dhfwk sa exit begin."); // release all the resources synchronously distributedHardwareMgrPtr_->Release(); diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 0447fbfa..fecf6941 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -61,6 +61,8 @@ bool DistributedHardwareService::Init() bool ret = Publish(this); if (!ret) { DHLOGE("DistributedHardwareService::Init Publish failed!"); + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "dhfwk sa init publish failed."); return false; } registerToService_ = true; @@ -68,13 +70,13 @@ bool DistributedHardwareService::Init() auto ret = AccessManager::GetInstance()->Init(); if (ret != DH_FWK_SUCCESS) { DHLOGI("DistributedHardwareService::Init failed."); - HiSysEventWriteFailedMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - ret, "dhfwk sa init fail."); + HiSysEventWriteErrCodeMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + ret, "dhfwk sa AccessManager init fail."); return false; } DHLOGI("DistributedHardwareService::Init init success."); HiSysEventWriteMsg(DHFWK_INIT_END, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "dhfwk sa init end."); + "dhfwk sa init success."); return true; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 9223af08..23a88164 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -147,9 +147,8 @@ void *ComponentLoader::GetHandler(const std::string &soName) void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { DHLOGE("%s handler load failed.", path); - HiSysEventWriteCompLoadMsg(DHFWK_COMP_LOAD_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - soName, "dhfwk component so open failed."); - + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "dhfwk so open failed, soname : " + soName); return nullptr; } return pHandler; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 4adbfef5..76db5fda 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -44,7 +44,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (ret != DH_FWK_SUCCESS) { DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -56,7 +56,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (!waitStatus) { DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, "dhfwk distributed hardware disable timeout."); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 310ac075..53656f43 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -44,7 +44,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -56,7 +56,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (!waitStatus) { DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, "dhfwk distributed hardware enable timeout."); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index e4335167..5c05167d 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -25,6 +25,7 @@ #include "component_loader.h" #include "constants.h" #include "dh_context.h" +#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -70,9 +71,13 @@ int32_t ComponentManager::Init() if (!WaitForResult(Action::START_SOURCE, sourceResult)) { DHLOGE("StartSource failed, some virtual components maybe cannot work, but want to continue"); + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "dhfwk start source failed."); } if (!WaitForResult(Action::START_SINK, sinkResult)) { DHLOGE("StartSink failed, some virtual components maybe cannot work, but want to continue"); + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "dhfwk start sink failed."); } DHLOGI("Init component success"); diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index fc7693a9..d23d7e8c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -155,6 +155,9 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI DHContext::GetInstance().RemoveOnlineDevice(realUUID); CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); + HiSysEventWriteCompOfflineMsg(DHFWK_DEV_OFFLINE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + GetAnonyString(GetDeviceIdByUUID(realUUID)), "dhfwk device offline event."); + return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index 6b91a396..fa12f057 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -19,7 +19,6 @@ #include "anonymous_string.h" #include "capability_info_manager.h" -#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -102,10 +101,6 @@ void OffLineTask::CreateDisableTask() }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - - HiSysEventWriteCompAbleMsg(DHFWK_DEV_DISABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), - "dhfwk create disable task."); } } diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index 7c040ffe..a8d6f5f5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -17,7 +17,6 @@ #include "anonymous_string.h" #include "capability_info_manager.h" -#include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -103,10 +102,6 @@ void OnLineTask::CreateEnableTask() }; auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this()); TaskExecutor::GetInstance().PushTask(task); - - HiSysEventWriteCompAbleMsg(DHFWK_DEV_ENABLE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(GetDeviceIdByUUID(GetUUID())), GetAnonyString(iter->GetDHId()), - "dhfwk create enable task."); } } } // namespace DistributedHardware diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h index 0b0f6054..baeadd45 100644 --- a/utils/include/dh_utils_hisysevent.h +++ b/utils/include/dh_utils_hisysevent.h @@ -26,28 +26,22 @@ namespace OHOS { namespace DistributedHardware { const std::string DHFWK_INIT_BEGIN = "DHFWK_INIT_BEGIN"; const std::string DHFWK_INIT_END = "DHFWK_INIT_END"; -const std::string DHFWK_INIT_FAIL ="DHFWK_INIT_FAIL"; +const std::string DHFWK_INIT_FAIL = "DHFWK_INIT_FAIL"; const std::string DHFWK_EXIT_BEGIN = "DHFWK_EXIT_BEGIN"; const std::string DHFWK_EXIT_END = "DHFWK_EXIT_END"; -const std::string COMP_LOAD = "COMP_LOAD"; -const std::string DHFWK_COMP_LOAD_FAIL = "DHFWK_COMP_LOAD_FAIL"; -const std::string COMP_RELEASE = "COMP_RELEASE"; +const std::string DHFWK_DEV_OFFLINE = "DHFWK_DEV_OFFLINE"; const std::string DHFWK_COMP_RELEASE_FAIL = "DHFWK_COMP_RELEASE_FAIL"; -const std::string DHFWK_DEV_ENABLE = "DHFWK_DEV_ENABLE"; -const std::string DHFWK_DEV_DISABLE = "DHFWK_DEV_DISABLE"; const std::string DHFWK_DH_REGISTER_FAIL = "DHFWK_DH_REGISTER_FAIL"; const std::string DHFWK_DH_UNREGISTER_FAIL = "DHFWK_DH_UNREGISTER_FAIL"; void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &msg); -void HiSysEventWriteFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, int32_t errCode, const std::string &msg); -void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &soName, const std::string &msg); void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg); -void HiSysEventWriteCompAbleMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg); +void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &msg); void HiSysEventWriteCompAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDHId, int32_t errCode, const std::string &msg); } // namespace DistributedHardware diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index fd5ca453..dab8b424 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -36,33 +36,33 @@ void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysE } } -void HiSysEventWriteFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, int32_t errCode, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, - "ERR_CODE", errCode + "ERR_CODE", errCode, "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } -void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &soName, const std::string &msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, - status.c_str(), - eventType, - "SONAME", soName.c_str(), - "MSG", msg.c_str()); - if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } -} +// void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +// const std::string &soName, const std::string &msg) +// { +// int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( +// OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, +// status.c_str(), +// eventType, +// "SONAME", soName.c_str(), +// "MSG", msg.c_str()); +// if (res != DH_FWK_SUCCESS) { +// DHLOGE("Write HiSysEvent error, res:%d", res); +// } +// } void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg) @@ -86,22 +86,21 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview } -void HiSysEventWriteCompAbleMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &anonyDHId, const std::string &msg) +void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyDevid, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, "DEVID", anonyDevid.c_str(), - "DHID", anonyDHId.c_str(), "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } -void HiSysEventWriteAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteCompAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDHId, int32_t errCode, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( -- Gitee From fa8c317a04893204716be87520267b4baa5ba5a2 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 12:14:39 +0800 Subject: [PATCH 44/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 3 --- utils/src/dh_utils_hisysevent.cpp | 14 -------------- 2 files changed, 17 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 23a88164..0b4d0beb 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -141,7 +141,6 @@ void *ComponentLoader::GetHandler(const std::string &soName) if (soName.length() == 0 || (LIB_LOAD_PATH.length() + soName.length()) > PATH_MAX || realpath((LIB_LOAD_PATH + soName).c_str(), path) == nullptr) { DHLOGE("File canonicalization failed"); - return nullptr; } void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); @@ -246,7 +245,6 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); @@ -275,7 +273,6 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); - int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); iter != compHandlerMap_.end(); iter++) { diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index dab8b424..1f90f79e 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -50,20 +50,6 @@ void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX: } } -// void HiSysEventWriteCompLoadMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, -// const std::string &soName, const std::string &msg) -// { -// int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( -// OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, -// status.c_str(), -// eventType, -// "SONAME", soName.c_str(), -// "MSG", msg.c_str()); -// if (res != DH_FWK_SUCCESS) { -// DHLOGE("Write HiSysEvent error, res:%d", res); -// } -// } - void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg) { -- Gitee From dd28cb6e06be6e3bc870db30314bb9295e228122 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 15:35:11 +0800 Subject: [PATCH 45/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 8032801b..228bc659 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -60,11 +60,6 @@ DHFWK_EXIT_END: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} MSG: {type: STRING, desc: dhfwk sa stop} -DHFWK_COMP_LOAD_FAIL: - __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component load error occured} - SONAME: {type: STRING, desc: component so name} - MSG: {type: STRING, desc: dhfwk component so open failed} - DHFWK_COMP_RELEASE_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} DHTYPE: {type: STRING, desc: dhtype} -- Gitee From 9e2a5bff885fc8126c0ba979975b388c096f544d Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 15:58:56 +0800 Subject: [PATCH 46/55] add hisysevent Signed-off-by: wanderer-dl122 --- utils/src/dh_utils_hisysevent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index 1f90f79e..0ba32505 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -71,7 +71,6 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview } } - void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &msg) { -- Gitee From e245d2d4f8482b832edae41f202c696fd024a739 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 16:15:23 +0800 Subject: [PATCH 47/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 25 ++++++++++--------- .../include/hidumphelper/enabled_comps_dump.h | 14 +++++------ .../src/componentloader/component_loader.cpp | 6 ++--- .../componentmanager/component_disable.cpp | 8 +++--- .../src/componentmanager/component_enable.cpp | 8 +++--- .../componentmanager/component_manager.cpp | 8 +++--- .../src/distributed_hardware_manager.cpp | 2 +- .../src/hidumphelper/enabled_comps_dump.cpp | 8 +++--- .../src/hidumphelper/hidump_helper.cpp | 14 ++++++----- utils/include/dh_utils_hisysevent.h | 6 ++--- utils/src/dh_utils_hisysevent.cpp | 21 ++++++++-------- 11 files changed, 62 insertions(+), 58 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 228bc659..059ff67f 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -50,36 +50,37 @@ DHFWK_INIT_END: DHFWK_INIT_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk sa init failed} ERR_CODE: {type: INT32, desc: dhfwk sa init failed result} - MSG: {type: STRING, desc: dhfwk sa init failed} + ERR_MSG: {type: STRING, desc: dhfwk sa init failed} DHFWK_EXIT_BEGIN: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start exit on demand} MSG: {type: STRING, desc: dhfwk sa stop} DHFWK_EXIT_END: - __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa stop on demand} + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa finish exit on demand} MSG: {type: STRING, desc: dhfwk sa stop} -DHFWK_COMP_RELEASE_FAIL: +DHFWK_RELEASE_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} DHTYPE: {type: STRING, desc: dhtype} - RESULT: {type: INT32, desc: dlclose failed result} - MSG: {type: STRING, desc: dhfwk component dlclose failed} + ERR_CODE: {type: INT32, desc: dlclose failed result} + ERR_MSG: {type: STRING, desc: dhfwk component dlclose failed} DHFWK_DEV_OFFLINE: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk create disable task} - DEVID: {type: STRING, desc: device id} - DHID: {type: STRING, desc: component id} + NETWORKID: {type: STRING, desc: network id} MSG: {type: STRING, desc: dhfwk create disable task} DHFWK_DH_REGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware enable failed} + NETWORKID: {type: STRING, desc: network id} DHID: {type: STRING, desc: component id} - RESULT: {type: INT32, desc: dhfwk distributed hardware enable failed result} - MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} + ERR_CODE: {type: INT32, desc: dhfwk distributed hardware enable failed result} + ERR_MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} DHFWK_DH_UNREGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware disable failed} + NETWORKID: {type: STRING, desc: network id} DHID: {type: STRING, desc: component id} - RESULT: {type: INT32, desc: dhfwk distributed hardware disable result} - MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} + ERR_CODE: {type: INT32, desc: dhfwk distributed hardware disable result} + ERR_MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} diff --git a/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h b/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h index d99cd0f2..44dbcbca 100644 --- a/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h +++ b/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h @@ -26,25 +26,25 @@ namespace OHOS { namespace DistributedHardware { struct HidumpCompInfo { - std::string deviceId_; + std::string networkId_; std::string dhId_; DHType dhType_; - HidumpCompInfo(std::string deviceId, DHType dhType, std::string dhId) - : deviceId_(deviceId), dhId_(dhId), dhType_(dhType) {} + HidumpCompInfo(std::string networkId, DHType dhType, std::string dhId) + : networkId_(networkId), dhId_(dhId), dhType_(dhType) {} bool operator < (const HidumpCompInfo &other) const { - return (((this->deviceId_ == other.deviceId_) && (this->dhId_ < other.dhId_)) || - (this->deviceId_ < other.deviceId_)); + return (((this->networkId_ == other.networkId_) && (this->dhId_ < other.dhId_)) || + (this->networkId_ < other.networkId_)); } }; class EnabledCompsDump { DECLARE_SINGLE_INSTANCE_BASE(EnabledCompsDump); public: - void DumpEnabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId); - void DumpDisabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId); + void DumpEnabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId); + void DumpDisabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId); void Dump(std::set &compInfoSet); diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 0b4d0beb..ce6d4f77 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -292,7 +292,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release hardware handler failed."); } return ret; @@ -306,7 +306,7 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release source failed."); } return ret; @@ -320,7 +320,7 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); - HiSysEventWriteCompReleaseMsg(DHFWK_COMP_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release sink failed."); } return ret; diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 76db5fda..62c615a3 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -44,8 +44,8 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (ret != DH_FWK_SUCCESS) { DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(dhId).c_str(), ret, "dhfwk unregister distributed hardware failed."); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(networkId), GetAnonyString(dhId), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -56,8 +56,8 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin if (!waitStatus) { DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(networkId), GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, "dhfwk distributed hardware disable timeout."); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 53656f43..030c8e7a 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -44,8 +44,8 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(dhId).c_str(), ret, "dhfwk register distributed hardware failed."); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(networkId), GetAnonyString(dhId), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -56,8 +56,8 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string if (!waitStatus) { DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); - HiSysEventWriteCompAbleFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(dhId).c_str(), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(networkId), GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, "dhfwk distributed hardware enable timeout."); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 5c05167d..ebd55467 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -263,7 +263,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); - EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); + EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } DHLOGE("enable failed, retryCount = %d", retryCount); @@ -272,7 +272,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); + EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return result; } @@ -294,7 +294,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); - EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); + EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); @@ -303,7 +303,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); + EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return result; } diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index d23d7e8c..ffccdaa8 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -156,7 +156,7 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI CapabilityInfoManager::GetInstance()->RemoveManualSyncCount(GetDeviceIdByUUID(realUUID)); HiSysEventWriteCompOfflineMsg(DHFWK_DEV_OFFLINE, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - GetAnonyString(GetDeviceIdByUUID(realUUID)), "dhfwk device offline event."); + GetAnonyString(networkId), "dhfwk device offline event."); return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp index 054984e1..c6f45529 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/enabled_comps_dump.cpp @@ -20,17 +20,17 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(EnabledCompsDump); -void EnabledCompsDump::DumpEnabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId) +void EnabledCompsDump::DumpEnabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId) { - HidumpCompInfo info(GetDeviceIdByUUID(uuid), dhType, dhId); + HidumpCompInfo info(networkId, dhType, dhId); std::lock_guard lock(compInfosMutex_); compInfoSet_.emplace(info); } -void EnabledCompsDump::DumpDisabledComp(const std::string &uuid, const DHType dhType, const std::string &dhId) +void EnabledCompsDump::DumpDisabledComp(const std::string &networkId, const DHType dhType, const std::string &dhId) { - HidumpCompInfo info(GetDeviceIdByUUID(uuid), dhType, dhId); + HidumpCompInfo info(networkId, dhType, dhId); std::lock_guard lock(compInfosMutex_); auto it = compInfoSet_.find(info); diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index 03ab7272..b5b86b12 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -181,11 +181,11 @@ int32_t HidumpHelper::ShowAllEnabledComps(std::string &result) for (auto info : compInfoSet) { result.append("\n{"); - result.append("\n DeviceId : "); - result.append(GetAnonyString(info.deviceId_)); - result.append("\n DHType : "); + result.append("\n NetworkId : "); + result.append(GetAnonyString(info.uuId_)); + result.append("\n DHType : "); result.append(g_mapDhTypeName[info.dhType_]); - result.append("\n DHId : "); + result.append("\n DHId : "); result.append(GetAnonyString(info.dhId_)); result.append("\n},"); } @@ -241,11 +241,13 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) } for (auto info : capInfos) { + std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(info.GetDeviceId()); + std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); result.append("\n{"); result.append("\n DeviceName : "); result.append(GetAnonyString(info.GetDeviceName())); - result.append("\n DeviceId : "); - result.append(GetAnonyString(info.GetDeviceId())); + result.append("\n NetworkId : "); + result.append(GetAnonyString(networkId)); result.append("\n DeviceType : "); result.append(std::to_string(info.GetDeviceType())); result.append("\n DHType : "); diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h index baeadd45..00456f78 100644 --- a/utils/include/dh_utils_hisysevent.h +++ b/utils/include/dh_utils_hisysevent.h @@ -30,7 +30,7 @@ const std::string DHFWK_INIT_FAIL = "DHFWK_INIT_FAIL"; const std::string DHFWK_EXIT_BEGIN = "DHFWK_EXIT_BEGIN"; const std::string DHFWK_EXIT_END = "DHFWK_EXIT_END"; const std::string DHFWK_DEV_OFFLINE = "DHFWK_DEV_OFFLINE"; -const std::string DHFWK_COMP_RELEASE_FAIL = "DHFWK_COMP_RELEASE_FAIL"; +const std::string DHFWK_RELEASE_FAIL = "DHFWK_RELEASE_FAIL"; const std::string DHFWK_DH_REGISTER_FAIL = "DHFWK_DH_REGISTER_FAIL"; const std::string DHFWK_DH_UNREGISTER_FAIL = "DHFWK_DH_UNREGISTER_FAIL"; @@ -38,11 +38,11 @@ void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysE const std::string &msg); void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, int32_t errCode, const std::string &msg); -void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg); void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDevid, const std::string &msg); -void HiSysEventWriteCompAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteCompMgrFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDHId, int32_t errCode, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index 0ba32505..5cd86e48 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -44,13 +44,13 @@ void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX: status.c_str(), eventType, "ERR_CODE", errCode, - "MSG", msg.c_str()); + "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } -void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, +void HiSysEventWriteReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg) { std::string dhTypeStr = "UNKNOWN"; @@ -64,37 +64,38 @@ void HiSysEventWriteCompReleaseMsg(const std::string &status, const OHOS::Hiview status.c_str(), eventType, "DHTYPE", dhTypeStr.c_str(), - "RESULT", errCode, - "MSG", msg.c_str()); + "ERR_CODE", errCode, + "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &msg) + const std::string &anonyNetworkId, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, - "DEVID", anonyDevid.c_str(), + "NETWORKID", anonyNetworkId.c_str(), "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } } -void HiSysEventWriteCompAbleFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDHId, int32_t errCode, const std::string &msg) +void HiSysEventWriteCompMgrFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &anonyNetworkId, const std::string &anonyDHId, int32_t errCode, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, + "NETWORKID", anonyNetworkId.c_str(), "DHID", anonyDHId.c_str(), - "RESULT", errCode, - "MSG", msg.c_str()); + "ERR_CODE", errCode, + "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { DHLOGE("Write HiSysEvent error, res:%d", res); } -- Gitee From 087dc6bae7fac5c82ccbb789979faaf07c88f242 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 16:45:32 +0800 Subject: [PATCH 48/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index b5b86b12..85c5e0c3 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -19,6 +19,7 @@ #include "capability_info_manager.h" #include "component_manager.h" +#include "dh_context.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" #include "task_board.h" @@ -182,7 +183,7 @@ int32_t HidumpHelper::ShowAllEnabledComps(std::string &result) for (auto info : compInfoSet) { result.append("\n{"); result.append("\n NetworkId : "); - result.append(GetAnonyString(info.uuId_)); + result.append(GetAnonyString(info.networkId_)); result.append("\n DHType : "); result.append(g_mapDhTypeName[info.dhType_]); result.append("\n DHId : "); -- Gitee From 5e250afd61997dbdb11ff044b367e00246e90843 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 18:36:40 +0800 Subject: [PATCH 49/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_disable.cpp | 4 ++-- .../src/componentmanager/component_enable.cpp | 4 ++-- utils/src/dh_utils_hisysevent.cpp | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 62c615a3..4314457e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -45,7 +45,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(networkId), GetAnonyString(dhId), ret, "dhfwk unregister distributed hardware failed."); + GetAnonyString(dhId), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -57,7 +57,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(networkId), GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, + GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, "dhfwk distributed hardware disable timeout."); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 030c8e7a..5a05ae65 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -45,7 +45,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(networkId), GetAnonyString(dhId), ret, "dhfwk register distributed hardware failed."); + GetAnonyString(dhId), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -57,7 +57,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - GetAnonyString(networkId), GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, + GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, "dhfwk distributed hardware enable timeout."); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index 5cd86e48..aac98804 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.cpp @@ -86,13 +86,12 @@ void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::Hiview } void HiSysEventWriteCompMgrFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyNetworkId, const std::string &anonyDHId, int32_t errCode, const std::string &msg) + const std::string &anonyDHId, int32_t errCode, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, status.c_str(), eventType, - "NETWORKID", anonyNetworkId.c_str(), "DHID", anonyDHId.c_str(), "ERR_CODE", errCode, "ERR_MSG", msg.c_str()); -- Gitee From 09023b5e6cc7c8a10a856f80cd445caac4012736 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 18:59:00 +0800 Subject: [PATCH 50/55] add hisysevent Signed-off-by: wanderer-dl122 --- hisysevent.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 059ff67f..a0e1113c 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -73,14 +73,12 @@ DHFWK_DEV_OFFLINE: DHFWK_DH_REGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware enable failed} - NETWORKID: {type: STRING, desc: network id} DHID: {type: STRING, desc: component id} ERR_CODE: {type: INT32, desc: dhfwk distributed hardware enable failed result} ERR_MSG: {type: STRING, desc: dhfwk distributed hardware enable failed} DHFWK_DH_UNREGISTER_FAIL: __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk distributed hardware disable failed} - NETWORKID: {type: STRING, desc: network id} DHID: {type: STRING, desc: component id} ERR_CODE: {type: INT32, desc: dhfwk distributed hardware disable result} ERR_MSG: {type: STRING, desc: dhfwk distributed hardware disable failed} -- Gitee From 8c000ac55b44c61221a030883f38d418aa5966d7 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 19:33:31 +0800 Subject: [PATCH 51/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index 85c5e0c3..7f978d00 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -42,20 +42,6 @@ const std::unordered_map MAP_ARGS = { { CAPABILITY_LIST, HidumpFlag::GET_CAPABILITY_LIST }, }; -std::unordered_map g_mapDhTypeName = { - { DHType::UNKNOWN, "UNKNOWN" }, - { DHType::CAMERA, "CAMERA" }, - { DHType::MIC, "MIC" }, - { DHType::SPEAKER, "SPEAKER" }, - { DHType::DISPLAY, "DISPLAY" }, - { DHType::GPS, "GPS" }, - { DHType::BUTTON, "BUTTON" }, - { DHType::HFP, "HFP" }, - { DHType::A2D, "A2D" }, - { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, - { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, -}; - std::unordered_map g_mapTaskType = { { TaskType::UNKNOWN, "UNKNOWN" }, { TaskType::ENABLE, "ENABLE" }, @@ -147,8 +133,13 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) result.append("\n Source : ["); if (!loadedCompSource.empty()) { for (auto compSource : loadedCompSource) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(compSource); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append(" "); - result.append(g_mapDhTypeName[compSource]); + result.append(dhTypeStr); result.append(","); } result.replace(result.size() - 1, 1, " "); @@ -158,8 +149,13 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) result.append("\n Sink : ["); if (!loadedCompSink.empty()) { for (auto compSink : loadedCompSink) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(compSink); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append(" "); - result.append(g_mapDhTypeName[compSink]); + result.append(dhTypeStr); result.append(","); } result.replace(result.size() - 1, 1, " "); @@ -181,11 +177,16 @@ int32_t HidumpHelper::ShowAllEnabledComps(std::string &result) } for (auto info : compInfoSet) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(info.dhType_); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n NetworkId : "); result.append(GetAnonyString(info.networkId_)); result.append("\n DHType : "); - result.append(g_mapDhTypeName[info.dhType_]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(info.dhId_)); result.append("\n},"); @@ -206,13 +207,18 @@ int32_t HidumpHelper::ShowAllTaskInfos(std::string &result) } for (auto taskInfo : taskInfos) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(taskInfo.taskParm.dhType); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n TaskId : "); result.append(taskInfo.id); result.append("\n TaskType : "); result.append(g_mapTaskType[taskInfo.taskType]); result.append("\n DHType : "); - result.append(g_mapDhTypeName[taskInfo.taskParm.dhType]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(taskInfo.taskParm.dhId)); result.append("\n TaskState : "); @@ -244,6 +250,11 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) for (auto info : capInfos) { std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(info.GetDeviceId()); std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(info.GetDHType()); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n DeviceName : "); result.append(GetAnonyString(info.GetDeviceName())); @@ -252,7 +263,7 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) result.append("\n DeviceType : "); result.append(std::to_string(info.GetDeviceType())); result.append("\n DHType : "); - result.append(g_mapDhTypeName[info.GetDHType()]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(info.GetDHId())); result.append("\n DHAttrs :\n"); -- Gitee From e5fcaea25c1258f89023e89242b2a74ce72ebfb2 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 19:53:29 +0800 Subject: [PATCH 52/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../distributedhardwarefwkserviceimpl/src/task/offline_task.cpp | 2 +- .../distributedhardwarefwkserviceimpl/src/task/online_task.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index fa12f057..d73ae1f4 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * 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 diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index a8d6f5f5..a576cabe 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * 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 -- Gitee From 8d6685402e3d30c4977ca67f31f390a38ea4eb27 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 20:50:53 +0800 Subject: [PATCH 53/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index 7f978d00..a6162aa9 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -248,8 +248,6 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) } for (auto info : capInfos) { - std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(info.GetDeviceId()); - std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); std::string dhTypeStr = "UNKNOWN"; auto it = DHTypeStrMap.find(info.GetDHType()); if (it != DHTypeStrMap.end()) { @@ -259,7 +257,7 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) result.append("\n DeviceName : "); result.append(GetAnonyString(info.GetDeviceName())); result.append("\n NetworkId : "); - result.append(GetAnonyString(networkId)); + result.append(GetAnonyString(info.GetDeviceId())); result.append("\n DeviceType : "); result.append(std::to_string(info.GetDeviceType())); result.append("\n DHType : "); -- Gitee From 6c98e9a700a246a0c78c970dc878a6da01c238b5 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Tue, 7 Jun 2022 21:11:56 +0800 Subject: [PATCH 54/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 2 +- utils/include/dh_utils_hisysevent.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index a6162aa9..cba0f2c2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -256,7 +256,7 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) result.append("\n{"); result.append("\n DeviceName : "); result.append(GetAnonyString(info.GetDeviceName())); - result.append("\n NetworkId : "); + result.append("\n DeviceId : "); result.append(GetAnonyString(info.GetDeviceId())); result.append("\n DeviceType : "); result.append(std::to_string(info.GetDeviceType())); diff --git a/utils/include/dh_utils_hisysevent.h b/utils/include/dh_utils_hisysevent.h index 00456f78..fcdfdf6b 100644 --- a/utils/include/dh_utils_hisysevent.h +++ b/utils/include/dh_utils_hisysevent.h @@ -41,7 +41,7 @@ void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX: void HiSysEventWriteReleaseMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const DHType dhType, int32_t errCode, const std::string &msg); void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, - const std::string &anonyDevid, const std::string &msg); + const std::string &anonyNetworkId, const std::string &msg); void HiSysEventWriteCompMgrFailedMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, const std::string &anonyDHId, int32_t errCode, const std::string &msg); } // namespace DistributedHardware -- Gitee From edec81aed8e7f69e2c1b7d28d71a41992acbf6e4 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 09:49:42 +0800 Subject: [PATCH 55/55] add hisysevent Signed-off-by: wanderer-dl122 --- .../test/unittest/common/componentmanager/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn index fcf5acbf..0279ceb9 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 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 -- Gitee