diff --git a/bundle.json b/bundle.json index 08a4998a1a5678e99eb901e556abe408711510b0..242d05a374345dda9d7ba715741de4a58bf71d5e 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/common/utils/include/device_type.h b/common/utils/include/device_type.h index 03a4f819008da594d1c704eb4dfcd0c4bcd29237..563fcb2a296ab850faea3bd279a6d8761bd3933f 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/hisysevent.yaml b/hisysevent.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a0e1113c867b880d02f120eb00d60dc99573d8da --- /dev/null +++ b/hisysevent.yaml @@ -0,0 +1,84 @@ +# 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_INIT_BEGIN: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dhfwk sa start on demand and init} + MSG: {type: STRING, desc: dhfwk sa start init} + +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} + ERR_MSG: {type: STRING, desc: dhfwk sa init failed} + +DHFWK_EXIT_BEGIN: + __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 finish exit on demand} + MSG: {type: STRING, desc: dhfwk sa stop} + +DHFWK_RELEASE_FAIL: + __BASE: {type: FAULT, level: CRITICAL, desc: dhfwk component dlclose failed} + DHTYPE: {type: STRING, desc: dhtype} + 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} + 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} + 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} + 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} diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index b17f50eba93a89f72585ca18aab890951580421a..f9a205b8e67e31ef619f40c3fa4436823fbbf3a5 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 @@ -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_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 1dcbedf9b39b014b5c6c8856344e1a1a19541187..b50a6fe525dbcf510c484cea4c1aff4396f5f45a 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -22,6 +22,7 @@ #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" @@ -61,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(); @@ -75,6 +78,9 @@ 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_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 6c130aa711a10d6cbf7828958f4324f4ebe18a21..fecf6941cb472b1a73567365a40d3067a3a7463a 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -23,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" @@ -38,6 +39,9 @@ DistributedHardwareService::DistributedHardwareService(int32_t saId, bool runOnC void DistributedHardwareService::OnStart() { DHLOGI("DistributedHardwareService::OnStart start"); + HiSysEventWriteMsg(DHFWK_INIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "dhfwk sa start on demand."); + if (state_ == ServiceRunningState::STATE_RUNNING) { DHLOGI("DistributedHardwareService has already started."); return; @@ -57,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; @@ -64,9 +70,13 @@ bool DistributedHardwareService::Init() auto ret = AccessManager::GetInstance()->Init(); if (ret != DH_FWK_SUCCESS) { DHLOGI("DistributedHardwareService::Init failed."); + 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 success."); return true; } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkservice/test/fuzztest/accessmanager_fuzzer/BUILD.gn index 53d89fa2be3427cf19f47b64120e02fbd5a7307c..4ecb1bd96a80ce89c2f60d015c40fb4ed21d38c7 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 74c8c30e69fc95cc712b0a8da4ea37851e091b9b..be489786ef42dd1014e223c2a6ab44dc6e750121 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -60,6 +60,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 53cfb524e0326bb086bad79bd6e9eed04730bc75..80a164ff79b387b7b3f0a5ac9a4b49a99d9a17f1 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,6 +83,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", diff --git a/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h b/services/distributedhardwarefwkserviceimpl/include/hidumphelper/enabled_comps_dump.h index d99cd0f251229f40ac5574cdcaaffb5f58f3d2fe..44dbcbcace72d47ace92d7d25266211d9130ca45 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 86a00f594bdf43f9825cbcff8172d0a1ca0da6c4..ce6d4f77106722f3dbd1cf92ae66d79cdc94dc00 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -23,6 +23,7 @@ #include "constants.h" #include "distributed_hardware_log.h" +#include "dh_utils_hisysevent.h" #include "hidump_helper.h" using nlohmann::json; @@ -145,6 +146,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); + HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "dhfwk so open failed, soname : " + soName); return nullptr; } return pHandler; @@ -289,6 +292,8 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + dhType, ret, "dhfwk release hardware handler failed."); } return ret; } @@ -301,6 +306,8 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + dhType, ret, "dhfwk release source failed."); } return ret; } @@ -313,6 +320,8 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { DHLOGE("fail, dhType: %#X", dhType); + 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 9cb2c82e0d622d2b3d9312e92b34f7ff26b9c7dc..4314457e67b5eb3edbb53bd48a72febe7edbc792 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 @@ -17,6 +17,7 @@ #include "anonymous_string.h" #include "constants.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -43,6 +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()); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; } @@ -53,6 +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()); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId), 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 ebbf1cbc84da0f531d244198c27f92bc4b87493a..5a05ae655e26335efccda6ac4ed93f9871fd05ca 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 @@ -17,6 +17,7 @@ #include "anonymous_string.h" #include "constants.h" +#include "dh_utils_hisysevent.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -43,6 +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()); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; } @@ -53,6 +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()); + HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + GetAnonyString(dhId), 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/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index e433516791824d6ce4d02c329f35950daac7b0be..ebd55467c95a4cd2ca18ffe1c54fb6733ec3f7c3 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"); @@ -258,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); @@ -267,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; } @@ -289,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); @@ -298,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 173594129b837241b4cf974dc3a003d7b4d33316..ffccdaa8228078a83725d13bd93d83f787ffe3ad 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -20,6 +20,7 @@ #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" @@ -154,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(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 feeb4fe5762667a17634f4335ac036eb19f05a44..840b8bcc7b68312f4dae2dd2039e64008ffac546 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); @@ -45,4 +45,4 @@ void EnabledCompsDump::Dump(std::set &compInfoSet) compInfoSet = compInfoSet_; } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index 03ab72729a01c26396630951007c788d4e162b00..bc0a4aac6cced3f9aad6e7710e364b532451a5ba 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -41,20 +41,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" }, @@ -146,8 +132,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, " "); @@ -157,8 +148,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, " "); @@ -180,12 +176,17 @@ 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 DeviceId : "); - result.append(GetAnonyString(info.deviceId_)); - result.append("\n DHType : "); - result.append(g_mapDhTypeName[info.dhType_]); - result.append("\n DHId : "); + result.append("\n NetworkId : "); + result.append(GetAnonyString(info.networkId_)); + result.append("\n DHType : "); + result.append(dhTypeStr); + result.append("\n DHId : "); result.append(GetAnonyString(info.dhId_)); result.append("\n},"); } @@ -205,13 +206,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 : "); @@ -241,6 +247,11 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) } for (auto info : capInfos) { + 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())); @@ -249,7 +260,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"); @@ -286,4 +297,4 @@ int32_t HidumpHelper::ShowIllealInfomation(std::string &result) return ERR_DH_FWK_HIDUMP_INVALID_ARGS; } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/fuzztest/componentmanager_fuzzer/BUILD.gn index 5314afb0ab2759af07bfbe51a3ce8b1108e48f89..69bf6a8920256bf4d3164e456cbc0114cdbf267f 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 @@ -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 4ff5522b561767791272ad747e6b4f4c98bba0c2..6c4c13c6723c7499163c3dc9f59fa4cf19568b77 100644 --- a/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_fuzzer/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/test/fuzztest/resourcemanager_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 @@ -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/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/BUILD.gn index c94546ee99a3991382845c48656c5c6e9061954e..8d97bae956d9210a94fbc26e316103fbd1e5554c 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 @@ -44,6 +44,8 @@ ohos_unittest("ComponentLoaderTest") { "//third_party/googletest:gtest_main", ] + 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 82f4f3ce8b43c57332ecdf3627eebef3a6d05547..0279ceb9859b2f2b7a9bb47ffcf07a2d5f177333 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 @@ -52,7 +52,10 @@ ohos_unittest("ComponentManagerTest") { "LOG_DOMAIN=0xD004100", ] - external_deps = [ "ipc:ipc_core" ] + external_deps = [ + "hisysevent_native:libhisysevent", + "ipc:ipc_core", + ] } group("component_manager_test") { diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/BUILD.gn index bcf729a8182966735fd1d5501fccf2afe6364b4a..4bf290b890d6e4879554c46b9a789f850ad3ba33 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 @@ -56,6 +56,7 @@ ohos_unittest("ResourceManagerTest") { "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 27018ede10c82e79af10b933e093391fd97536a6..dfd17d9dca91f98c584387a698c35ce2e1931aa7 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 0000000000000000000000000000000000000000..fcdfdf6b196c3ebf96dcd2f0c6b4d86b5c42fe4f --- /dev/null +++ b/utils/include/dh_utils_hisysevent.h @@ -0,0 +1,49 @@ +/* + * 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_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 DHFWK_DEV_OFFLINE = "DHFWK_DEV_OFFLINE"; +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"; + +void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &msg); +void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + int32_t errCode, const std::string &msg); +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 &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 +} // 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 0000000000000000000000000000000000000000..aac98804e796d1d939086c8d96f935273ad6e043 --- /dev/null +++ b/utils/src/dh_utils_hisysevent.cpp @@ -0,0 +1,103 @@ +/* + * 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 { +void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysEvent::EventType eventType, + const std::string &msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +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_MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +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"; + 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", dhTypeStr.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 &anonyNetworkId, 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(), + "MSG", msg.c_str()); + if (res != DH_FWK_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HiSysEventWriteCompMgrFailedMsg(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( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_HARDWARE_FWK, + status.c_str(), + eventType, + "DHID", anonyDHId.c_str(), + "ERR_CODE", errCode, + "ERR_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