1 /*
2 * Copyright (c) 2024 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 #define LOG_TAG "UdmfRadarReporter"
16
17 #include "udmf_radar_reporter.h"
18
19 namespace OHOS {
20 namespace UDMF {
21 using namespace RadarReporter;
ReportNormal(std::string func,int32_t scene,int32_t stage,int32_t stageRes,int32_t state)22 void RadarReporterAdapter::ReportNormal(
23 std::string func, int32_t scene, int32_t stage, int32_t stageRes, int32_t state)
24 {
25 struct HiSysEventParam params[] = {
26 { .name = { "ORG_PKG" },
27 .t = HISYSEVENT_STRING,
28 .v = { .s = const_cast<char *>(ORG_PKG) },
29 .arraySize = 0 },
30 { .name = { "FUNC" },
31 .t = HISYSEVENT_STRING,
32 .v = { .s = const_cast<char *>(func.c_str()) },
33 .arraySize = 0 },
34 { .name = { "BIZ_SCENE" },
35 .t = HISYSEVENT_INT32,
36 .v = { .i32 = scene },
37 .arraySize = 0 },
38 { .name = { "BIZ_STAGE" },
39 .t = HISYSEVENT_INT32,
40 .v = { .i32 = stage },
41 .arraySize = 0 },
42 { .name = { "STAGE_RES" },
43 .t = HISYSEVENT_INT32,
44 .v = { .i32 = stageRes },
45 .arraySize = 0 },
46 { .name = { "BIZ_STATE" },
47 .t = HISYSEVENT_INT32,
48 .v = { .i32 = state },
49 .arraySize = 0 }
50 };
51 OH_HiSysEvent_Write(
52 DOMAIN,
53 EVENT_NAME,
54 HISYSEVENT_BEHAVIOR,
55 params,
56 sizeof(params) / sizeof(params[0])
57 );
58 }
59
ReportNormal(std::string func,int32_t scene,int32_t stage,int32_t stageRes)60 void RadarReporterAdapter::ReportNormal(std::string func, int32_t scene, int32_t stage, int32_t stageRes)
61 {
62 struct HiSysEventParam params[] = {
63 { .name = { "ORG_PKG" },
64 .t = HISYSEVENT_STRING,
65 .v = { .s = const_cast<char *>(ORG_PKG) },
66 .arraySize = 0 },
67 { .name = { "FUNC" },
68 .t = HISYSEVENT_STRING,
69 .v = { .s = const_cast<char *>(func.c_str()) },
70 .arraySize = 0 },
71 { .name = { "BIZ_SCENE" },
72 .t = HISYSEVENT_INT32,
73 .v = { .i32 = scene },
74 .arraySize = 0 },
75 { .name = { "BIZ_STAGE" },
76 .t = HISYSEVENT_INT32,
77 .v = { .i32 = stage },
78 .arraySize = 0 },
79 { .name = { "STAGE_RES" },
80 .t = HISYSEVENT_INT32,
81 .v = { .i32 = stageRes },
82 .arraySize = 0 }
83 };
84 OH_HiSysEvent_Write(
85 DOMAIN,
86 EVENT_NAME,
87 HISYSEVENT_BEHAVIOR,
88 params,
89 sizeof(params) / sizeof(params[0])
90 );
91 }
92
ReportNormal(std::string func,int32_t scene,int32_t stage,int32_t stageRes,std::string & bundleName)93 void RadarReporterAdapter::ReportNormal(std::string func, int32_t scene, int32_t stage,
94 int32_t stageRes, std::string &bundleName)
95 {
96 struct HiSysEventParam params[] = {
97 { .name = { "ORG_PKG" },
98 .t = HISYSEVENT_STRING,
99 .v = { .s = const_cast<char *>(ORG_PKG) },
100 .arraySize = 0 },
101 { .name = { "FUNC" },
102 .t = HISYSEVENT_STRING,
103 .v = { .s = const_cast<char *>(func.c_str()) },
104 .arraySize = 0 },
105 { .name = { "BIZ_SCENE" },
106 .t = HISYSEVENT_INT32,
107 .v = { .i32 = scene },
108 .arraySize = 0 },
109 { .name = { "BIZ_STAGE" },
110 .t = HISYSEVENT_INT32,
111 .v = { .i32 = stage },
112 .arraySize = 0 },
113 { .name = { "STAGE_RES" },
114 .t = HISYSEVENT_INT32,
115 .v = { .i32 = stageRes },
116 .arraySize = 0 },
117 { .name = { "APP_CALLER" },
118 .t = HISYSEVENT_STRING,
119 .v = { .s = const_cast<char *>(bundleName.c_str()) },
120 .arraySize = 0 }
121 };
122 OH_HiSysEvent_Write(
123 DOMAIN,
124 EVENT_NAME,
125 HISYSEVENT_BEHAVIOR,
126 params,
127 sizeof(params) / sizeof(params[0])
128 );
129 }
130
ReportFail(std::string func,int32_t scene,int32_t stage,int32_t stageRes,int32_t errorCode,int32_t state)131 void RadarReporterAdapter::ReportFail(
132 std::string func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode, int32_t state)
133 {
134 struct HiSysEventParam params[] = {
135 { .name = { "ORG_PKG" },
136 .t = HISYSEVENT_STRING,
137 .v = { .s = const_cast<char *>(ORG_PKG) },
138 .arraySize = 0 },
139 { .name = { "FUNC" },
140 .t = HISYSEVENT_STRING,
141 .v = { .s = const_cast<char *>(func.c_str()) },
142 .arraySize = 0 },
143 { .name = { "BIZ_SCENE" },
144 .t = HISYSEVENT_INT32,
145 .v = { .i32 = scene },
146 .arraySize = 0 },
147 { .name = { "BIZ_STAGE" },
148 .t = HISYSEVENT_INT32,
149 .v = { .i32 = stage },
150 .arraySize = 0 },
151 { .name = { "STAGE_RES" },
152 .t = HISYSEVENT_INT32,
153 .v = { .i32 = stageRes },
154 .arraySize = 0 },
155 { .name = { "ERROR_CODE" },
156 .t = HISYSEVENT_INT32,
157 .v = { .i32 = errorCode },
158 .arraySize = 0 },
159 { .name = { "BIZ_STATE" },
160 .t = HISYSEVENT_INT32,
161 .v = { .i32 = state },
162 .arraySize = 0 }
163 };
164 OH_HiSysEvent_Write(
165 DOMAIN,
166 EVENT_NAME,
167 HISYSEVENT_BEHAVIOR,
168 params,
169 sizeof(params) / sizeof(params[0])
170 );
171 }
172
ReportFail(std::string func,int32_t scene,int32_t stage,int32_t stageRes,int32_t errorCode)173 void RadarReporterAdapter::ReportFail(
174 std::string func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode)
175 {
176 struct HiSysEventParam params[] = {
177 { .name = { "ORG_PKG" },
178 .t = HISYSEVENT_STRING,
179 .v = { .s = const_cast<char *>(ORG_PKG) },
180 .arraySize = 0 },
181 { .name = { "FUNC" },
182 .t = HISYSEVENT_STRING,
183 .v = { .s = const_cast<char *>(func.c_str()) },
184 .arraySize = 0 },
185 { .name = { "BIZ_SCENE" },
186 .t = HISYSEVENT_INT32,
187 .v = { .i32 = scene },
188 .arraySize = 0 },
189 { .name = { "BIZ_STAGE" },
190 .t = HISYSEVENT_INT32,
191 .v = { .i32 = stage },
192 .arraySize = 0 },
193 { .name = { "STAGE_RES" },
194 .t = HISYSEVENT_INT32,
195 .v = { .i32 = stageRes },
196 .arraySize = 0 },
197 { .name = { "ERROR_CODE" },
198 .t = HISYSEVENT_INT32,
199 .v = { .i32 = errorCode },
200 .arraySize = 0 }
201 };
202 OH_HiSysEvent_Write(
203 DOMAIN,
204 EVENT_NAME,
205 HISYSEVENT_BEHAVIOR,
206 params,
207 sizeof(params) / sizeof(params[0])
208 );
209 }
210 }
211 }
212