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/hisysevent.yaml b/hisysevent.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b7cee2eb3da8c0057ee07eabaff0a8f4f3705072 --- /dev/null +++ b/hisysevent.yaml @@ -0,0 +1,136 @@ +# 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} + +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} + 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} \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 3fd69ff76613a5a557aa346f3a77c435df0478b8..08d32b6ecc97cf2c1ef31e429446c3716fafe763 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_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 7f801b21377b3adb12d167065fd2e11d1fc7d760..44ccdde03fc24faf476f2802bef7d5114beaf7b4 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" @@ -25,6 +28,7 @@ #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" + namespace OHOS { namespace DistributedHardware { const char* LIB_NAME = "libdistributedhardwarefwksvr_impl.z.so"; @@ -74,6 +78,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/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 6c130aa711a10d6cbf7828958f4324f4ebe18a21..285fa99d6e80d014206018be326e5f1b209f769c 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; diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a20217fd08611be789314fcc1bdbe12138d..9553b9c8d0dcf991165260840f1e3f9b604f30b2 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/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 86a00f594bdf43f9825cbcff8172d0a1ca0da6c4..ca1b4762f4d937ee00e6db36f5f2a6b3bd4a5f69 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" @@ -140,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; @@ -242,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"); @@ -270,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++) { @@ -289,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; } @@ -301,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; } @@ -313,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 9cb2c82e0d622d2b3d9312e92b34f7ff26b9c7dc..d53d0f0d22616b562143a7cee1d2cb7b44e98426 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 ebbf1cbc84da0f531d244198c27f92bc4b87493a..d3cb3f3387b8f1da2e0002cfa51c207763f5d7ba 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 173594129b837241b4cf974dc3a003d7b4d33316..80b8cf36a1a80cccd06a254a5a561e58cd9584fb 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 07e054739173af88fb187d3193add9e4b8d6fae1..2a3f9fdc21525a9171bf825b8036aa23f19b49cb 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 d73ae1f4fa7bbca9571c1e0618968b743b7261a1..8cb94e5f64db1838cd40b0febf6e8f768126228b 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 a576cabe39e3569f44effcaf4ac0a86e1ad3317e..11dee8f88ff394610e4111b3b8daf3deddeb978f 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