1 /*
2 * Copyright (c) 2022 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 "dscreen_hisysevent.h"
17
18 #include "hisysevent.h"
19
20 #include "dscreen_errcode.h"
21 #include "dscreen_log.h"
22
23 namespace OHOS {
24 namespace DistributedHardware {
ReportSaFail(const std::string & eventName,int32_t errCode,int32_t saId,const std::string & errMsg)25 void ReportSaFail(const std::string &eventName, int32_t errCode, int32_t saId, const std::string &errMsg)
26 {
27 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
28 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
29 eventName,
30 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
31 "ERRCODE", errCode,
32 "SAID", saId,
33 "MSG", errMsg);
34 if (res != DH_SUCCESS) {
35 DHLOGE("Write HiSysEvent error, res:%d", res);
36 }
37 }
38
ReportRegisterFail(const std::string & eventName,int32_t errCode,const std::string & devId,const std::string & dhId,const std::string & errMsg)39 void ReportRegisterFail(const std::string &eventName, int32_t errCode, const std::string &devId,
40 const std::string &dhId, const std::string &errMsg)
41 {
42 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
43 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
44 eventName,
45 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
46 "ERRCODE", errCode,
47 "DEVID", devId,
48 "DHID", dhId,
49 "MSG", errMsg);
50 if (res != DH_SUCCESS) {
51 DHLOGE("Write HiSysEvent error, res:%d", res);
52 }
53 }
54
ReportUnRegisterFail(const std::string & eventName,int32_t errCode,const std::string & devId,const std::string & dhId,const std::string & errMsg)55 void ReportUnRegisterFail(const std::string &eventName, int32_t errCode, const std::string &devId,
56 const std::string &dhId, const std::string &errMsg)
57 {
58 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
59 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
60 eventName,
61 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
62 "ERRCODE", errCode,
63 "DEVID", devId,
64 "DHID", dhId,
65 "MSG", errMsg);
66 if (res != DH_SUCCESS) {
67 DHLOGE("Write HiSysEvent error, res:%d", res);
68 }
69 }
70
ReportOptFail(const std::string & eventName,int32_t errCode,const std::string & errMsg)71 void ReportOptFail(const std::string &eventName, int32_t errCode, const std::string &errMsg)
72 {
73 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
74 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
75 eventName,
76 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
77 "ERRCODE", errCode,
78 "MSG", errMsg);
79 if (res != DH_SUCCESS) {
80 DHLOGE("Write HiSysEvent error, res:%d", res);
81 }
82 }
83
ReportSaEvent(const std::string & eventName,int32_t saId,const std::string & errMsg)84 void ReportSaEvent(const std::string &eventName, int32_t saId, const std::string &errMsg)
85 {
86 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
87 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
88 eventName,
89 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
90 "SAID", saId,
91 "MSG", errMsg);
92 if (res != DH_SUCCESS) {
93 DHLOGE("Write HiSysEvent error, res:%d", res);
94 }
95 }
96
ReportRegisterScreenEvent(const std::string & eventName,const std::string & devId,const std::string & dhId,const std::string & errMsg)97 void ReportRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
98 const std::string &errMsg)
99 {
100 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
101 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
102 eventName,
103 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
104 "DEVID", devId,
105 "DHID", dhId,
106 "MSG", errMsg);
107 if (res != DH_SUCCESS) {
108 DHLOGE("Write HiSysEvent error, res:%d", res);
109 }
110 }
111
ReportUnRegisterScreenEvent(const std::string & eventName,const std::string & devId,const std::string & dhId,const std::string & errMsg)112 void ReportUnRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
113 const std::string &errMsg)
114 {
115 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
116 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
117 eventName,
118 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
119 "DEVID", devId,
120 "DHID", dhId,
121 "MSG", errMsg);
122 if (res != DH_SUCCESS) {
123 DHLOGE("Write HiSysEvent error, res:%d", res);
124 }
125 }
126
ReportScreenMirrorEvent(const std::string & eventName,const std::string & devId,const std::string & dhId,const std::string & errMsg)127 void ReportScreenMirrorEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
128 const std::string &errMsg)
129 {
130 int32_t res = OHOS::HiviewDFX::HiSysEvent::Write(
131 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
132 eventName,
133 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
134 "DEVID", devId,
135 "DHID", dhId,
136 "MSG", errMsg);
137 if (res != DH_SUCCESS) {
138 DHLOGE("Write HiSysEvent error, res:%d", res);
139 }
140 }
141 } // namespace DistributedHardware
142 } // namespace OHOS
143