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