From 1e03a02ce112d99c739bef011d8d6f73425db485 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 15:06:13 +0800 Subject: [PATCH 01/34] =?UTF-8?q?dm=E6=B7=BB=E5=8A=A0hisysevent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- hisysevent.yaml | 124 ++++++++++++++++++ interfaces/inner_kits/native_cpp/BUILD.gn | 3 + .../native_cpp/src/device_manager_impl.cpp | 21 +++ services/devicemanagerservice/BUILD.gn | 12 +- .../dependency/hichain/hichain_connector.cpp | 9 ++ .../src/device_manager_service.cpp | 1 - test/unittest/BUILD.gn | 3 + .../UTTest_dm_device_state_manager.cpp | 1 + test/unittest/UTTest_softbus_connector.cpp | 1 + utils/BUILD.gn | 7 + utils/include/dm_hisysevent.h | 61 +++++++++ utils/src/dm_hisysevent.cpp | 72 ++++++++++ 12 files changed, 313 insertions(+), 2 deletions(-) create mode 100644 hisysevent.yaml create mode 100644 utils/include/dm_hisysevent.h create mode 100644 utils/src/dm_hisysevent.cpp diff --git a/hisysevent.yaml b/hisysevent.yaml new file mode 100644 index 00000000..f9f340b4 --- /dev/null +++ b/hisysevent.yaml @@ -0,0 +1,124 @@ +# 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: DISTDM + +DM_INIT_DEVICE_MANAGER_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm init devicemanager success} + +DM_INIT_DEVICE_MANAGER_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm init devicemanager failed} + +START_DEVICE_DISCOVERY_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: device manager discovery success} + +START_DEVICE_DISCOVERY_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: device manager discovery failed} + +GET_LOCAL_DEVICE_INFO_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm get local device info success} + +GET_LOCAL_DEVICE_INFO_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm get local device info failed} + +DM_SEND_REQUEST_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm send request success} + +DM_SEND_REQUEST_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm send request failed} + +ADD_HICHAIN_GROUP_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm add member to group success} + +ADD_HICHAIN_GROUP_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm add member to group failed} + +DM_CREATE_GROUP_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm create group success} + +DM_CREATE_GROUP_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: dm create group failed} + +UNAUTHENTICATE_DEVICE_SUCCESS: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device success} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: unauthenticate device success} + +UNAUTHENTICATE_DEVICE_FAILED: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device failed} + PID: {type: INT32, desc: dhfwk pid} + UID: {type: INT32, desc: dhfwk uid} + MSG: {type: STRING, desc: unauthenticate device failed} diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 64eca50a..2760729c 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -33,6 +33,7 @@ if (defined(ohos_lite)) { include_dirs += [ "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//third_party/json/include", @@ -75,6 +76,7 @@ if (defined(ohos_lite)) { include_dirs += [ "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", @@ -143,6 +145,7 @@ if (defined(ohos_lite)) { deps = [ "${utils_path}:devicemanagerutils" ] external_deps = [ + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 19b2bdc8..7b791c77 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -35,6 +35,7 @@ #include "ipc_verify_authenticate_req.h" #include "ipc_register_dev_state_callback_req.h" #include "securec.h" +#include "dm_hisysevent.h" namespace OHOS { namespace DistributedHardware { @@ -68,11 +69,15 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); LOGI("InitDeviceManager success"); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "init devicemanager success."); return DM_OK; } @@ -140,11 +145,15 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info failed."); return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info success."); return DM_OK; } @@ -206,10 +215,14 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery failed."); return ret; } LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery success."); return DM_OK; } @@ -264,8 +277,12 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request failed."); return ERR_DM_IPC_SEND_REQUEST_FAILED; } + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request success."); ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -297,8 +314,12 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device failed."); return ERR_DM_IPC_RESPOND_FAILED; } + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device success."); LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 2be7fed6..105fd479 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -45,6 +45,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "//base/security/deviceauth/interfaces/innerkits", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", "${utils_path}/include", "${utils_path}/include/permission/lite", @@ -55,6 +56,7 @@ if (defined(ohos_lite)) { ] include_dirs += [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/security/deviceauth/interfaces/innerkits", "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", "//utils/native/lite/include", @@ -108,7 +110,10 @@ if (defined(ohos_lite)) { if (os_account_part_exists) { defines += [ "OS_ACCOUNT_PART_EXISTS" ] - include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ] + include_dirs += [ + "//base/account/os_account/interfaces/innerkits/osaccount/native/include", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", + ] } ldflags = dm_ldflags @@ -125,6 +130,8 @@ if (defined(ohos_lite)) { "//third_party/mbedtls", "//utils/native/lite:utils", ] + + external_deps = [ "hisysevent_native:libhisysevent" ] } } else { executable("devicemanagerservice") { @@ -157,6 +164,7 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include/ipc/lite", ] include_dirs += [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/security/deviceauth/interfaces/innerkits", "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", "//utils/native/lite/include", @@ -255,6 +263,7 @@ if (defined(ohos_lite)) { "${utils_path}/include/fwkload/standard", "${utils_path}/include/permission/standard", "//base/security/deviceauth/interfaces/innerkits", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", ] @@ -327,6 +336,7 @@ if (defined(ohos_lite)) { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 2b47c4c9..8d6606a4 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -14,6 +14,7 @@ */ #include "hichain_connector.h" +#include "dm_hisysevent.h" #include @@ -261,12 +262,16 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group success."); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group success."); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -286,12 +291,16 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group failed."); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); + DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group failed."); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index ebafb5d0..0c97d234 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -17,7 +17,6 @@ #include - #include "device_manager_service_listener.h" #include "dm_constants.h" #include "dm_device_info_manager.h" diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 8fd97f00..9876d981 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -283,6 +283,7 @@ ohos_unittest("UTTest_profile_connector") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", ] } @@ -300,6 +301,7 @@ ohos_unittest("UTTest_device_profile_adapter") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", ] } @@ -640,6 +642,7 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index e3d5b7b4..1dcf5769 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -16,6 +16,7 @@ #include "dm_log.h" #include "dm_constants.h" +#include "dm_hisysevent.h" #include "dm_adapter_manager.h" #include "ipc_notify_device_state_req.h" #include "ipc_notify_auth_result_req.h" diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 01b7976d..da9ee309 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,6 +24,7 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" +#include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 760eb0b6..860afc3a 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -35,6 +35,7 @@ if (defined(ohos_lite)) { "//utils/system/safwk/native/include", "//third_party/json/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", ] @@ -42,6 +43,7 @@ if (defined(ohos_lite)) { sources = [ "${utils_path}/src/dm_anonymous.cpp", "${utils_path}/src/dm_error_message.cpp", + "${utils_path}/src/dm_hisysevent.cpp", "${utils_path}/src/dm_log.cpp", "${utils_path}/src/dm_random.cpp", "${utils_path}/src/permission/lite/permission_manager.cpp", @@ -55,6 +57,7 @@ if (defined(ohos_lite)) { deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", "//foundation/distributedschedule/samgr_lite/samgr", "//third_party/bounds_checking_function:libsec_static", @@ -81,6 +84,7 @@ if (defined(ohos_lite)) { "//utils/system/safwk/native/include", "//third_party/json/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", @@ -93,6 +97,7 @@ if (defined(ohos_lite)) { sources = [ "src/dm_anonymous.cpp", "src/dm_error_message.cpp", + "src/dm_hisysevent.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/fwkload/lite/dm_distributed_hardware_load.cpp", @@ -135,6 +140,7 @@ if (defined(ohos_lite)) { "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_hash.cpp", + "src/dm_hisysevent.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/ipc/standard/ipc_cmd_register.cpp", @@ -158,6 +164,7 @@ if (defined(ohos_lite)) { external_deps = [ "access_token:libaccesstoken_sdk", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/utils/include/dm_hisysevent.h b/utils/include/dm_hisysevent.h new file mode 100644 index 00000000..f74ba4ee --- /dev/null +++ b/utils/include/dm_hisysevent.h @@ -0,0 +1,61 @@ +/* + * 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_DM_HISYSEVENT_H +#define OHOS_DISTRIBUTED_DM_HISYSEVENT_H + +#include +#include + +#include "single_instance.h" +#include "hisysevent.h" +#include "dm_log.h" +#include "dm_constants.h" +#include "dm_anonymous.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedDM { +#define DM_INIT_DEVICE_MANAGER_SUCCESS "DM_INIT_DEVICE_MANAGER_SUCCESS" +#define DM_INIT_DEVICE_MANAGER_FAILED "DM_INIT_DEVICE_MANAGER_FAILED" +#define START_DEVICE_DISCOVERY_SUCCESS "START_DEVICE_DISCOVERY_SUCCESS" +#define START_DEVICE_DISCOVERY_FAILED "START_DEVICE_DISCOVERY_FAILED" +#define GET_LOCAL_DEVICE_INFO_SUCCESS "GET_LOCAL_DEVICE_INFO_SUCCESS" +#define GET_LOCAL_DEVICE_INFO_FAILED "GET_LOCAL_DEVICE_INFO_FAILED" +#define DM_SEND_REQUEST_SUCCESS "DM_SEND_REQUEST_SUCCESS" +#define DM_SEND_REQUEST_FAILED "DM_SEND_REQUEST_FAILED" +#define ADD_HICHAIN_GROUP_SUCCESS "ADD_HICHAIN_GROUP_SUCCESS" +#define ADD_HICHAIN_GROUP_FAILED "ADD_HICHAIN_GROUP_FAILED" +#define DM_CREATE_GROUP_SUCCESS "DM_CREATE_GROUP_SUCCESS" +#define DM_CREATE_GROUP_FAILED "DM_CREATE_GROUP_FAILED" +#define UNAUTHENTICATE_DEVICE_SUCCESS "UNAUTHENTICATE_DEVICE_SUCCESS" +#define UNAUTHENTICATE_DEVICE_FAILED "UNAUTHENTICATE_DEVICE_FAILED" + +class HisyseventUtil { +DECLARE_SINGLE_INSTANCE_BASE(HisyseventUtil); +public: + void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); + void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, + std::string devId, std::string msg); + void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, + std::string devId, std::string dhId, std::string msg); +private: + HisyseventUtil() = default; + ~HisyseventUtil() = default; +}; +} // namespace DistributedDM +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/src/dm_hisysevent.cpp b/utils/src/dm_hisysevent.cpp new file mode 100644 index 00000000..7d7a7fe4 --- /dev/null +++ b/utils/src/dm_hisysevent.cpp @@ -0,0 +1,72 @@ +/* + * 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 "dm_hisysevent.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedDM { +IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); + +void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, + std::string msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, + status, + eventType, + "PID", getpid(), + "UID", getuid(), + "MSG", msg); + if (res != DM_OK) { + LOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, + std::string devId, std::string msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, + status, + eventType, + "DEVID", GetAnonyString(devId), + "PID", getpid(), + "UID", getuid(), + "MSG", msg); + if (res != DM_OK) { + LOGE("Write HiSysEvent error, res:%d", res); + } +} + +void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, + std::string devId, std::string dhId, std::string msg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, + status, + eventType, + "DEVID", GetAnonyString(devId), + "DHID", GetAnonyString(dhId), + "PID", getpid(), + "UID", getuid(), + "MSG", msg); + if (res != DM_OK) { + LOGE("Write HiSysEvent error, res:%d", res); + } +} +} // namespace DistributedDM +} // namespace DistributedHardware +} // namespace OHOS From 9ea1ae8e65a8d15ba35ac08e6cb6f45e83d9fb15 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 15:38:42 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT=20Signed-off-by:=20w?= =?UTF-8?q?angyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp | 3 +++ test/unittest/BUILD.gn | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 7b791c77..d441d140 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -69,6 +69,9 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); + #if defined(__LITEOS_M__) + DmMutex mutexLock; + #else DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); return ERR_DM_INIT_FAILED; diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 9876d981..cb59c2cb 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -158,6 +158,8 @@ ohos_unittest("UTTest_softbus_connector") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hisysevent_native:libhisysevent", ] } ## UnitTest UTTest_softbus_connector }}} @@ -361,6 +363,8 @@ ohos_unittest("UTTest_dm_device_state_manager") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hisysevent_native:libhisysevent", ] } ## UnitTest UTTest_dm_device_state_manager }}} From 5a5aa2c9433455f52da630840562538b6543db3b Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 15:47:44 +0800 Subject: [PATCH 03/34] 1 Signed-off-by: wangyb0625 --- interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index d441d140..7b791c77 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -69,9 +69,6 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - #if defined(__LITEOS_M__) - DmMutex mutexLock; - #else DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); return ERR_DM_INIT_FAILED; From b327b4b1f9efe8dcfb76c11a7704e9a8b9f1e8c4 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 16:03:50 +0800 Subject: [PATCH 04/34] =?UTF-8?q?=E5=8F=AA=E4=BF=AE=E6=94=B9L2=20Signed-of?= =?UTF-8?q?f-by:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native_cpp/src/device_manager_impl.cpp | 20 +++++++++++++++++++ services/devicemanagerservice/BUILD.gn | 5 ----- .../dependency/hichain/hichain_connector.cpp | 10 ++++++++++ .../UTTest_dm_device_state_manager.cpp | 2 ++ test/unittest/UTTest_softbus_connector.cpp | 2 ++ utils/BUILD.gn | 3 --- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 7b791c77..eee2480d 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -35,7 +35,9 @@ #include "ipc_verify_authenticate_req.h" #include "ipc_register_dev_state_callback_req.h" #include "securec.h" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" +#endif namespace OHOS { namespace DistributedHardware { @@ -69,15 +71,19 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); + #endif return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); LOGI("InitDeviceManager success"); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "init devicemanager success."); + #endif return DM_OK; } @@ -145,15 +151,19 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info failed."); + #endif return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info success."); + #endif return DM_OK; } @@ -215,14 +225,18 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery failed."); + #endif return ret; } LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery success."); + #endif return DM_OK; } @@ -277,10 +291,12 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request failed."); return ERR_DM_IPC_SEND_REQUEST_FAILED; } + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request success."); @@ -314,12 +330,16 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device failed."); + #endif return ERR_DM_IPC_RESPOND_FAILED; } + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device success."); + #endif LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 105fd479..396ba7ef 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -45,7 +45,6 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "//base/security/deviceauth/interfaces/innerkits", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", "${utils_path}/include", "${utils_path}/include/permission/lite", @@ -56,7 +55,6 @@ if (defined(ohos_lite)) { ] include_dirs += [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/security/deviceauth/interfaces/innerkits", "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", "//utils/native/lite/include", @@ -112,7 +110,6 @@ if (defined(ohos_lite)) { defines += [ "OS_ACCOUNT_PART_EXISTS" ] include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", ] } @@ -164,7 +161,6 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include/ipc/lite", ] include_dirs += [ - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/security/deviceauth/interfaces/innerkits", "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", "//utils/native/lite/include", @@ -263,7 +259,6 @@ if (defined(ohos_lite)) { "${utils_path}/include/fwkload/standard", "${utils_path}/include/permission/standard", "//base/security/deviceauth/interfaces/innerkits", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/json/include", ] diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 8d6606a4..a1471962 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -14,7 +14,9 @@ */ #include "hichain_connector.h" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" +#endif #include @@ -262,16 +264,20 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group success."); + #endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group success."); + #endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -291,16 +297,20 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group failed."); + #endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group failed."); + #endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index 1dcf5769..4e9ab50f 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -16,7 +16,9 @@ #include "dm_log.h" #include "dm_constants.h" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" +#endif #include "dm_adapter_manager.h" #include "ipc_notify_device_state_req.h" #include "ipc_notify_auth_result_req.h" diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index da9ee309..ccb12e0e 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,7 +24,9 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" +#endif #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 860afc3a..091b9311 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -35,7 +35,6 @@ if (defined(ohos_lite)) { "//utils/system/safwk/native/include", "//third_party/json/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", ] @@ -57,7 +56,6 @@ if (defined(ohos_lite)) { deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", "//foundation/distributedschedule/samgr_lite/samgr", "//third_party/bounds_checking_function:libsec_static", @@ -84,7 +82,6 @@ if (defined(ohos_lite)) { "//utils/system/safwk/native/include", "//third_party/json/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", From 2fba8e88b84a292f00d64a0895e248636718cfe5 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 16:06:00 +0800 Subject: [PATCH 05/34] 12 Signed-off-by: wangyb0625 --- interfaces/inner_kits/native_cpp/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 2760729c..2534db6b 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -33,7 +33,6 @@ if (defined(ohos_lite)) { include_dirs += [ "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//third_party/json/include", @@ -76,7 +75,6 @@ if (defined(ohos_lite)) { include_dirs += [ "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", - "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/bounds_checking_function/include", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", From b3e5136836169e68e8f1732542e0189e5f164b16 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 16:40:24 +0800 Subject: [PATCH 06/34] 1234 Signed-off-by: wangyb0625 --- .../native_cpp/src/device_manager_impl.cpp | 38 ++++++++++--------- services/devicemanagerservice/BUILD.gn | 4 +- .../dependency/hichain/hichain_connector.cpp | 12 +++--- test/unittest/BUILD.gn | 4 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index eee2480d..0faca76f 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -71,19 +71,19 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); - #endif +#endif return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); LOGI("InitDeviceManager success"); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "init devicemanager success."); - #endif +#endif return DM_OK; } @@ -151,19 +151,19 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info failed."); - #endif +#endif return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info success."); - #endif +#endif return DM_OK; } @@ -225,18 +225,18 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery failed."); - #endif +#endif return ret; } LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery success."); - #endif +#endif return DM_OK; } @@ -291,14 +291,16 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request failed."); +#endif return ERR_DM_IPC_SEND_REQUEST_FAILED; } - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request success."); +#endif ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -330,16 +332,16 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device failed."); - #endif +#endif return ERR_DM_IPC_RESPOND_FAILED; } - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device success."); - #endif +#endif LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 396ba7ef..f6be411e 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -108,9 +108,7 @@ if (defined(ohos_lite)) { if (os_account_part_exists) { defines += [ "OS_ACCOUNT_PART_EXISTS" ] - include_dirs += [ - "//base/account/os_account/interfaces/innerkits/osaccount/native/include", - ] + include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ] } ldflags = dm_ldflags diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index a1471962..847eb4a5 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -264,20 +264,20 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group success."); - #endif +#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group success."); - #endif +#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -307,10 +307,10 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group failed."); - #endif +#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index cb59c2cb..0a1c639d 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -159,7 +159,7 @@ ohos_unittest("UTTest_softbus_connector") { deps = [ ":device_manager_test" ] - external_deps = [ "hisysevent_native:libhisysevent", ] + external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_softbus_connector }}} @@ -364,7 +364,7 @@ ohos_unittest("UTTest_dm_device_state_manager") { deps = [ ":device_manager_test" ] - external_deps = [ "hisysevent_native:libhisysevent", ] + external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_dm_device_state_manager }}} From 9e50edb6bc5784f242b533af6a297a9364687ab9 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 17:18:59 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9L1=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/include/dm_hisysevent.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/include/dm_hisysevent.h b/utils/include/dm_hisysevent.h index f74ba4ee..0fea8f55 100644 --- a/utils/include/dm_hisysevent.h +++ b/utils/include/dm_hisysevent.h @@ -20,7 +20,9 @@ #include #include "single_instance.h" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "hisysevent.h" +#endif #include "dm_log.h" #include "dm_constants.h" #include "dm_anonymous.h" From 84290c312030bbe734d8cfee22d7d5a21b27ef5d Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 17:23:50 +0800 Subject: [PATCH 08/34] codecheck Signed-off-by: wangyb0625 --- .../src/dependency/hichain/hichain_connector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 847eb4a5..7eb3b303 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -297,10 +297,10 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); - #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group failed."); - #endif +#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } From 7618bdfed47f6de0c6cf3ee62780998b2d6307f7 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 16 Jun 2022 20:57:10 +0800 Subject: [PATCH 09/34] =?UTF-8?q?L1=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 091b9311..cfe0843c 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -152,6 +152,7 @@ if (defined(ohos_lite)) { public_configs = [ ":devicemanagerutils_config" ] defines = [ + "LITE_DEVICE", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerutils\"", "LOG_DOMAIN=0xD004100", From 3cbf8f5f4dac38d5c33610ad4efb9cdf31c5107f Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Fri, 17 Jun 2022 09:33:42 +0800 Subject: [PATCH 10/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9L1=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/BUILD.gn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index cfe0843c..6a577217 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -49,6 +49,7 @@ if (defined(ohos_lite)) { ] defines = [ + "LITE_DEVICE", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerutils\"", "LOG_DOMAIN=0xD004100", @@ -102,6 +103,7 @@ if (defined(ohos_lite)) { "src/permission/lite/permission_manager.cpp", ] defines = [ + "LITE_DEVICE", "hI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerutils\"", "lOG_DOMAIN=0xD004100", @@ -152,7 +154,6 @@ if (defined(ohos_lite)) { public_configs = [ ":devicemanagerutils_config" ] defines = [ - "LITE_DEVICE", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerutils\"", "LOG_DOMAIN=0xD004100", From e85c386eb2277a2fc60291efc1d7f6285d84fb6b Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Fri, 17 Jun 2022 10:59:44 +0800 Subject: [PATCH 11/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9build.gn=20Signed-off-b?= =?UTF-8?q?y:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_kits/native_cpp/BUILD.gn | 2 +- services/devicemanagerservice/BUILD.gn | 2 +- utils/BUILD.gn | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 2534db6b..e1e1c2de 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -45,7 +45,7 @@ if (defined(ohos_lite)) { ] defines = [ - "LITE_DEVICE", + "__LITEOS_M__", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerkit\"", "LOG_DOMAIN=0xD004100", diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index f6be411e..121e0c3f 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -100,7 +100,7 @@ if (defined(ohos_lite)) { ] defines = [ - "LITE_DEVICE", + "__LITEOS_M__", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerservice\"", "LOG_DOMAIN=0xD004100", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 6a577217..fd487eff 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -49,7 +49,7 @@ if (defined(ohos_lite)) { ] defines = [ - "LITE_DEVICE", + "__LITEOS_M__", "HI_LOG_ENABLE", "DH_LOG_TAG=\"devicemanagerutils\"", "LOG_DOMAIN=0xD004100", From 3d2671e399050ef4f180784782cbf06fd949d95f Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Fri, 17 Jun 2022 12:37:27 +0800 Subject: [PATCH 12/34] 12 Signed-off-by: wangyb0625 --- utils/include/dm_hisysevent.h | 2 ++ utils/src/dm_hisysevent.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/utils/include/dm_hisysevent.h b/utils/include/dm_hisysevent.h index 0fea8f55..a5d53f03 100644 --- a/utils/include/dm_hisysevent.h +++ b/utils/include/dm_hisysevent.h @@ -45,6 +45,7 @@ namespace DistributedDM { #define UNAUTHENTICATE_DEVICE_SUCCESS "UNAUTHENTICATE_DEVICE_SUCCESS" #define UNAUTHENTICATE_DEVICE_FAILED "UNAUTHENTICATE_DEVICE_FAILED" +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) class HisyseventUtil { DECLARE_SINGLE_INSTANCE_BASE(HisyseventUtil); public: @@ -57,6 +58,7 @@ private: HisyseventUtil() = default; ~HisyseventUtil() = default; }; +#endif } // namespace DistributedDM } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dm_hisysevent.cpp b/utils/src/dm_hisysevent.cpp index 7d7a7fe4..d0864ed3 100644 --- a/utils/src/dm_hisysevent.cpp +++ b/utils/src/dm_hisysevent.cpp @@ -20,6 +20,7 @@ namespace DistributedHardware { namespace DistributedDM { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg) { @@ -67,6 +68,7 @@ void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEve LOGE("Write HiSysEvent error, res:%d", res); } } +#endif } // namespace DistributedDM } // namespace DistributedHardware } // namespace OHOS From 11df291a7579d3487d1b10286ed6ffd045982d60 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Fri, 17 Jun 2022 13:09:30 +0800 Subject: [PATCH 13/34] 12 Signed-off-by: wangyb0625 --- utils/include/dm_hisysevent.h | 2 +- utils/src/dm_hisysevent.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/include/dm_hisysevent.h b/utils/include/dm_hisysevent.h index a5d53f03..1d6e3ffe 100644 --- a/utils/include/dm_hisysevent.h +++ b/utils/include/dm_hisysevent.h @@ -30,6 +30,7 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedDM { +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #define DM_INIT_DEVICE_MANAGER_SUCCESS "DM_INIT_DEVICE_MANAGER_SUCCESS" #define DM_INIT_DEVICE_MANAGER_FAILED "DM_INIT_DEVICE_MANAGER_FAILED" #define START_DEVICE_DISCOVERY_SUCCESS "START_DEVICE_DISCOVERY_SUCCESS" @@ -45,7 +46,6 @@ namespace DistributedDM { #define UNAUTHENTICATE_DEVICE_SUCCESS "UNAUTHENTICATE_DEVICE_SUCCESS" #define UNAUTHENTICATE_DEVICE_FAILED "UNAUTHENTICATE_DEVICE_FAILED" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) class HisyseventUtil { DECLARE_SINGLE_INSTANCE_BASE(HisyseventUtil); public: diff --git a/utils/src/dm_hisysevent.cpp b/utils/src/dm_hisysevent.cpp index d0864ed3..91001ed7 100644 --- a/utils/src/dm_hisysevent.cpp +++ b/utils/src/dm_hisysevent.cpp @@ -18,9 +18,9 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedDM { +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg) { From e67cf7df34a101856abdef36a6be05d7379c284d Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Sat, 18 Jun 2022 11:46:44 +0800 Subject: [PATCH 14/34] =?UTF-8?q?hisysevent=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- hisysevent.yaml | 56 +++++++++---------- interfaces/inner_kits/native_cpp/BUILD.gn | 3 + .../native_cpp/src/device_manager_impl.cpp | 44 ++++----------- services/devicemanagerservice/BUILD.gn | 3 + .../dependency/hichain/hichain_connector.cpp | 20 ++----- .../UTTest_dm_device_state_manager.cpp | 2 - test/unittest/UTTest_softbus_connector.cpp | 2 - utils/BUILD.gn | 9 ++- utils/include/hisysevent/lite/dm_hisysevent.h | 37 ++++++++++++ .../{ => hisysevent/standard}/dm_hisysevent.h | 34 +++++------ utils/src/hisysevent/lite/dm_hisysevent.cpp | 26 +++++++++ .../standard}/dm_hisysevent.cpp | 37 ------------ 12 files changed, 132 insertions(+), 141 deletions(-) create mode 100644 utils/include/hisysevent/lite/dm_hisysevent.h rename utils/include/{ => hisysevent/standard}/dm_hisysevent.h (73%) create mode 100644 utils/src/hisysevent/lite/dm_hisysevent.cpp rename utils/src/{ => hisysevent/standard}/dm_hisysevent.cpp (50%) diff --git a/hisysevent.yaml b/hisysevent.yaml index f9f340b4..94239bd8 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -41,84 +41,84 @@ domain: DISTDM DM_INIT_DEVICE_MANAGER_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm init devicemanager success} DM_INIT_DEVICE_MANAGER_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm init devicemanager failed} START_DEVICE_DISCOVERY_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: device manager discovery success} START_DEVICE_DISCOVERY_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: device manager discovery failed} GET_LOCAL_DEVICE_INFO_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm get local device info success} GET_LOCAL_DEVICE_INFO_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm get local device info failed} DM_SEND_REQUEST_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm send request success} DM_SEND_REQUEST_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm send request failed} ADD_HICHAIN_GROUP_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm add member to group success} ADD_HICHAIN_GROUP_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm add member to group failed} DM_CREATE_GROUP_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm create group success} DM_CREATE_GROUP_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: dm create group failed} UNAUTHENTICATE_DEVICE_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device success} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: unauthenticate device success} UNAUTHENTICATE_DEVICE_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device failed} - PID: {type: INT32, desc: dhfwk pid} - UID: {type: INT32, desc: dhfwk uid} + PID: {type: INT32, desc: dhdevevicemanager pid} + UID: {type: INT32, desc: dhdevevicemanager uid} MSG: {type: STRING, desc: unauthenticate device failed} diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index e1e1c2de..a9e4ba79 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -25,6 +25,7 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include", "${innerkits_path}/native_cpp/include/notify", "${utils_path}/include", + "${utils_path}/include/hisysevent/lite", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -70,6 +71,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include", + "${utils_path}/include/hisysevent/lite", "${utils_path}/include/ipc/lite", ] include_dirs += [ @@ -117,6 +119,7 @@ if (defined(ohos_lite)) { "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", + "${utils_path}/include/ipc/standard", ] } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 0faca76f..58be8921 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -18,6 +18,7 @@ #include "device_manager_notify.h" #include "dm_anonymous.h" #include "dm_constants.h" +#include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_authenticate_device_req.h" #include "ipc_get_dmfaparam_rsp.h" @@ -35,9 +36,6 @@ #include "ipc_verify_authenticate_req.h" #include "ipc_register_dev_state_callback_req.h" #include "securec.h" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) -#include "dm_hisysevent.h" -#endif namespace OHOS { namespace DistributedHardware { @@ -71,19 +69,15 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); -#endif return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); LOGI("InitDeviceManager success"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "init devicemanager success."); -#endif return DM_OK; } @@ -151,19 +145,15 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info failed."); -#endif return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info success."); -#endif return DM_OK; } @@ -225,18 +215,14 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery failed."); -#endif return ret; } LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery success."); -#endif return DM_OK; } @@ -291,16 +277,12 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request failed."); -#endif return ERR_DM_IPC_SEND_REQUEST_FAILED; } -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request success."); -#endif ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -332,16 +314,12 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device failed."); -#endif return ERR_DM_IPC_RESPOND_FAILED; } -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device success."); -#endif LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 121e0c3f..4d431810 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -47,6 +47,7 @@ if (defined(ohos_lite)) { "//base/security/deviceauth/interfaces/innerkits", "//third_party/json/include", "${utils_path}/include", + "${utils_path}/include/hisysevent/lite", "${utils_path}/include/permission/lite", "foundation/multimedia/image_standard/mock/native/include", "${services_path}/include/dispatch", @@ -152,6 +153,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/lite", + "${utils_path}/include/hisysevent/lite", "${utils_path}/include/ipc/lite", "${utils_path}/include/permission/lite", "${innerkits_path}/native_cpp/include", @@ -255,6 +257,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/standard", + "${utils_path}/include/hisysevent/standard", "${utils_path}/include/permission/standard", "//base/security/deviceauth/interfaces/innerkits", "//third_party/json/include", diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 7eb3b303..7376e49e 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -14,9 +14,6 @@ */ #include "hichain_connector.h" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) -#include "dm_hisysevent.h" -#endif #include @@ -26,6 +23,7 @@ #include "dm_anonymous.h" #include "dm_constants.h" +#include "dm_hisysevent.h" #include "dm_log.h" #include "dm_random.h" #include "hichain_connector_callback.h" @@ -264,20 +262,16 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group success."); -#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, + HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group success."); -#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -297,20 +291,16 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group failed."); -#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DistributedDM::HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, + HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group failed."); -#endif if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index 4e9ab50f..1dcf5769 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -16,9 +16,7 @@ #include "dm_log.h" #include "dm_constants.h" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" -#endif #include "dm_adapter_manager.h" #include "ipc_notify_device_state_req.h" #include "ipc_notify_auth_result_req.h" diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index ccb12e0e..da9ee309 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,9 +24,7 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "dm_hisysevent.h" -#endif #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" diff --git a/utils/BUILD.gn b/utils/BUILD.gn index fd487eff..d33ccc9f 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -24,6 +24,7 @@ if (defined(ohos_lite)) { static_library("devicemanagerutils_mini") { include_dirs = [ "${utils_path}/include", + "${utils_path}/include/hisysevent/lite", "${utils_path}/include/permission/lite", "${common_path}/include", ] @@ -42,9 +43,9 @@ if (defined(ohos_lite)) { sources = [ "${utils_path}/src/dm_anonymous.cpp", "${utils_path}/src/dm_error_message.cpp", - "${utils_path}/src/dm_hisysevent.cpp", "${utils_path}/src/dm_log.cpp", "${utils_path}/src/dm_random.cpp", + "${utils_path}/src/hisysevent/lite/dm_hisysevent.cpp", "${utils_path}/src/permission/lite/permission_manager.cpp", ] @@ -72,6 +73,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "include", + "include/hisysevent/lite", "include/fwkload/lite", "include/ipc/lite", "include/permission/lite", @@ -95,10 +97,10 @@ if (defined(ohos_lite)) { sources = [ "src/dm_anonymous.cpp", "src/dm_error_message.cpp", - "src/dm_hisysevent.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/fwkload/lite/dm_distributed_hardware_load.cpp", + "src/hisysevent/lite/dm_hisysevent.cpp", "src/ipc/lite/ipc_cmd_register.cpp", "src/permission/lite/permission_manager.cpp", ] @@ -125,6 +127,7 @@ if (defined(ohos_lite)) { include_dirs = [ "include", "include/fwkload/standard", + "include/hisysevent/standard", "include/ipc/standard", "${common_path}/include", "${common_path}/include/ipc", @@ -139,7 +142,6 @@ if (defined(ohos_lite)) { "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_hash.cpp", - "src/dm_hisysevent.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/ipc/standard/ipc_cmd_register.cpp", @@ -147,6 +149,7 @@ if (defined(ohos_lite)) { if (support_jsapi) { sources += [ "src/fwkload/standard/dm_distributed_hardware_load.cpp", + "src/hisysevent/standard/dm_hisysevent.cpp", "src/permission/standard/permission_manager.cpp", ] } diff --git a/utils/include/hisysevent/lite/dm_hisysevent.h b/utils/include/hisysevent/lite/dm_hisysevent.h new file mode 100644 index 00000000..819ae8cb --- /dev/null +++ b/utils/include/hisysevent/lite/dm_hisysevent.h @@ -0,0 +1,37 @@ +/* + * 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_DM_HISYSEVENT_H +#define OHOS_DISTRIBUTED_DM_HISYSEVENT_H + +#include "single_instance.h" +#include "dm_log.h" +#include "dm_constants.h" +#include "dm_anonymous.h" + +#include +#include + +namespace OHOS { +namespace DistributedHardware { +class HisyseventUtil { + DECLARE_SINGLE_INSTANCE(HisyseventUtil); + +public: + void SysEventWrite(void); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/include/dm_hisysevent.h b/utils/include/hisysevent/standard/dm_hisysevent.h similarity index 73% rename from utils/include/dm_hisysevent.h rename to utils/include/hisysevent/standard/dm_hisysevent.h index 1d6e3ffe..684e7f86 100644 --- a/utils/include/dm_hisysevent.h +++ b/utils/include/hisysevent/standard/dm_hisysevent.h @@ -16,21 +16,17 @@ #ifndef OHOS_DISTRIBUTED_DM_HISYSEVENT_H #define OHOS_DISTRIBUTED_DM_HISYSEVENT_H -#include -#include - #include "single_instance.h" -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) -#include "hisysevent.h" -#endif #include "dm_log.h" #include "dm_constants.h" #include "dm_anonymous.h" +#include "hisysevent.h" + +#include +#include namespace OHOS { namespace DistributedHardware { -namespace DistributedDM { -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #define DM_INIT_DEVICE_MANAGER_SUCCESS "DM_INIT_DEVICE_MANAGER_SUCCESS" #define DM_INIT_DEVICE_MANAGER_FAILED "DM_INIT_DEVICE_MANAGER_FAILED" #define START_DEVICE_DISCOVERY_SUCCESS "START_DEVICE_DISCOVERY_SUCCESS" @@ -46,20 +42,16 @@ namespace DistributedDM { #define UNAUTHENTICATE_DEVICE_SUCCESS "UNAUTHENTICATE_DEVICE_SUCCESS" #define UNAUTHENTICATE_DEVICE_FAILED "UNAUTHENTICATE_DEVICE_FAILED" +#define DM_SYSEVENTT_FAULT OHOS::HiviewDFX::HiSysEvent::EventType::FAULT +#define DM_SYSEVENTT_BEHAVIOR OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR + class HisyseventUtil { -DECLARE_SINGLE_INSTANCE_BASE(HisyseventUtil); + DECLARE_SINGLE_INSTANCE(HisyseventUtil); + public: void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); - void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, - std::string devId, std::string msg); - void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, - std::string devId, std::string dhId, std::string msg); -private: - HisyseventUtil() = default; - ~HisyseventUtil() = default; + }; -#endif -} // namespace DistributedDM -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/src/hisysevent/lite/dm_hisysevent.cpp b/utils/src/hisysevent/lite/dm_hisysevent.cpp new file mode 100644 index 00000000..8c9cdb4e --- /dev/null +++ b/utils/src/hisysevent/lite/dm_hisysevent.cpp @@ -0,0 +1,26 @@ +/* + * 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 "dm_hisysevent.h" + +namespace OHOS { +namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); +void HisyseventUtil::SysEventWrite(void) +{ + return; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/src/dm_hisysevent.cpp b/utils/src/hisysevent/standard/dm_hisysevent.cpp similarity index 50% rename from utils/src/dm_hisysevent.cpp rename to utils/src/hisysevent/standard/dm_hisysevent.cpp index 91001ed7..bffec93c 100644 --- a/utils/src/dm_hisysevent.cpp +++ b/utils/src/hisysevent/standard/dm_hisysevent.cpp @@ -17,8 +17,6 @@ namespace OHOS { namespace DistributedHardware { -namespace DistributedDM { -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, @@ -35,40 +33,5 @@ void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEve LOGE("Write HiSysEvent error, res:%d", res); } } - -void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, - std::string devId, std::string msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, - status, - eventType, - "DEVID", GetAnonyString(devId), - "PID", getpid(), - "UID", getuid(), - "MSG", msg); - if (res != DM_OK) { - LOGE("Write HiSysEvent error, res:%d", res); - } -} - -void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, - std::string devId, std::string dhId, std::string msg) -{ - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, - status, - eventType, - "DEVID", GetAnonyString(devId), - "DHID", GetAnonyString(dhId), - "PID", getpid(), - "UID", getuid(), - "MSG", msg); - if (res != DM_OK) { - LOGE("Write HiSysEvent error, res:%d", res); - } -} -#endif -} // namespace DistributedDM } // namespace DistributedHardware } // namespace OHOS From 26116c0ee989697d44035313bba0a8979d945708 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Sat, 18 Jun 2022 18:05:11 +0800 Subject: [PATCH 15/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/BUILD.gn | 2 +- utils/include/hisysevent/lite/dm_hisysevent.h | 3 --- utils/include/hisysevent/standard/dm_hisysevent.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index d33ccc9f..9d8dc731 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -144,12 +144,12 @@ if (defined(ohos_lite)) { "src/dm_hash.cpp", "src/dm_log.cpp", "src/dm_random.cpp", + "src/hisysevent/standard/dm_hisysevent.cpp", "src/ipc/standard/ipc_cmd_register.cpp", ] if (support_jsapi) { sources += [ "src/fwkload/standard/dm_distributed_hardware_load.cpp", - "src/hisysevent/standard/dm_hisysevent.cpp", "src/permission/standard/permission_manager.cpp", ] } diff --git a/utils/include/hisysevent/lite/dm_hisysevent.h b/utils/include/hisysevent/lite/dm_hisysevent.h index 819ae8cb..552ac549 100644 --- a/utils/include/hisysevent/lite/dm_hisysevent.h +++ b/utils/include/hisysevent/lite/dm_hisysevent.h @@ -17,9 +17,6 @@ #define OHOS_DISTRIBUTED_DM_HISYSEVENT_H #include "single_instance.h" -#include "dm_log.h" -#include "dm_constants.h" -#include "dm_anonymous.h" #include #include diff --git a/utils/include/hisysevent/standard/dm_hisysevent.h b/utils/include/hisysevent/standard/dm_hisysevent.h index 684e7f86..813e0749 100644 --- a/utils/include/hisysevent/standard/dm_hisysevent.h +++ b/utils/include/hisysevent/standard/dm_hisysevent.h @@ -50,7 +50,6 @@ class HisyseventUtil { public: void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); - }; } // namespace DistributedHardware } // namespace OHOS From 8585e0f907be6fbfdf36a803191887e3e08befc5 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 11:59:55 +0800 Subject: [PATCH 16/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9hisysevent=20Signed-off?= =?UTF-8?q?-by:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_kits/native_cpp/BUILD.gn | 5 +- .../native_cpp/src/device_manager_impl.cpp | 40 +++++----- services/devicemanagerservice/BUILD.gn | 6 +- .../dependency/hichain/hichain_connector.cpp | 16 ++-- utils/BUILD.gn | 12 +-- .../{hisysevent => dfx}/lite/dm_hisysevent.h | 4 +- utils/include/dfx/standard/dm_hisysevent.h | 78 +++++++++++++++++++ .../hisysevent/standard/dm_hisysevent.h | 56 ------------- .../lite/dm_hisysevent.cpp | 2 +- .../standard/dm_hisysevent.cpp | 7 +- 10 files changed, 125 insertions(+), 101 deletions(-) rename utils/include/{hisysevent => dfx}/lite/dm_hisysevent.h (88%) create mode 100644 utils/include/dfx/standard/dm_hisysevent.h delete mode 100644 utils/include/hisysevent/standard/dm_hisysevent.h rename utils/src/{hisysevent => dfx}/lite/dm_hisysevent.cpp (88%) rename utils/src/{hisysevent => dfx}/standard/dm_hisysevent.cpp (81%) diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index a9e4ba79..272a55f4 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -25,7 +25,7 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include", "${innerkits_path}/native_cpp/include/notify", "${utils_path}/include", - "${utils_path}/include/hisysevent/lite", + "${utils_path}/include/dfx/lite", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -71,7 +71,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include", - "${utils_path}/include/hisysevent/lite", + "${utils_path}/include/dfx/lite", "${utils_path}/include/ipc/lite", ] include_dirs += [ @@ -120,6 +120,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include/ipc/standard", + "${utils_path}/include/dfx/standard", ] } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 58be8921..cd2ee3bb 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -69,15 +69,15 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "init devicemanager failed."); + HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, DM_HISYEVENT_FAULT, + DM_INIT_DEVICE_MANAGER_FAILED_MSG); return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); LOGI("InitDeviceManager success"); - HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "init devicemanager success."); + HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, DM_HISYEVENT_BEHAVIOR, + DM_INIT_DEVICE_MANAGER_SUCCESS_MSG); return DM_OK; } @@ -145,15 +145,15 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info failed."); + HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, DM_HISYEVENT_BEHAVIOR, + GET_LOCAL_DEVICE_INFO_FAILED_MSG); return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); - HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "get local device info success."); + HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, DM_HISYEVENT_BEHAVIOR, + GET_LOCAL_DEVICE_INFO_SUCCESS_MSG); return DM_OK; } @@ -215,14 +215,14 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery failed."); + HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, DM_HISYEVENT_BEHAVIOR, + START_DEVICE_DISCOVERY_FAILED_MSG); return ret; } LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); - HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "device manager discovery success."); + HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, DM_HISYEVENT_BEHAVIOR, + START_DEVICE_DISCOVERY_SUCCESS_MSG); return DM_OK; } @@ -277,12 +277,12 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request failed."); + HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, DM_HISYEVENT_BEHAVIOR, + DM_SEND_REQUEST_FAILED_MSG); return ERR_DM_IPC_SEND_REQUEST_FAILED; } - HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "send request success."); + HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, DM_HISYEVENT_BEHAVIOR, + DM_SEND_REQUEST_SUCCESS_MSG); ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -314,12 +314,12 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device failed."); + HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, DM_HISYEVENT_BEHAVIOR, + UNAUTHENTICATE_DEVICE_FAILED_MSG); return ERR_DM_IPC_RESPOND_FAILED; } - HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "unauthenticate device success."); + HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, DM_HISYEVENT_BEHAVIOR, + UNAUTHENTICATE_DEVICE_SUCCESS_MSG); LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 4d431810..e72d0a2d 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -47,7 +47,7 @@ if (defined(ohos_lite)) { "//base/security/deviceauth/interfaces/innerkits", "//third_party/json/include", "${utils_path}/include", - "${utils_path}/include/hisysevent/lite", + "${utils_path}/include/dfx/lite", "${utils_path}/include/permission/lite", "foundation/multimedia/image_standard/mock/native/include", "${services_path}/include/dispatch", @@ -153,7 +153,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/lite", - "${utils_path}/include/hisysevent/lite", + "${utils_path}/include/dfx/lite", "${utils_path}/include/ipc/lite", "${utils_path}/include/permission/lite", "${innerkits_path}/native_cpp/include", @@ -257,7 +257,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/standard", - "${utils_path}/include/hisysevent/standard", + "${utils_path}/include/dfx/standard", "${utils_path}/include/permission/standard", "//base/security/deviceauth/interfaces/innerkits", "//third_party/json/include", diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index 7376e49e..db39f993 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -262,16 +262,16 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); - HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group success."); + HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, + ADD_HICHAIN_GROUP_SUCCESS_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); - HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group success."); + HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, + DM_CREATE_GROUP_SUCCESS_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -291,16 +291,16 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); - HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm add member to group failed."); + HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, + ADD_HICHAIN_GROUP_FAILED_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); - HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dm create group failed."); + HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, + DM_CREATE_GROUP_FAILED_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 9d8dc731..92f51f30 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -24,7 +24,7 @@ if (defined(ohos_lite)) { static_library("devicemanagerutils_mini") { include_dirs = [ "${utils_path}/include", - "${utils_path}/include/hisysevent/lite", + "${utils_path}/include/dfx/lite", "${utils_path}/include/permission/lite", "${common_path}/include", ] @@ -41,11 +41,11 @@ if (defined(ohos_lite)) { ] sources = [ + "${utils_path}/src/dfx/lite/dm_hisysevent.cpp", "${utils_path}/src/dm_anonymous.cpp", "${utils_path}/src/dm_error_message.cpp", "${utils_path}/src/dm_log.cpp", "${utils_path}/src/dm_random.cpp", - "${utils_path}/src/hisysevent/lite/dm_hisysevent.cpp", "${utils_path}/src/permission/lite/permission_manager.cpp", ] @@ -73,7 +73,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "include", - "include/hisysevent/lite", + "include/dfx/lite", "include/fwkload/lite", "include/ipc/lite", "include/permission/lite", @@ -95,12 +95,12 @@ if (defined(ohos_lite)) { "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", ] sources = [ + "src/dfx/lite/dm_hisysevent.cpp", "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/fwkload/lite/dm_distributed_hardware_load.cpp", - "src/hisysevent/lite/dm_hisysevent.cpp", "src/ipc/lite/ipc_cmd_register.cpp", "src/permission/lite/permission_manager.cpp", ] @@ -127,7 +127,7 @@ if (defined(ohos_lite)) { include_dirs = [ "include", "include/fwkload/standard", - "include/hisysevent/standard", + "include/dfx/standard", "include/ipc/standard", "${common_path}/include", "${common_path}/include/ipc", @@ -139,12 +139,12 @@ if (defined(ohos_lite)) { ohos_shared_library("devicemanagerutils") { sources = [ + "src/dfx/standard/dm_hisysevent.cpp", "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_hash.cpp", "src/dm_log.cpp", "src/dm_random.cpp", - "src/hisysevent/standard/dm_hisysevent.cpp", "src/ipc/standard/ipc_cmd_register.cpp", ] if (support_jsapi) { diff --git a/utils/include/hisysevent/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h similarity index 88% rename from utils/include/hisysevent/lite/dm_hisysevent.h rename to utils/include/dfx/lite/dm_hisysevent.h index 552ac549..bc6e8159 100644 --- a/utils/include/hisysevent/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -17,6 +17,7 @@ #define OHOS_DISTRIBUTED_DM_HISYSEVENT_H #include "single_instance.h" +#include "dm_constants.h" #include #include @@ -27,7 +28,8 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(void); + void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); +{ }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h new file mode 100644 index 00000000..5ec203d8 --- /dev/null +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -0,0 +1,78 @@ +/* + * 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_DM_HISYSEVENT_H +#define OHOS_DISTRIBUTED_DM_HISYSEVENT_H + +#include "single_instance.h" +#include "dm_log.h" +#include "dm_constants.h" +#include "dm_anonymous.h" +#include "hisysevent.h" + +#include +#include + +namespace OHOS { +namespace DistributedHardware { +// type +enum DM_HISYEVENT_EventType { + DM_HISYEVENT_FAULT = 1, // system fault event + DM_HISYEVENT_STATISTIC = 2, // system statistic event + DM_HISYEVENT_SECURITY = 3, // system security event + DM_HISYEVENT_BEHAVIOR = 4 // system behavior event +}; + +// state +const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS"; +const std::string DM_INIT_DEVICE_MANAGER_FAILED = "DM_INIT_DEVICE_MANAGER_FAILED"; +const std::string START_DEVICE_DISCOVERY_SUCCESS = "START_DEVICE_DISCOVERY_SUCCESS"; +const std::string START_DEVICE_DISCOVERY_FAILED = "START_DEVICE_DISCOVERY_FAILED"; +const std::string GET_LOCAL_DEVICE_INFO_SUCCESS = "GET_LOCAL_DEVICE_INFO_SUCCESS"; +const std::string GET_LOCAL_DEVICE_INFO_FAILED = "GET_LOCAL_DEVICE_INFO_FAILED"; +const std::string DM_SEND_REQUEST_SUCCESS = "DM_SEND_REQUEST_SUCCESS"; +const std::string DM_SEND_REQUEST_FAILED = "DM_SEND_REQUEST_FAILED"; +const std::string ADD_HICHAIN_GROUP_SUCCESS = "ADD_HICHAIN_GROUP_SUCCESS"; +const std::string ADD_HICHAIN_GROUP_FAILED = "ADD_HICHAIN_GROUP_FAILED"; +const std::string DM_CREATE_GROUP_SUCCESS = "DM_CREATE_GROUP_SUCCESS"; +const std::string DM_CREATE_GROUP_FAILED = "DM_CREATE_GROUP_FAILED"; +const std::string UNAUTHENTICATE_DEVICE_SUCCESS = "UNAUTHENTICATE_DEVICE_SUCCESS"; +const std::string UNAUTHENTICATE_DEVICE_FAILED = "UNAUTHENTICATE_DEVICE_FAILED"; + +// msg +const std::string DM_INIT_DEVICE_MANAGER_SUCCESS_MSG = "init devicemanager success."; +const std::string DM_INIT_DEVICE_MANAGER_FAILED_MSG = "init devicemanager failed."; +const std::string START_DEVICE_DISCOVERY_SUCCESS_MSG = "device manager discovery success."; +const std::string START_DEVICE_DISCOVERY_FAILED_MSG = "device manager discovery failed."; +const std::string GET_LOCAL_DEVICE_INFO_SUCCESS_MSG = "get local device info success."; +const std::string GET_LOCAL_DEVICE_INFO_FAILED_MSG = "get local device info failed."; +const std::string DM_SEND_REQUEST_SUCCESS_MSG = "send request success."; +const std::string DM_SEND_REQUEST_FAILED_MSG = "send request failed."; +const std::string ADD_HICHAIN_GROUP_SUCCESS_MSG = "dm add member to group success."; +const std::string ADD_HICHAIN_GROUP_FAILED_MSG = "dm add member to group failed."; +const std::string DM_CREATE_GROUP_SUCCESS_MSG = "dm create group success."; +const std::string DM_CREATE_GROUP_FAILED_MSG = "dm create group failed."; +const std::string UNAUTHENTICATE_DEVICE_SUCCESS_MSG = "unauthenticate device success."; +const std::string UNAUTHENTICATE_DEVICE_FAILED_MSG = "unauthenticate device failed."; + +class HisyseventUtil { + DECLARE_SINGLE_INSTANCE(HisyseventUtil); + +public: + void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/include/hisysevent/standard/dm_hisysevent.h b/utils/include/hisysevent/standard/dm_hisysevent.h deleted file mode 100644 index 813e0749..00000000 --- a/utils/include/hisysevent/standard/dm_hisysevent.h +++ /dev/null @@ -1,56 +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_DM_HISYSEVENT_H -#define OHOS_DISTRIBUTED_DM_HISYSEVENT_H - -#include "single_instance.h" -#include "dm_log.h" -#include "dm_constants.h" -#include "dm_anonymous.h" -#include "hisysevent.h" - -#include -#include - -namespace OHOS { -namespace DistributedHardware { -#define DM_INIT_DEVICE_MANAGER_SUCCESS "DM_INIT_DEVICE_MANAGER_SUCCESS" -#define DM_INIT_DEVICE_MANAGER_FAILED "DM_INIT_DEVICE_MANAGER_FAILED" -#define START_DEVICE_DISCOVERY_SUCCESS "START_DEVICE_DISCOVERY_SUCCESS" -#define START_DEVICE_DISCOVERY_FAILED "START_DEVICE_DISCOVERY_FAILED" -#define GET_LOCAL_DEVICE_INFO_SUCCESS "GET_LOCAL_DEVICE_INFO_SUCCESS" -#define GET_LOCAL_DEVICE_INFO_FAILED "GET_LOCAL_DEVICE_INFO_FAILED" -#define DM_SEND_REQUEST_SUCCESS "DM_SEND_REQUEST_SUCCESS" -#define DM_SEND_REQUEST_FAILED "DM_SEND_REQUEST_FAILED" -#define ADD_HICHAIN_GROUP_SUCCESS "ADD_HICHAIN_GROUP_SUCCESS" -#define ADD_HICHAIN_GROUP_FAILED "ADD_HICHAIN_GROUP_FAILED" -#define DM_CREATE_GROUP_SUCCESS "DM_CREATE_GROUP_SUCCESS" -#define DM_CREATE_GROUP_FAILED "DM_CREATE_GROUP_FAILED" -#define UNAUTHENTICATE_DEVICE_SUCCESS "UNAUTHENTICATE_DEVICE_SUCCESS" -#define UNAUTHENTICATE_DEVICE_FAILED "UNAUTHENTICATE_DEVICE_FAILED" - -#define DM_SYSEVENTT_FAULT OHOS::HiviewDFX::HiSysEvent::EventType::FAULT -#define DM_SYSEVENTT_BEHAVIOR OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR - -class HisyseventUtil { - DECLARE_SINGLE_INSTANCE(HisyseventUtil); - -public: - void SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, std::string msg); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/src/hisysevent/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp similarity index 88% rename from utils/src/hisysevent/lite/dm_hisysevent.cpp rename to utils/src/dfx/lite/dm_hisysevent.cpp index 8c9cdb4e..bbe820dd 100644 --- a/utils/src/hisysevent/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(void) +void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg) { return; } diff --git a/utils/src/hisysevent/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp similarity index 81% rename from utils/src/hisysevent/standard/dm_hisysevent.cpp rename to utils/src/dfx/standard/dm_hisysevent.cpp index bffec93c..d6e97c70 100644 --- a/utils/src/hisysevent/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -19,18 +19,17 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string status, OHOS::HiviewDFX::HiSysEvent::EventType eventType, - std::string msg) +void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType eventType, std::string msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, status, - eventType, + (OHOS::HiviewDFX::HiSysEvent::EventType)eventType, "PID", getpid(), "UID", getuid(), "MSG", msg); if (res != DM_OK) { - LOGE("Write HiSysEvent error, res:%d", res); + LOGE("%s Write HiSysEvent error, res:%d", status.c_str(), res); } } } // namespace DistributedHardware From b7966e09f3962f62d0d0196b126f81cd57227c95 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 12:52:22 +0800 Subject: [PATCH 17/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20Signed-off-by:=20wan?= =?UTF-8?q?gyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp | 2 +- utils/include/dfx/lite/dm_hisysevent.h | 4 +--- utils/src/dfx/lite/dm_hisysevent.cpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index cd2ee3bb..739c4635 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -69,7 +69,7 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, DM_HISYEVENT_FAULT, + HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, DM_HISYEVENT_FAULT, DM_INIT_DEVICE_MANAGER_FAILED_MSG); return ERR_DM_INIT_FAILED; } diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index bc6e8159..2ada5ee5 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -28,9 +28,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); -{ -}; + void SysEventWrite(void); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index bbe820dd..8c9cdb4e 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg) +void HisyseventUtil::SysEventWrite(void) { return; } From 23d28076cff081068e1b593eae86532af87369a0 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 13:16:17 +0800 Subject: [PATCH 18/34] 12 Signed-off-by: wangyb0625 --- utils/include/dfx/lite/dm_hisysevent.h | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index 2ada5ee5..a2b02767 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -29,6 +29,7 @@ class HisyseventUtil { public: void SysEventWrite(void); +}; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H From ccaacc7b069ee22b84137ace4849d4e3b82a286c Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 15:14:35 +0800 Subject: [PATCH 19/34] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/BUILD.gn | 3 ++ utils/include/dfx/dm_dfx_constants.h | 63 ++++++++++++++++++++++ utils/include/dfx/lite/dm_hisysevent.h | 3 +- utils/include/dfx/standard/dm_hisysevent.h | 45 ++-------------- utils/src/dfx/lite/dm_hisysevent.cpp | 2 +- 5 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 utils/include/dfx/dm_dfx_constants.h diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 92f51f30..17fc9f56 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -24,6 +24,7 @@ if (defined(ohos_lite)) { static_library("devicemanagerutils_mini") { include_dirs = [ "${utils_path}/include", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/lite", "${utils_path}/include/permission/lite", "${common_path}/include", @@ -73,6 +74,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "include", + "include/dfx", "include/dfx/lite", "include/fwkload/lite", "include/ipc/lite", @@ -127,6 +129,7 @@ if (defined(ohos_lite)) { include_dirs = [ "include", "include/fwkload/standard", + "include/dfx", "include/dfx/standard", "include/ipc/standard", "${common_path}/include", diff --git a/utils/include/dfx/dm_dfx_constants.h b/utils/include/dfx/dm_dfx_constants.h new file mode 100644 index 00000000..0f63eb53 --- /dev/null +++ b/utils/include/dfx/dm_dfx_constants.h @@ -0,0 +1,63 @@ +/* + * 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_DM_DFX_CONSTANTS_H +#define OHOS_DM_DFX_CONSTANTS_H + +#include + +namespace OHOS { +namespace DistributedHardware { +// type +enum DM_HISYEVENT_EventType { + DM_HISYEVENT_FAULT = 1, // system fault event + DM_HISYEVENT_STATISTIC = 2, // system statistic event + DM_HISYEVENT_SECURITY = 3, // system security event + DM_HISYEVENT_BEHAVIOR = 4 // system behavior event +}; + +// state +const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS"; +const std::string DM_INIT_DEVICE_MANAGER_FAILED = "DM_INIT_DEVICE_MANAGER_FAILED"; +const std::string START_DEVICE_DISCOVERY_SUCCESS = "START_DEVICE_DISCOVERY_SUCCESS"; +const std::string START_DEVICE_DISCOVERY_FAILED = "START_DEVICE_DISCOVERY_FAILED"; +const std::string GET_LOCAL_DEVICE_INFO_SUCCESS = "GET_LOCAL_DEVICE_INFO_SUCCESS"; +const std::string GET_LOCAL_DEVICE_INFO_FAILED = "GET_LOCAL_DEVICE_INFO_FAILED"; +const std::string DM_SEND_REQUEST_SUCCESS = "DM_SEND_REQUEST_SUCCESS"; +const std::string DM_SEND_REQUEST_FAILED = "DM_SEND_REQUEST_FAILED"; +const std::string ADD_HICHAIN_GROUP_SUCCESS = "ADD_HICHAIN_GROUP_SUCCESS"; +const std::string ADD_HICHAIN_GROUP_FAILED = "ADD_HICHAIN_GROUP_FAILED"; +const std::string DM_CREATE_GROUP_SUCCESS = "DM_CREATE_GROUP_SUCCESS"; +const std::string DM_CREATE_GROUP_FAILED = "DM_CREATE_GROUP_FAILED"; +const std::string UNAUTHENTICATE_DEVICE_SUCCESS = "UNAUTHENTICATE_DEVICE_SUCCESS"; +const std::string UNAUTHENTICATE_DEVICE_FAILED = "UNAUTHENTICATE_DEVICE_FAILED"; + +// msg +const std::string DM_INIT_DEVICE_MANAGER_SUCCESS_MSG = "init devicemanager success."; +const std::string DM_INIT_DEVICE_MANAGER_FAILED_MSG = "init devicemanager failed."; +const std::string START_DEVICE_DISCOVERY_SUCCESS_MSG = "device manager discovery success."; +const std::string START_DEVICE_DISCOVERY_FAILED_MSG = "device manager discovery failed."; +const std::string GET_LOCAL_DEVICE_INFO_SUCCESS_MSG = "get local device info success."; +const std::string GET_LOCAL_DEVICE_INFO_FAILED_MSG = "get local device info failed."; +const std::string DM_SEND_REQUEST_SUCCESS_MSG = "send request success."; +const std::string DM_SEND_REQUEST_FAILED_MSG = "send request failed."; +const std::string ADD_HICHAIN_GROUP_SUCCESS_MSG = "dm add member to group success."; +const std::string ADD_HICHAIN_GROUP_FAILED_MSG = "dm add member to group failed."; +const std::string DM_CREATE_GROUP_SUCCESS_MSG = "dm create group success."; +const std::string DM_CREATE_GROUP_FAILED_MSG = "dm create group failed."; +const std::string UNAUTHENTICATE_DEVICE_SUCCESS_MSG = "unauthenticate device success."; +const std::string UNAUTHENTICATE_DEVICE_FAILED_MSG = "unauthenticate device failed."; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_CONSTANTS_H diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index a2b02767..e1ea4156 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -18,6 +18,7 @@ #include "single_instance.h" #include "dm_constants.h" +#include "dm_dfx_constants.h" #include #include @@ -28,7 +29,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(void); + void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h index 5ec203d8..b8a16a9e 100644 --- a/utils/include/dfx/standard/dm_hisysevent.h +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -16,57 +16,18 @@ #ifndef OHOS_DISTRIBUTED_DM_HISYSEVENT_H #define OHOS_DISTRIBUTED_DM_HISYSEVENT_H -#include "single_instance.h" +#include "dm_anonymous.h" #include "dm_log.h" #include "dm_constants.h" -#include "dm_anonymous.h" +#include "dm_dfx_constants.h" #include "hisysevent.h" +#include "single_instance.h" #include #include namespace OHOS { namespace DistributedHardware { -// type -enum DM_HISYEVENT_EventType { - DM_HISYEVENT_FAULT = 1, // system fault event - DM_HISYEVENT_STATISTIC = 2, // system statistic event - DM_HISYEVENT_SECURITY = 3, // system security event - DM_HISYEVENT_BEHAVIOR = 4 // system behavior event -}; - -// state -const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS"; -const std::string DM_INIT_DEVICE_MANAGER_FAILED = "DM_INIT_DEVICE_MANAGER_FAILED"; -const std::string START_DEVICE_DISCOVERY_SUCCESS = "START_DEVICE_DISCOVERY_SUCCESS"; -const std::string START_DEVICE_DISCOVERY_FAILED = "START_DEVICE_DISCOVERY_FAILED"; -const std::string GET_LOCAL_DEVICE_INFO_SUCCESS = "GET_LOCAL_DEVICE_INFO_SUCCESS"; -const std::string GET_LOCAL_DEVICE_INFO_FAILED = "GET_LOCAL_DEVICE_INFO_FAILED"; -const std::string DM_SEND_REQUEST_SUCCESS = "DM_SEND_REQUEST_SUCCESS"; -const std::string DM_SEND_REQUEST_FAILED = "DM_SEND_REQUEST_FAILED"; -const std::string ADD_HICHAIN_GROUP_SUCCESS = "ADD_HICHAIN_GROUP_SUCCESS"; -const std::string ADD_HICHAIN_GROUP_FAILED = "ADD_HICHAIN_GROUP_FAILED"; -const std::string DM_CREATE_GROUP_SUCCESS = "DM_CREATE_GROUP_SUCCESS"; -const std::string DM_CREATE_GROUP_FAILED = "DM_CREATE_GROUP_FAILED"; -const std::string UNAUTHENTICATE_DEVICE_SUCCESS = "UNAUTHENTICATE_DEVICE_SUCCESS"; -const std::string UNAUTHENTICATE_DEVICE_FAILED = "UNAUTHENTICATE_DEVICE_FAILED"; - -// msg -const std::string DM_INIT_DEVICE_MANAGER_SUCCESS_MSG = "init devicemanager success."; -const std::string DM_INIT_DEVICE_MANAGER_FAILED_MSG = "init devicemanager failed."; -const std::string START_DEVICE_DISCOVERY_SUCCESS_MSG = "device manager discovery success."; -const std::string START_DEVICE_DISCOVERY_FAILED_MSG = "device manager discovery failed."; -const std::string GET_LOCAL_DEVICE_INFO_SUCCESS_MSG = "get local device info success."; -const std::string GET_LOCAL_DEVICE_INFO_FAILED_MSG = "get local device info failed."; -const std::string DM_SEND_REQUEST_SUCCESS_MSG = "send request success."; -const std::string DM_SEND_REQUEST_FAILED_MSG = "send request failed."; -const std::string ADD_HICHAIN_GROUP_SUCCESS_MSG = "dm add member to group success."; -const std::string ADD_HICHAIN_GROUP_FAILED_MSG = "dm add member to group failed."; -const std::string DM_CREATE_GROUP_SUCCESS_MSG = "dm create group success."; -const std::string DM_CREATE_GROUP_FAILED_MSG = "dm create group failed."; -const std::string UNAUTHENTICATE_DEVICE_SUCCESS_MSG = "unauthenticate device success."; -const std::string UNAUTHENTICATE_DEVICE_FAILED_MSG = "unauthenticate device failed."; - class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index 8c9cdb4e..bbe820dd 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(void) +void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg) { return; } From fde3579680dc95bc87adf8c1d830455e71014a95 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 16:37:42 +0800 Subject: [PATCH 20/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9L1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- interfaces/inner_kits/native_cpp/BUILD.gn | 3 +++ interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp | 1 + services/devicemanagerservice/BUILD.gn | 3 +++ 3 files changed, 7 insertions(+) diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 272a55f4..61137065 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -25,6 +25,7 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include", "${innerkits_path}/native_cpp/include/notify", "${utils_path}/include", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/lite", "${common_path}/include", "${common_path}/include/ipc", @@ -71,6 +72,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/lite", "${utils_path}/include/ipc/lite", ] @@ -120,6 +122,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include/ipc/standard", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/standard", ] } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 739c4635..5c07b3cc 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -18,6 +18,7 @@ #include "device_manager_notify.h" #include "dm_anonymous.h" #include "dm_constants.h" +#include "dm_dfx_constants.h" #include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_authenticate_device_req.h" diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index e72d0a2d..61f0fcb2 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -47,6 +47,7 @@ if (defined(ohos_lite)) { "//base/security/deviceauth/interfaces/innerkits", "//third_party/json/include", "${utils_path}/include", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/lite", "${utils_path}/include/permission/lite", "foundation/multimedia/image_standard/mock/native/include", @@ -153,6 +154,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/lite", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/lite", "${utils_path}/include/ipc/lite", "${utils_path}/include/permission/lite", @@ -257,6 +259,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/fwkload/standard", + "${utils_path}/include/dfx", "${utils_path}/include/dfx/standard", "${utils_path}/include/permission/standard", "//base/security/deviceauth/interfaces/innerkits", From 57f88349ad91c28c0dea71fa38e2cff0f085ba27 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 18:55:13 +0800 Subject: [PATCH 21/34] 123 Signed-off-by: wangyb0625 --- utils/include/dfx/lite/dm_hisysevent.h | 2 +- utils/include/dfx/standard/dm_hisysevent.h | 2 +- utils/src/dfx/lite/dm_hisysevent.cpp | 2 +- utils/src/dfx/standard/dm_hisysevent.cpp | 8 +++----- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index e1ea4156..bac4ca97 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -29,7 +29,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); + void SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h index b8a16a9e..e16319f7 100644 --- a/utils/include/dfx/standard/dm_hisysevent.h +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -32,7 +32,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg); + void SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index bbe820dd..53ebb6da 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType dmeventType, std::string msg) +void HisyseventUtil::SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg) { return; } diff --git a/utils/src/dfx/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp index d6e97c70..cffb46e8 100644 --- a/utils/src/dfx/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -19,15 +19,13 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string status, DM_HISYEVENT_EventType eventType, std::string msg) +void HisyseventUtil::SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, - status, + status.c_str(), (OHOS::HiviewDFX::HiSysEvent::EventType)eventType, - "PID", getpid(), - "UID", getuid(), - "MSG", msg); + "MSG", msg.c_str()); if (res != DM_OK) { LOGE("%s Write HiSysEvent error, res:%d", status.c_str(), res); } From 6ed691647d8464dcab0fb6cd476b9b19dba51da3 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Mon, 20 Jun 2022 21:09:28 +0800 Subject: [PATCH 22/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- hisysevent.yaml | 56 +++++++++++----------- interfaces/inner_kits/native_cpp/BUILD.gn | 1 - test/unittest/BUILD.gn | 3 -- test/unittest/UTTest_softbus_connector.cpp | 1 - utils/include/dfx/lite/dm_hisysevent.h | 2 +- utils/include/dfx/standard/dm_hisysevent.h | 2 +- utils/src/dfx/lite/dm_hisysevent.cpp | 2 +- utils/src/dfx/standard/dm_hisysevent.cpp | 4 +- 8 files changed, 34 insertions(+), 37 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 94239bd8..a846a26b 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -41,84 +41,84 @@ domain: DISTDM DM_INIT_DEVICE_MANAGER_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm init devicemanager success} DM_INIT_DEVICE_MANAGER_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm init devicemanager failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm init devicemanager failed} START_DEVICE_DISCOVERY_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: device manager discovery success} START_DEVICE_DISCOVERY_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: device manager discovery failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: device manager discovery failed} GET_LOCAL_DEVICE_INFO_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm get local device info success} GET_LOCAL_DEVICE_INFO_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm get local device info failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm get local device info failed} DM_SEND_REQUEST_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm send request success} DM_SEND_REQUEST_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm send request failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm send request failed} ADD_HICHAIN_GROUP_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm add member to group success} ADD_HICHAIN_GROUP_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm add member to group failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm add member to group failed} DM_CREATE_GROUP_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm create group success} DM_CREATE_GROUP_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dm create group failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: dm create group failed} UNAUTHENTICATE_DEVICE_SUCCESS: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device success} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: unauthenticate device success} UNAUTHENTICATE_DEVICE_FAILED: __BASE: {type: BEHAVIOR, level: CRITICAL, desc: unauthenticate device failed} - PID: {type: INT32, desc: dhdevevicemanager pid} - UID: {type: INT32, desc: dhdevevicemanager uid} + PID: {type: INT32, desc: devevicemanager pid} + UID: {type: INT32, desc: devevicemanager uid} MSG: {type: STRING, desc: unauthenticate device failed} diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 61137065..880e147b 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -121,7 +121,6 @@ if (defined(ohos_lite)) { "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", - "${utils_path}/include/ipc/standard", "${utils_path}/include/dfx", "${utils_path}/include/dfx/standard", ] diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 0a1c639d..88a7479b 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -363,8 +363,6 @@ ohos_unittest("UTTest_dm_device_state_manager") { ] deps = [ ":device_manager_test" ] - - external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_dm_device_state_manager }}} @@ -646,7 +644,6 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index da9ee309..01b7976d 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,7 +24,6 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" -#include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index bac4ca97..edd05ce9 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -29,7 +29,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg); + void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h index e16319f7..dcfbb43c 100644 --- a/utils/include/dfx/standard/dm_hisysevent.h +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -32,7 +32,7 @@ class HisyseventUtil { DECLARE_SINGLE_INSTANCE(HisyseventUtil); public: - void SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg); + void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index 53ebb6da..2020063e 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -18,7 +18,7 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg) +void HisyseventUtil::SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) { return; } diff --git a/utils/src/dfx/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp index cffb46e8..aaf627c6 100644 --- a/utils/src/dfx/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -19,12 +19,14 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(std::string &status, DM_HISYEVENT_EventType eventType, std::string &msg) +void HisyseventUtil::SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, status.c_str(), (OHOS::HiviewDFX::HiSysEvent::EventType)eventType, + "PID", getpid(), + "UID", getuid(), "MSG", msg.c_str()); if (res != DM_OK) { LOGE("%s Write HiSysEvent error, res:%d", status.c_str(), res); From 3decb8696c7199adca5f3db91ccb639c5c8e198a Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 09:28:25 +0800 Subject: [PATCH 23/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- test/unittest/BUILD.gn | 3 +++ test/unittest/UTTest_softbus_connector.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 88a7479b..0a1c639d 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -363,6 +363,8 @@ ohos_unittest("UTTest_dm_device_state_manager") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_dm_device_state_manager }}} @@ -644,6 +646,7 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 01b7976d..da9ee309 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,6 +24,7 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" +#include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" From c950f17fad4e292f2e5b20d8adab24ab8f630a28 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 10:47:21 +0800 Subject: [PATCH 24/34] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- test/unittest/BUILD.gn | 7 ------- test/unittest/UTTest_dm_device_state_manager.cpp | 1 - 2 files changed, 8 deletions(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 0a1c639d..8fd97f00 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -158,8 +158,6 @@ ohos_unittest("UTTest_softbus_connector") { ] deps = [ ":device_manager_test" ] - - external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_softbus_connector }}} @@ -285,7 +283,6 @@ ohos_unittest("UTTest_profile_connector") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", ] } @@ -303,7 +300,6 @@ ohos_unittest("UTTest_device_profile_adapter") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", ] } @@ -363,8 +359,6 @@ ohos_unittest("UTTest_dm_device_state_manager") { ] deps = [ ":device_manager_test" ] - - external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_dm_device_state_manager }}} @@ -646,7 +640,6 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index 1dcf5769..e3d5b7b4 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -16,7 +16,6 @@ #include "dm_log.h" #include "dm_constants.h" -#include "dm_hisysevent.h" #include "dm_adapter_manager.h" #include "ipc_notify_device_state_req.h" #include "ipc_notify_auth_result_req.h" From bb0b1dca1fcec5d09210d7cb7900e224b40507d0 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 10:55:40 +0800 Subject: [PATCH 25/34] 11 Signed-off-by: wangyb0625 --- test/unittest/UTTest_softbus_connector.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index da9ee309..01b7976d 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -24,7 +24,6 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "dm_device_info.h" -#include "dm_hisysevent.h" #include "dm_log.h" #include "ipc_notify_auth_result_req.h" #include "ipc_notify_device_state_req.h" From b1b478c1287e17ffbe409169e0198793827fee10 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 12:47:58 +0800 Subject: [PATCH 26/34] 12121 Signed-off-by: wangyb0625 --- test/unittest/BUILD.gn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 8fd97f00..0a1c639d 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -158,6 +158,8 @@ ohos_unittest("UTTest_softbus_connector") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_softbus_connector }}} @@ -283,6 +285,7 @@ ohos_unittest("UTTest_profile_connector") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", ] } @@ -300,6 +303,7 @@ ohos_unittest("UTTest_device_profile_adapter") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", ] } @@ -359,6 +363,8 @@ ohos_unittest("UTTest_dm_device_state_manager") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hisysevent_native:libhisysevent" ] } ## UnitTest UTTest_dm_device_state_manager }}} @@ -640,6 +646,7 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", From 9825c61731ce329caca3e1b58a015796ef838217 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 17:17:47 +0800 Subject: [PATCH 27/34] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=8F=90=E4=BA=A4dfx?= =?UTF-8?q?=20Signed-off-by:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/inner_kits/native_cpp/BUILD.gn | 1 + .../native_cpp/src/device_manager_impl.cpp | 39 +++++++++---------- services/devicemanagerservice/BUILD.gn | 6 ++- .../dependency/hichain/hichain_connector.cpp | 12 ++---- .../dependency/softbus/softbus_session.cpp | 3 ++ test/unittest/BUILD.gn | 13 ++++++- utils/BUILD.gn | 4 ++ utils/include/dfx/dm_dfx_constants.h | 11 ++++++ utils/include/dfx/lite/dm_hisysevent.h | 8 +--- utils/include/dfx/lite/dm_hitrace.h | 30 ++++++++++++++ utils/include/dfx/standard/dm_hisysevent.h | 7 +--- utils/include/dfx/standard/dm_hitrace.h | 33 ++++++++++++++++ utils/src/dfx/lite/dm_hisysevent.cpp | 3 +- utils/src/dfx/lite/dm_hitrace.cpp | 29 ++++++++++++++ utils/src/dfx/standard/dm_hisysevent.cpp | 4 +- utils/src/dfx/standard/dm_hitrace.cpp | 29 ++++++++++++++ 16 files changed, 183 insertions(+), 49 deletions(-) create mode 100644 utils/include/dfx/lite/dm_hitrace.h create mode 100644 utils/include/dfx/standard/dm_hitrace.h create mode 100644 utils/src/dfx/lite/dm_hitrace.cpp create mode 100644 utils/src/dfx/standard/dm_hitrace.cpp diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 880e147b..b9b12866 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -150,6 +150,7 @@ if (defined(ohos_lite)) { external_deps = [ "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 5c07b3cc..7da5de98 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -20,6 +20,7 @@ #include "dm_constants.h" #include "dm_dfx_constants.h" #include "dm_hisysevent.h" +#include "dm_hitrace.h" #include "dm_log.h" #include "ipc_authenticate_device_req.h" #include "ipc_get_dmfaparam_rsp.h" @@ -49,6 +50,7 @@ DeviceManagerImpl &DeviceManagerImpl::GetInstance() int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::shared_ptr dmInitCallback) { LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); + DMTraceStart(DM_HITRACE_INIT); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -70,15 +72,14 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, DM_HISYEVENT_FAULT, - DM_INIT_DEVICE_MANAGER_FAILED_MSG); + SysEventWrite(DM_INIT_DEVICE_MANAGER_FAILED, DM_HISYEVENT_FAULT, DM_INIT_DEVICE_MANAGER_FAILED_MSG); return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); + DMTraceEnd(); LOGI("InitDeviceManager success"); - HisyseventUtil::GetInstance().SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, DM_HISYEVENT_BEHAVIOR, - DM_INIT_DEVICE_MANAGER_SUCCESS_MSG); + SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, DM_HISYEVENT_BEHAVIOR, DM_INIT_DEVICE_MANAGER_SUCCESS_MSG); return DM_OK; } @@ -134,6 +135,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &info) { LOGI("DeviceManager::GetLocalDeviceInfo start, pkgName: %s", pkgName.c_str()); + DMTraceStart(DM_HITRACE_GET_LOCAL_DEVICE_INFO); std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); @@ -146,15 +148,14 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, DM_HISYEVENT_BEHAVIOR, - GET_LOCAL_DEVICE_INFO_FAILED_MSG); + SysEventWrite(GET_LOCAL_DEVICE_INFO_FAILED, DM_HISYEVENT_BEHAVIOR, GET_LOCAL_DEVICE_INFO_FAILED_MSG); return ERR_DM_IPC_RESPOND_FAILED; } info = rsp->GetLocalDeviceInfo(); + DMTraceEnd(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); - HisyseventUtil::GetInstance().SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, DM_HISYEVENT_BEHAVIOR, - GET_LOCAL_DEVICE_INFO_SUCCESS_MSG); + SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, DM_HISYEVENT_BEHAVIOR, GET_LOCAL_DEVICE_INFO_SUCCESS_MSG); return DM_OK; } @@ -194,6 +195,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons const std::string &extra, std::shared_ptr callback) { LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); + DMTraceStart(DM_HITRACE_START_DEVICE); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -216,14 +218,13 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Failed with ret %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_FAILED, DM_HISYEVENT_BEHAVIOR, - START_DEVICE_DISCOVERY_FAILED_MSG); + SysEventWrite(START_DEVICE_DISCOVERY_FAILED, DM_HISYEVENT_BEHAVIOR, START_DEVICE_DISCOVERY_FAILED_MSG); return ret; } + DMTraceEnd(); LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); - HisyseventUtil::GetInstance().SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, DM_HISYEVENT_BEHAVIOR, - START_DEVICE_DISCOVERY_SUCCESS_MSG); + SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, DM_HISYEVENT_BEHAVIOR, START_DEVICE_DISCOVERY_SUCCESS_MSG); return DM_OK; } @@ -262,6 +263,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ std::shared_ptr callback) { LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); + DMTraceStart(DM_HITRACE_AUTH_TO_CONSULT); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -278,18 +280,17 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_FAILED, DM_HISYEVENT_BEHAVIOR, - DM_SEND_REQUEST_FAILED_MSG); + SysEventWrite(DM_SEND_REQUEST_FAILED, DM_HISYEVENT_BEHAVIOR, DM_SEND_REQUEST_FAILED_MSG); return ERR_DM_IPC_SEND_REQUEST_FAILED; } - HisyseventUtil::GetInstance().SysEventWrite(DM_SEND_REQUEST_SUCCESS, DM_HISYEVENT_BEHAVIOR, - DM_SEND_REQUEST_SUCCESS_MSG); + SysEventWrite(DM_SEND_REQUEST_SUCCESS, DM_HISYEVENT_BEHAVIOR, DM_SEND_REQUEST_SUCCESS_MSG); ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Failed with ret %d", ret); return ERR_DM_IPC_RESPOND_FAILED; } + DMTraceEnd(); LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; } @@ -315,12 +316,10 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); - HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, DM_HISYEVENT_BEHAVIOR, - UNAUTHENTICATE_DEVICE_FAILED_MSG); + SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, DM_HISYEVENT_BEHAVIOR, UNAUTHENTICATE_DEVICE_FAILED_MSG); return ERR_DM_IPC_RESPOND_FAILED; } - HisyseventUtil::GetInstance().SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, DM_HISYEVENT_BEHAVIOR, - UNAUTHENTICATE_DEVICE_SUCCESS_MSG); + SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, DM_HISYEVENT_BEHAVIOR, UNAUTHENTICATE_DEVICE_SUCCESS_MSG); LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 61f0fcb2..9d2325da 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -128,7 +128,10 @@ if (defined(ohos_lite)) { "//utils/native/lite:utils", ] - external_deps = [ "hisysevent_native:libhisysevent" ] + external_deps = [ + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + ] } } else { executable("devicemanagerservice") { @@ -343,6 +346,7 @@ if (defined(ohos_lite)) { "startup_l2:syspara", "startup_l2:syspara_watchagent", "utils_base:utils", + "hitrace_native:hitrace_meter", ] subsystem_name = "distributedhardware" diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index db39f993..7e5b908d 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -262,16 +262,14 @@ void HiChainConnector::onFinish(int64_t requestId, int operationCode, const char LOGI("HiChainConnector::onFinish reqId:%lld, operation:%d", requestId, operationCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGI("Add Member To Group success"); - HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, - ADD_HICHAIN_GROUP_SUCCESS_MSG); + SysEventWrite(ADD_HICHAIN_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, ADD_HICHAIN_GROUP_SUCCESS_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGI("Create group success"); - HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, - DM_CREATE_GROUP_SUCCESS_MSG); + SysEventWrite(DM_CREATE_GROUP_SUCCESS, DM_HISYEVENT_BEHAVIOR, DM_CREATE_GROUP_SUCCESS_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, DM_OK); hiChainConnectorCallback_->OnGroupCreated(requestId, data); @@ -291,16 +289,14 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); - HisyseventUtil::GetInstance().SysEventWrite(ADD_HICHAIN_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, - ADD_HICHAIN_GROUP_FAILED_MSG); + SysEventWrite(ADD_HICHAIN_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, ADD_HICHAIN_GROUP_FAILED_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); - HisyseventUtil::GetInstance().SysEventWrite(DM_CREATE_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, - DM_CREATE_GROUP_FAILED_MSG); + SysEventWrite(DM_CREATE_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, DM_CREATE_GROUP_FAILED_MSG); if (hiChainConnectorCallback_ != nullptr) { hiChainConnectorCallback_->OnGroupCreated(requestId, "{}"); } diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp index 99605d7d..fa80fa4d 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp @@ -17,6 +17,7 @@ #include "dm_anonymous.h" #include "dm_constants.h" +#include "dm_hitrace.h" #include "dm_log.h" #include "nlohmann/json.hpp" #include "softbus_connector.h" @@ -60,6 +61,7 @@ int32_t SoftbusSession::UnRegisterSessionCallback() int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) { LOGI("SoftbusSession::OpenAuthSession"); + DMTraceStart(DM_HITRACE_AUTH_TO_OPPEN_SESSION); int32_t sessionId = -1; std::string connectAddr; ConnectionAddr *addrInfo = SoftbusConnector::GetConnectAddr(deviceId, connectAddr); @@ -72,6 +74,7 @@ int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) LOGE("open session error, ret:%d", sessionId); return sessionId; } + DMTraceEnd(); LOGI("SoftbusSession::OpenAuthSession success. sessionId is:%d", sessionId); return sessionId; } diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 0a1c639d..5e1cf6e7 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -159,7 +159,10 @@ ohos_unittest("UTTest_softbus_connector") { deps = [ ":device_manager_test" ] - external_deps = [ "hisysevent_native:libhisysevent" ] + external_deps = [ + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + ] } ## UnitTest UTTest_softbus_connector }}} @@ -285,6 +288,7 @@ ohos_unittest("UTTest_profile_connector") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", ] } @@ -303,6 +307,7 @@ ohos_unittest("UTTest_device_profile_adapter") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", ] } @@ -364,7 +369,10 @@ ohos_unittest("UTTest_dm_device_state_manager") { deps = [ ":device_manager_test" ] - external_deps = [ "hisysevent_native:libhisysevent" ] + external_deps = [ + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + ] } ## UnitTest UTTest_dm_device_state_manager }}} @@ -646,6 +654,7 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 17fc9f56..e350d0dc 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -43,6 +43,7 @@ if (defined(ohos_lite)) { sources = [ "${utils_path}/src/dfx/lite/dm_hisysevent.cpp", + "${utils_path}/src/dfx/lite/dm_hitrace.cpp", "${utils_path}/src/dm_anonymous.cpp", "${utils_path}/src/dm_error_message.cpp", "${utils_path}/src/dm_log.cpp", @@ -98,6 +99,7 @@ if (defined(ohos_lite)) { ] sources = [ "src/dfx/lite/dm_hisysevent.cpp", + "src/dfx/lite/dm_hitrace.cpp", "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_log.cpp", @@ -143,6 +145,7 @@ if (defined(ohos_lite)) { ohos_shared_library("devicemanagerutils") { sources = [ "src/dfx/standard/dm_hisysevent.cpp", + "src/dfx/standard/dm_hitrace.cpp", "src/dm_anonymous.cpp", "src/dm_error_message.cpp", "src/dm_hash.cpp", @@ -170,6 +173,7 @@ if (defined(ohos_lite)) { external_deps = [ "access_token:libaccesstoken_sdk", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/utils/include/dfx/dm_dfx_constants.h b/utils/include/dfx/dm_dfx_constants.h index 0f63eb53..1d6c8ec7 100644 --- a/utils/include/dfx/dm_dfx_constants.h +++ b/utils/include/dfx/dm_dfx_constants.h @@ -22,11 +22,14 @@ namespace DistributedHardware { // type enum DM_HISYEVENT_EventType { DM_HISYEVENT_FAULT = 1, // system fault event + DM_HISYEVENT_STATISTIC = 2, // system statistic event DM_HISYEVENT_SECURITY = 3, // system security event DM_HISYEVENT_BEHAVIOR = 4 // system behavior event }; +// DMHisyseventFault = 1; + // state const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS"; const std::string DM_INIT_DEVICE_MANAGER_FAILED = "DM_INIT_DEVICE_MANAGER_FAILED"; @@ -58,6 +61,14 @@ const std::string DM_CREATE_GROUP_SUCCESS_MSG = "dm create group success."; const std::string DM_CREATE_GROUP_FAILED_MSG = "dm create group failed."; const std::string UNAUTHENTICATE_DEVICE_SUCCESS_MSG = "unauthenticate device success."; const std::string UNAUTHENTICATE_DEVICE_FAILED_MSG = "unauthenticate device failed."; + +// dfx hitrace +const std::string DM_HITRACE_START_DEVICE = "DM_HITRACE_START_DEVICE"; +const std::string DM_HITRACE_GET_LOCAL_DEVICE_INFO = "DM_HITRACE_GET_LOCAL_DEVICE_INFO"; +const std::string DM_HITRACE_AUTH_TO_CONSULT = "DM_HITRACE_AUTH_TO_CONSULT"; +const std::string DM_HITRACE_AUTH_TO_OPPEN_SESSION = "DM_HITRACE_AUTH_TO_OPPEN_SESSION"; +const std::string DM_HITRACE_DEVICE_ONLINE = "DM_HITRACE_DEVICE_ONLINE"; +const std::string DM_HITRACE_INIT = "DM_HITRACE_INIT"; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_CONSTANTS_H diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index edd05ce9..b7904a3c 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -16,7 +16,6 @@ #ifndef OHOS_DISTRIBUTED_DM_HISYSEVENT_H #define OHOS_DISTRIBUTED_DM_HISYSEVENT_H -#include "single_instance.h" #include "dm_constants.h" #include "dm_dfx_constants.h" @@ -25,12 +24,7 @@ namespace OHOS { namespace DistributedHardware { -class HisyseventUtil { - DECLARE_SINGLE_INSTANCE(HisyseventUtil); - -public: - void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); -}; +void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/include/dfx/lite/dm_hitrace.h b/utils/include/dfx/lite/dm_hitrace.h new file mode 100644 index 00000000..c8d83589 --- /dev/null +++ b/utils/include/dfx/lite/dm_hitrace.h @@ -0,0 +1,30 @@ +/* + * 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_DM_HITRACE_H +#define OHOS_DM_HITRACE_H + +#include + +#include "dm_constants.h" +#include "dm_dfx_constants.h" + +namespace OHOS { +namespace DistributedHardware { +void DMTraceStart(const std::string &msg); +void DMTraceEnd(); +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h index dcfbb43c..f332d6eb 100644 --- a/utils/include/dfx/standard/dm_hisysevent.h +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -28,12 +28,7 @@ namespace OHOS { namespace DistributedHardware { -class HisyseventUtil { - DECLARE_SINGLE_INSTANCE(HisyseventUtil); - -public: - void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); -}; +void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/include/dfx/standard/dm_hitrace.h b/utils/include/dfx/standard/dm_hitrace.h new file mode 100644 index 00000000..bbe849a0 --- /dev/null +++ b/utils/include/dfx/standard/dm_hitrace.h @@ -0,0 +1,33 @@ +/* + * 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_DM_HITRACE_H +#define OHOS_DM_HITRACE_H + +#include + +#include "hitrace_meter.h" + +#include "dm_constants.h" +#include "dm_dfx_constants.h" + +namespace OHOS { +namespace DistributedHardware { +constexpr uint64_t DM_HITRACE_LABEL = HITRACE_TAG_DEVICE_MANAGER; +void DMTraceStart(const std::string &msg); +void DMTraceEnd(); +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index 2020063e..81ec09bf 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -17,8 +17,7 @@ namespace OHOS { namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); -void HisyseventUtil::SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) +void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) { return; } diff --git a/utils/src/dfx/lite/dm_hitrace.cpp b/utils/src/dfx/lite/dm_hitrace.cpp new file mode 100644 index 00000000..1c1153e9 --- /dev/null +++ b/utils/src/dfx/lite/dm_hitrace.cpp @@ -0,0 +1,29 @@ +/* + * 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 "dm_hitrace.h" + +namespace OHOS { +namespace DistributedHardware { +void DMTraceStart(const std::string &msg) +{ + return; +} + +void DMTraceEnd() +{ + return; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/src/dfx/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp index aaf627c6..4eec2eed 100644 --- a/utils/src/dfx/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -17,9 +17,7 @@ namespace OHOS { namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(HisyseventUtil); - -void HisyseventUtil::SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) +void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) { int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, diff --git a/utils/src/dfx/standard/dm_hitrace.cpp b/utils/src/dfx/standard/dm_hitrace.cpp new file mode 100644 index 00000000..7b22ade6 --- /dev/null +++ b/utils/src/dfx/standard/dm_hitrace.cpp @@ -0,0 +1,29 @@ +/* + * 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 "dm_hitrace.h" + +namespace OHOS { +namespace DistributedHardware { +void DMTraceStart(const std::string &msg) +{ + StartTrace(DM_HITRACE_LABEL, msg); +} + +void DMTraceEnd() +{ + FinishTrace(DM_HITRACE_LABEL); +} +} // namespace DistributedHardware +} // namespace OHOS From 15d8558fc03111cb63eec73f86462669cc9e24a2 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 19:50:54 +0800 Subject: [PATCH 28/34] =?UTF-8?q?=E7=9B=91=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/include/dfx/dm_dfx_constants.h | 15 +++++---------- utils/include/dfx/lite/dm_hisysevent.h | 2 +- utils/include/dfx/standard/dm_hisysevent.h | 2 +- utils/src/dfx/lite/dm_hisysevent.cpp | 2 +- utils/src/dfx/standard/dm_hisysevent.cpp | 4 +++- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/utils/include/dfx/dm_dfx_constants.h b/utils/include/dfx/dm_dfx_constants.h index 1d6c8ec7..6cc6b325 100644 --- a/utils/include/dfx/dm_dfx_constants.h +++ b/utils/include/dfx/dm_dfx_constants.h @@ -19,16 +19,11 @@ namespace OHOS { namespace DistributedHardware { -// type -enum DM_HISYEVENT_EventType { - DM_HISYEVENT_FAULT = 1, // system fault event - - DM_HISYEVENT_STATISTIC = 2, // system statistic event - DM_HISYEVENT_SECURITY = 3, // system security event - DM_HISYEVENT_BEHAVIOR = 4 // system behavior event -}; - -// DMHisyseventFault = 1; +// HisysEvent Type +const int DM_HISYEVENT_FAULT = 1; +const int DM_HISYEVENT_STATISTIC = 2; +const int DM_HISYEVENT_SECURITY = 3; +const int DM_HISYEVENT_BEHAVIOR = 4; // state const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS"; diff --git a/utils/include/dfx/lite/dm_hisysevent.h b/utils/include/dfx/lite/dm_hisysevent.h index b7904a3c..c543bb64 100644 --- a/utils/include/dfx/lite/dm_hisysevent.h +++ b/utils/include/dfx/lite/dm_hisysevent.h @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { -void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); +void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/include/dfx/standard/dm_hisysevent.h b/utils/include/dfx/standard/dm_hisysevent.h index f332d6eb..a7296ad4 100644 --- a/utils/include/dfx/standard/dm_hisysevent.h +++ b/utils/include/dfx/standard/dm_hisysevent.h @@ -28,7 +28,7 @@ namespace OHOS { namespace DistributedHardware { -void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg); +void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H diff --git a/utils/src/dfx/lite/dm_hisysevent.cpp b/utils/src/dfx/lite/dm_hisysevent.cpp index 81ec09bf..e3bc5cee 100644 --- a/utils/src/dfx/lite/dm_hisysevent.cpp +++ b/utils/src/dfx/lite/dm_hisysevent.cpp @@ -17,7 +17,7 @@ namespace OHOS { namespace DistributedHardware { -void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) +void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) { return; } diff --git a/utils/src/dfx/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp index 4eec2eed..a5b567a7 100644 --- a/utils/src/dfx/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -17,8 +17,10 @@ namespace OHOS { namespace DistributedHardware { -void SysEventWrite(const std::string &status, DM_HISYEVENT_EventType eventType, const std::string &msg) +void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) { + // DeviceManageHisysEventType eventType = (DeviceManageHisysEventType)eventType; + // DeviceManageHisysEventType::DM_HISYEVENT_BEHAVIOR = eventType; int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, status.c_str(), From 6fe89908c472b280f7803c44a50dfa6cdf6860a5 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Tue, 21 Jun 2022 20:28:15 +0800 Subject: [PATCH 29/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20Signed-off-by:=20wan?= =?UTF-8?q?gyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/devicemanagerservice/BUILD.gn | 2 +- test/unittest/BUILD.gn | 13 +++++++++---- utils/include/dfx/dm_dfx_constants.h | 2 +- utils/src/dfx/standard/dm_hisysevent.cpp | 2 -- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 9d2325da..35f8253f 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -339,6 +339,7 @@ if (defined(ohos_lite)) { "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", @@ -346,7 +347,6 @@ if (defined(ohos_lite)) { "startup_l2:syspara", "startup_l2:syspara_watchagent", "utils_base:utils", - "hitrace_native:hitrace_meter", ] subsystem_name = "distributedhardware" diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 5e1cf6e7..d90e71c6 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -162,7 +162,7 @@ ohos_unittest("UTTest_softbus_connector") { external_deps = [ "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", - ] + ] } ## UnitTest UTTest_softbus_connector }}} @@ -174,6 +174,11 @@ ohos_unittest("UTTest_softbus_session") { sources = [ "UTTest_softbus_session.cpp" ] deps = [ ":device_manager_test_common" ] + + external_deps = [ + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + ] } ## UnitTest UTTest_softbus_session }}} @@ -288,8 +293,8 @@ ohos_unittest("UTTest_profile_connector") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", ] } @@ -307,8 +312,8 @@ ohos_unittest("UTTest_device_profile_adapter") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", ] } @@ -654,8 +659,8 @@ ohos_static_library("device_manager_test") { "common_event_service:cesfwk_innerkits", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/utils/include/dfx/dm_dfx_constants.h b/utils/include/dfx/dm_dfx_constants.h index 6cc6b325..761fe09b 100644 --- a/utils/include/dfx/dm_dfx_constants.h +++ b/utils/include/dfx/dm_dfx_constants.h @@ -19,7 +19,7 @@ namespace OHOS { namespace DistributedHardware { -// HisysEvent Type +// HisysEvent Type const int DM_HISYEVENT_FAULT = 1; const int DM_HISYEVENT_STATISTIC = 2; const int DM_HISYEVENT_SECURITY = 3; diff --git a/utils/src/dfx/standard/dm_hisysevent.cpp b/utils/src/dfx/standard/dm_hisysevent.cpp index a5b567a7..599cf5ad 100644 --- a/utils/src/dfx/standard/dm_hisysevent.cpp +++ b/utils/src/dfx/standard/dm_hisysevent.cpp @@ -19,8 +19,6 @@ namespace OHOS { namespace DistributedHardware { void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) { - // DeviceManageHisysEventType eventType = (DeviceManageHisysEventType)eventType; - // DeviceManageHisysEventType::DM_HISYEVENT_BEHAVIOR = eventType; int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, status.c_str(), From 4d1518533cd17aaaf2dd02466ccdbdcd4ba7c599 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 22 Jun 2022 12:31:29 +0800 Subject: [PATCH 30/34] 11 Signed-off-by: wangyb0625 --- test/unittest/BUILD.gn | 2 ++ utils/include/dfx/dm_dfx_constants.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index d90e71c6..40efb9d0 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -467,6 +467,8 @@ ohos_unittest("UTTest_dm_discovery_manager") { ] deps = [ ":device_manager_test" ] + + external_deps = [ "hitrace_native:hitrace_meter" ] } ## UnitTest UTTest_dm_discovery_manager }}} diff --git a/utils/include/dfx/dm_dfx_constants.h b/utils/include/dfx/dm_dfx_constants.h index 761fe09b..3d4f1768 100644 --- a/utils/include/dfx/dm_dfx_constants.h +++ b/utils/include/dfx/dm_dfx_constants.h @@ -66,4 +66,4 @@ const std::string DM_HITRACE_DEVICE_ONLINE = "DM_HITRACE_DEVICE_ONLINE"; const std::string DM_HITRACE_INIT = "DM_HITRACE_INIT"; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_DM_CONSTANTS_H +#endif // OHOS_DM_DFX_CONSTANTS_H From b45a6859decd9604f5a40df5fd8938d12c9f332b Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 22 Jun 2022 13:11:46 +0800 Subject: [PATCH 31/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- utils/include/dfx/standard/dm_hitrace.h | 2 +- utils/src/dfx/standard/dm_hitrace.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/include/dfx/standard/dm_hitrace.h b/utils/include/dfx/standard/dm_hitrace.h index bbe849a0..38bcb1b1 100644 --- a/utils/include/dfx/standard/dm_hitrace.h +++ b/utils/include/dfx/standard/dm_hitrace.h @@ -25,7 +25,7 @@ namespace OHOS { namespace DistributedHardware { -constexpr uint64_t DM_HITRACE_LABEL = HITRACE_TAG_DEVICE_MANAGER; +// constexpr uint64_t DM_HITRACE_LABEL = HITRACE_TAG_DEVICE_MANAGER; void DMTraceStart(const std::string &msg); void DMTraceEnd(); } // namespace DistributedHardware diff --git a/utils/src/dfx/standard/dm_hitrace.cpp b/utils/src/dfx/standard/dm_hitrace.cpp index 7b22ade6..94713db3 100644 --- a/utils/src/dfx/standard/dm_hitrace.cpp +++ b/utils/src/dfx/standard/dm_hitrace.cpp @@ -13,17 +13,18 @@ * limitations under the License. */ #include "dm_hitrace.h" +#include "hitrace_meter.h" namespace OHOS { namespace DistributedHardware { void DMTraceStart(const std::string &msg) { - StartTrace(DM_HITRACE_LABEL, msg); + StartTrace(HITRACE_TAG_DEVICE_MANAGER, msg); } void DMTraceEnd() { - FinishTrace(DM_HITRACE_LABEL); + FinishTrace(HITRACE_TAG_DEVICE_MANAGER); } } // namespace DistributedHardware } // namespace OHOS From 9cf7ca0114af0112892706606696fdd13fb3f315 Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 22 Jun 2022 14:09:54 +0800 Subject: [PATCH 32/34] 11 Signed-off-by: wangyb0625 --- utils/include/dfx/standard/dm_hitrace.h | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/include/dfx/standard/dm_hitrace.h b/utils/include/dfx/standard/dm_hitrace.h index 38bcb1b1..53523a9e 100644 --- a/utils/include/dfx/standard/dm_hitrace.h +++ b/utils/include/dfx/standard/dm_hitrace.h @@ -25,7 +25,6 @@ namespace OHOS { namespace DistributedHardware { -// constexpr uint64_t DM_HITRACE_LABEL = HITRACE_TAG_DEVICE_MANAGER; void DMTraceStart(const std::string &msg); void DMTraceEnd(); } // namespace DistributedHardware From de3399dc94c601e5f35a68811231be370ac268ea Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 22 Jun 2022 16:32:05 +0800 Subject: [PATCH 33/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81=20Signed-off-by:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native_cpp/src/device_manager_impl.cpp | 16 ++++++++-------- .../src/dependency/softbus/softbus_session.cpp | 4 ++-- utils/include/dfx/lite/dm_hitrace.h | 4 ++-- utils/include/dfx/standard/dm_hitrace.h | 4 ++-- utils/src/dfx/lite/dm_hitrace.cpp | 4 ++-- utils/src/dfx/standard/dm_hitrace.cpp | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 7da5de98..f2eb0278 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -50,7 +50,7 @@ DeviceManagerImpl &DeviceManagerImpl::GetInstance() int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::shared_ptr dmInitCallback) { LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); - DMTraceStart(DM_HITRACE_INIT); + DmTraceStart(DM_HITRACE_INIT); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -77,7 +77,7 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); - DMTraceEnd(); + DmTraceEnd(); LOGI("InitDeviceManager success"); SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, DM_HISYEVENT_BEHAVIOR, DM_INIT_DEVICE_MANAGER_SUCCESS_MSG); return DM_OK; @@ -135,7 +135,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &info) { LOGI("DeviceManager::GetLocalDeviceInfo start, pkgName: %s", pkgName.c_str()); - DMTraceStart(DM_HITRACE_GET_LOCAL_DEVICE_INFO); + DmTraceStart(DM_HITRACE_GET_LOCAL_DEVICE_INFO); std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); @@ -153,7 +153,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi } info = rsp->GetLocalDeviceInfo(); - DMTraceEnd(); + DmTraceEnd(); LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str()); SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, DM_HISYEVENT_BEHAVIOR, GET_LOCAL_DEVICE_INFO_SUCCESS_MSG); return DM_OK; @@ -195,7 +195,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons const std::string &extra, std::shared_ptr callback) { LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); - DMTraceStart(DM_HITRACE_START_DEVICE); + DmTraceStart(DM_HITRACE_START_DEVICE); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -222,7 +222,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons return ret; } - DMTraceEnd(); + DmTraceEnd(); LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str()); SysEventWrite(START_DEVICE_DISCOVERY_SUCCESS, DM_HISYEVENT_BEHAVIOR, START_DEVICE_DISCOVERY_SUCCESS_MSG); return DM_OK; @@ -263,7 +263,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ std::shared_ptr callback) { LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); - DMTraceStart(DM_HITRACE_AUTH_TO_CONSULT); + DmTraceStart(DM_HITRACE_AUTH_TO_CONSULT); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -290,7 +290,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGE("AuthenticateDevice error: Failed with ret %d", ret); return ERR_DM_IPC_RESPOND_FAILED; } - DMTraceEnd(); + DmTraceEnd(); LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; } diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp index fa80fa4d..c13dc691 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp @@ -61,7 +61,7 @@ int32_t SoftbusSession::UnRegisterSessionCallback() int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) { LOGI("SoftbusSession::OpenAuthSession"); - DMTraceStart(DM_HITRACE_AUTH_TO_OPPEN_SESSION); + DmTraceStart(DM_HITRACE_AUTH_TO_OPPEN_SESSION); int32_t sessionId = -1; std::string connectAddr; ConnectionAddr *addrInfo = SoftbusConnector::GetConnectAddr(deviceId, connectAddr); @@ -74,7 +74,7 @@ int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) LOGE("open session error, ret:%d", sessionId); return sessionId; } - DMTraceEnd(); + DmTraceEnd(); LOGI("SoftbusSession::OpenAuthSession success. sessionId is:%d", sessionId); return sessionId; } diff --git a/utils/include/dfx/lite/dm_hitrace.h b/utils/include/dfx/lite/dm_hitrace.h index c8d83589..ae1e2e31 100644 --- a/utils/include/dfx/lite/dm_hitrace.h +++ b/utils/include/dfx/lite/dm_hitrace.h @@ -23,8 +23,8 @@ namespace OHOS { namespace DistributedHardware { -void DMTraceStart(const std::string &msg); -void DMTraceEnd(); +void DmTraceStart(const std::string &msg); +void DmTraceEnd(); } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/utils/include/dfx/standard/dm_hitrace.h b/utils/include/dfx/standard/dm_hitrace.h index 53523a9e..a8374deb 100644 --- a/utils/include/dfx/standard/dm_hitrace.h +++ b/utils/include/dfx/standard/dm_hitrace.h @@ -25,8 +25,8 @@ namespace OHOS { namespace DistributedHardware { -void DMTraceStart(const std::string &msg); -void DMTraceEnd(); +void DmTraceStart(const std::string &msg); +void DmTraceEnd(); } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/utils/src/dfx/lite/dm_hitrace.cpp b/utils/src/dfx/lite/dm_hitrace.cpp index 1c1153e9..6030b857 100644 --- a/utils/src/dfx/lite/dm_hitrace.cpp +++ b/utils/src/dfx/lite/dm_hitrace.cpp @@ -16,12 +16,12 @@ namespace OHOS { namespace DistributedHardware { -void DMTraceStart(const std::string &msg) +void DmTraceStart(const std::string &msg) { return; } -void DMTraceEnd() +void DmTraceEnd() { return; } diff --git a/utils/src/dfx/standard/dm_hitrace.cpp b/utils/src/dfx/standard/dm_hitrace.cpp index 94713db3..1bbe65fa 100644 --- a/utils/src/dfx/standard/dm_hitrace.cpp +++ b/utils/src/dfx/standard/dm_hitrace.cpp @@ -17,12 +17,12 @@ namespace OHOS { namespace DistributedHardware { -void DMTraceStart(const std::string &msg) +void DmTraceStart(const std::string &msg) { StartTrace(HITRACE_TAG_DEVICE_MANAGER, msg); } -void DMTraceEnd() +void DmTraceEnd() { FinishTrace(HITRACE_TAG_DEVICE_MANAGER); } From 273dfc424df46f4f35c7410ef9360a1a529a895a Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Wed, 22 Jun 2022 20:28:09 +0800 Subject: [PATCH 34/34] =?UTF-8?q?=E5=A2=9E=E5=8A=A0bundle.json=20Signed-of?= =?UTF-8?q?f-by:=20wangyb0625=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundle.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bundle.json b/bundle.json index 082cdd9c..6c689d11 100644 --- a/bundle.json +++ b/bundle.json @@ -18,6 +18,9 @@ "adapted_system_type": [ "standard", "small" ], "rom": "2M", "ram": "16M", + "hisysevent_config": [ + "//foundation/distributedhardware/device_manager/hisysevent.yaml" + ], "deps": { "components": [ "appexecfwk_standard",