!617 【需求】dm添加hisysevent、hitrace打点

Merge pull request !617 from 王移波/master
This commit is contained in:
openharmony_ci
2022-06-23 01:16:11 +00:00
committed by Gitee
19 changed files with 531 additions and 3 deletions
+3
View File
@@ -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",
+124
View File
@@ -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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: devevicemanager pid}
UID: {type: INT32, desc: devevicemanager uid}
MSG: {type: STRING, desc: unauthenticate device failed}
+9 -1
View File
@@ -25,6 +25,8 @@ 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",
"${common_path}/include/ipc/model",
@@ -45,7 +47,7 @@ if (defined(ohos_lite)) {
]
defines = [
"LITE_DEVICE",
"__LITEOS_M__",
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"devicemanagerkit\"",
"LOG_DOMAIN=0xD004100",
@@ -70,6 +72,8 @@ 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",
]
include_dirs += [
@@ -117,6 +121,8 @@ if (defined(ohos_lite)) {
"${common_path}/include",
"${common_path}/include/ipc",
"${common_path}/include/ipc/model",
"${utils_path}/include/dfx",
"${utils_path}/include/dfx/standard",
]
}
@@ -143,6 +149,8 @@ if (defined(ohos_lite)) {
deps = [ "${utils_path}:devicemanagerutils" ]
external_deps = [
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"samgr_standard:samgr_proxy",
@@ -18,6 +18,9 @@
#include "device_manager_notify.h"
#include "dm_anonymous.h"
#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"
@@ -47,6 +50,7 @@ DeviceManagerImpl &DeviceManagerImpl::GetInstance()
int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::shared_ptr<DmInitCallback> 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;
@@ -68,11 +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);
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");
SysEventWrite(DM_INIT_DEVICE_MANAGER_SUCCESS, DM_HISYEVENT_BEHAVIOR, DM_INIT_DEVICE_MANAGER_SUCCESS_MSG);
return DM_OK;
}
@@ -128,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<IpcReq> req = std::make_shared<IpcReq>();
std::shared_ptr<IpcGetLocalDeviceInfoRsp> rsp = std::make_shared<IpcGetLocalDeviceInfoRsp>();
req->SetPkgName(pkgName);
@@ -140,11 +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);
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());
SysEventWrite(GET_LOCAL_DEVICE_INFO_SUCCESS, DM_HISYEVENT_BEHAVIOR, GET_LOCAL_DEVICE_INFO_SUCCESS_MSG);
return DM_OK;
}
@@ -184,6 +195,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons
const std::string &extra, std::shared_ptr<DiscoveryCallback> 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;
@@ -206,10 +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);
SysEventWrite(START_DEVICE_DISCOVERY_FAILED, DM_HISYEVENT_BEHAVIOR, START_DEVICE_DISCOVERY_FAILED_MSG);
return ret;
}
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;
}
@@ -248,6 +263,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_
std::shared_ptr<AuthenticateCallback> 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;
@@ -264,14 +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);
SysEventWrite(DM_SEND_REQUEST_FAILED, DM_HISYEVENT_BEHAVIOR, DM_SEND_REQUEST_FAILED_MSG);
return ERR_DM_IPC_SEND_REQUEST_FAILED;
}
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;
}
@@ -297,8 +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);
SysEventWrite(UNAUTHENTICATE_DEVICE_FAILED, DM_HISYEVENT_BEHAVIOR, UNAUTHENTICATE_DEVICE_FAILED_MSG);
return ERR_DM_IPC_RESPOND_FAILED;
}
SysEventWrite(UNAUTHENTICATE_DEVICE_SUCCESS, DM_HISYEVENT_BEHAVIOR, UNAUTHENTICATE_DEVICE_SUCCESS_MSG);
LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str());
return DM_OK;
+14 -1
View File
@@ -47,6 +47,8 @@ if (defined(ohos_lite)) {
"//base/security/device_auth/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",
"${services_path}/include/dispatch",
@@ -100,7 +102,7 @@ if (defined(ohos_lite)) {
]
defines = [
"LITE_DEVICE",
"__LITEOS_M__",
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"devicemanagerservice\"",
"LOG_DOMAIN=0xD004100",
@@ -125,6 +127,11 @@ if (defined(ohos_lite)) {
"//third_party/mbedtls",
"//utils/native/lite:utils",
]
external_deps = [
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
]
}
} else {
executable("devicemanagerservice") {
@@ -150,6 +157,8 @@ 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",
"${innerkits_path}/native_cpp/include",
@@ -253,6 +262,8 @@ 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/device_auth/interfaces/innerkits",
"//third_party/json/include",
@@ -327,6 +338,8 @@ if (defined(ohos_lite)) {
"common_event_service:cesfwk_innerkits",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"safwk:system_ability_fwk",
@@ -23,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"
@@ -261,12 +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");
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");
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);
@@ -286,12 +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");
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");
SysEventWrite(DM_CREATE_GROUP_FAILED, DM_HISYEVENT_BEHAVIOR, DM_CREATE_GROUP_FAILED_MSG);
if (hiChainConnectorCallback_ != nullptr) {
hiChainConnectorCallback_->OnGroupCreated(requestId, "{}");
}
@@ -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;
}
@@ -17,7 +17,6 @@
#include <functional>
#include "device_manager_service_listener.h"
#include "dm_constants.h"
#include "dm_device_info_manager.h"
+23
View File
@@ -158,6 +158,11 @@ ohos_unittest("UTTest_softbus_connector") {
]
deps = [ ":device_manager_test" ]
external_deps = [
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
]
}
## UnitTest UTTest_softbus_connector }}}
@@ -169,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 }}}
@@ -283,6 +293,8 @@ ohos_unittest("UTTest_profile_connector") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"eventhandler:libeventhandler",
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
]
}
@@ -300,6 +312,8 @@ ohos_unittest("UTTest_device_profile_adapter") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"eventhandler:libeventhandler",
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
]
}
@@ -359,6 +373,11 @@ ohos_unittest("UTTest_dm_device_state_manager") {
]
deps = [ ":device_manager_test" ]
external_deps = [
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
]
}
## UnitTest UTTest_dm_device_state_manager }}}
@@ -448,6 +467,8 @@ ohos_unittest("UTTest_dm_discovery_manager") {
]
deps = [ ":device_manager_test" ]
external_deps = [ "hitrace_native:hitrace_meter" ]
}
## UnitTest UTTest_dm_discovery_manager }}}
@@ -640,6 +661,8 @@ ohos_static_library("device_manager_test") {
"common_event_service:cesfwk_innerkits",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"safwk:system_ability_fwk",
+16
View File
@@ -24,6 +24,8 @@ 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",
]
@@ -40,6 +42,8 @@ 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",
@@ -48,6 +52,7 @@ if (defined(ohos_lite)) {
]
defines = [
"__LITEOS_M__",
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"devicemanagerutils\"",
"LOG_DOMAIN=0xD004100",
@@ -70,6 +75,8 @@ 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",
"include/permission/lite",
@@ -91,6 +98,8 @@ if (defined(ohos_lite)) {
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
]
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",
@@ -100,6 +109,7 @@ if (defined(ohos_lite)) {
"src/permission/lite/permission_manager.cpp",
]
defines = [
"LITE_DEVICE",
"hI_LOG_ENABLE",
"DH_LOG_TAG=\"devicemanagerutils\"",
"lOG_DOMAIN=0xD004100",
@@ -121,6 +131,8 @@ if (defined(ohos_lite)) {
include_dirs = [
"include",
"include/fwkload/standard",
"include/dfx",
"include/dfx/standard",
"include/ipc/standard",
"${common_path}/include",
"${common_path}/include/ipc",
@@ -132,6 +144,8 @@ 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",
@@ -158,6 +172,8 @@ 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",
+69
View File
@@ -0,0 +1,69 @@
/*
* 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 <string>
namespace OHOS {
namespace DistributedHardware {
// 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";
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.";
// 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_DFX_CONSTANTS_H
+30
View File
@@ -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_DISTRIBUTED_DM_HISYSEVENT_H
#define OHOS_DISTRIBUTED_DM_HISYSEVENT_H
#include "dm_constants.h"
#include "dm_dfx_constants.h"
#include <cstring>
#include <unistd.h>
namespace OHOS {
namespace DistributedHardware {
void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg);
} // namespace DistributedHardware
} // namespace OHOS
#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H
+30
View File
@@ -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 <string>
#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
@@ -0,0 +1,34 @@
/*
* 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 "dm_anonymous.h"
#include "dm_log.h"
#include "dm_constants.h"
#include "dm_dfx_constants.h"
#include "hisysevent.h"
#include "single_instance.h"
#include <cstring>
#include <unistd.h>
namespace OHOS {
namespace DistributedHardware {
void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg);
} // namespace DistributedHardware
} // namespace OHOS
#endif // OHOS_DISTRIBUTED_DM_HISYSEVENT_H
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_DM_HITRACE_H
#define OHOS_DM_HITRACE_H
#include <string>
#include "hitrace_meter.h"
#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
+25
View File
@@ -0,0 +1,25 @@
/*
* 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 {
void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg)
{
return;
}
} // namespace DistributedHardware
} // namespace OHOS
+29
View File
@@ -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
+34
View File
@@ -0,0 +1,34 @@
/*
* 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 {
void SysEventWrite(const std::string &status, int32_t 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);
}
}
} // namespace DistributedHardware
} // namespace OHOS
+30
View File
@@ -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.
*/
#include "dm_hitrace.h"
#include "hitrace_meter.h"
namespace OHOS {
namespace DistributedHardware {
void DmTraceStart(const std::string &msg)
{
StartTrace(HITRACE_TAG_DEVICE_MANAGER, msg);
}
void DmTraceEnd()
{
FinishTrace(HITRACE_TAG_DEVICE_MANAGER);
}
} // namespace DistributedHardware
} // namespace OHOS