• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dfx_hisysevent_device.h"
17 
18 #undef MMI_LOG_DOMAIN
19 #define MMI_LOG_DOMAIN MMI_LOG_SERVER
20 #undef MMI_LOG_TAG
21 #define MMI_LOG_TAG "DfxHisysevent"
22 
23 #define DFX_HISYSEVENT_DOMAIN OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MODAL_INPUT
24 #define DFX_HISYSEVENT_NAME_DEVICE_FAULT "DEVICE_MANAGER_FAULT"
25 #define DFX_HISYSEVENT_NAME_DEVICE_BEHAVIOR "DEVICE_MANAGER_BEHAVIOR"
26 #define DFX_HISYSEVENT_NAME_DEVICE_STATISTIC "DEVICE_MANAGER_STATISTIC"
27 
28 #define DFX_HISYSEVENT_TYPE_FAULT OHOS::HiviewDFX::HiSysEvent::EventType::FAULT
29 #define DFX_HISYSEVENT_TYPE_BEHAVIOR OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR
30 
31 namespace OHOS {
32 namespace MMI {
33 
ReportDeviceFault(int32_t faultType,std::string faultMsg)34 void DfxHisyseventDevice::ReportDeviceFault(int32_t faultType, std::string faultMsg)
35 {
36     int32_t ret = HiSysEventWrite(DFX_HISYSEVENT_DOMAIN,
37         DFX_HISYSEVENT_NAME_DEVICE_FAULT,
38         DFX_HISYSEVENT_TYPE_FAULT,
39         "FAULT_TYPE",
40         faultType,
41         "FAULT_MSG",
42         faultMsg);
43     if (ret != 0) {
44         MMI_HILOGE("HiviewDFX Write failed, ret:%{public}d, faultType:%{public}d, faultMsg:%{public}s",
45             ret,
46             faultType,
47             faultMsg.c_str());
48     }
49 }
50 
ReportDeviceFault(int32_t deviceId,int32_t faultType,std::string faultMsg)51 void DfxHisyseventDevice::ReportDeviceFault(int32_t deviceId, int32_t faultType, std::string faultMsg)
52 {
53     std::shared_ptr<InputDevice> dev = INPUT_DEV_MGR->GetInputDevice(deviceId);
54     CHKPV(dev);
55     int32_t ret = HiSysEventWrite(DFX_HISYSEVENT_DOMAIN,
56         DFX_HISYSEVENT_NAME_DEVICE_FAULT,
57         DFX_HISYSEVENT_TYPE_FAULT,
58         "FAULT_TYPE",
59         faultType,
60         "DEVICE_ID",
61         deviceId,
62         "DEVICE_PHYS",
63         dev->GetPhys(),
64         "DEVICE_NAME",
65         dev->GetName(),
66         "DEVICE_TYPE",
67         dev->GetType(),
68         "FAULT_MSG",
69         faultMsg);
70     if (ret != 0) {
71         MMI_HILOGE(
72             "HiviewDFX Write failed, ret:%{public}d, deivceId:%{public}d, faultType:%{public}d, faultMsg:%{public}s",
73             ret,
74             deviceId,
75             faultType,
76             faultMsg.c_str());
77     }
78 }
79 
ReportDeviceBehavior(int32_t deviceId,std::string msg)80 void DfxHisyseventDevice::ReportDeviceBehavior(int32_t deviceId, std::string msg)
81 {
82     std::shared_ptr<InputDevice> dev = INPUT_DEV_MGR->GetInputDevice(deviceId);
83     CHKPV(dev);
84     std::string message;
85     std::string name;
86     int32_t ret = HiSysEventWrite(DFX_HISYSEVENT_DOMAIN,
87         DFX_HISYSEVENT_NAME_DEVICE_BEHAVIOR,
88         DFX_HISYSEVENT_TYPE_BEHAVIOR,
89         "DEVICE_ID",
90         deviceId,
91         "DEVICE_PHYS",
92         dev->GetPhys(),
93         "DEVICE_NAME",
94         dev->GetName(),
95         "DEVICE_TYPE",
96         dev->GetType(),
97         "MSG",
98         msg);
99     if (ret != 0) {
100         MMI_HILOGE(
101             "HiviewDFX Write failed, ret:%{public}d, deivceId:%{public}d, msg:%{public}s", ret, deviceId, msg.c_str());
102     }
103 }
104 
ReportSimulateToRsLatecyBehavior(int32_t pointerId,int64_t processDT)105 void DfxHisyseventDevice::ReportSimulateToRsLatecyBehavior(int32_t pointerId, int64_t processDT)
106 {
107     int32_t ret = HiSysEventWrite(DFX_HISYSEVENT_DOMAIN,
108         DFX_HISYSEVENT_NAME_DEVICE_BEHAVIOR,
109         DFX_HISYSEVENT_TYPE_BEHAVIOR,
110         "BIZ_SCENE", BizScene::EVENT_DRAW,
111         "BIZ_STAGE", BizStage::SIMULATE_EVENT_DRAW,
112         "STAGE_RES", StageRes::SIMULATE_EVENT_DRAW_SUCCESS,
113         "BIZ_STATE", BizState::SIMULATE_EVENT_DRAW_START,
114         "POINTER_EVENT_ID", pointerId,
115         "PROCESS_TIME", processDT);
116     if (ret != 0) {
117         MMI_HILOGE(
118             "HiviewDFX Write failed, ret:%{public}d, pointerId:%{public}d, processDT:%{public}" PRId64,
119                 ret, pointerId, processDT);
120     }
121 }
122 
123 } // namespace MMI
124 } // namespace OHOS
125