• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
ReportFail(std::string func,int32_t scene,int32_t stage,int32_t stageRes,int32_t errorCode,int32_t state)93 void RadarReporterAdapter::ReportFail(
94     std::string func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode, int32_t state)
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 = { "ERROR_CODE" },
118             .t = HISYSEVENT_INT32,
119             .v = { .i32 = errorCode },
120             .arraySize = 0 },
121         { .name = { "BIZ_STATE" },
122             .t = HISYSEVENT_INT32,
123             .v = { .i32 = state },
124             .arraySize = 0 }
125     };
126     OH_HiSysEvent_Write(
127         DOMAIN,
128         EVENT_NAME,
129         HISYSEVENT_BEHAVIOR,
130         params,
131         sizeof(params) / sizeof(params[0])
132     );
133 }
134 
ReportFail(std::string func,int32_t scene,int32_t stage,int32_t stageRes,int32_t errorCode)135 void RadarReporterAdapter::ReportFail(
136     std::string func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode)
137 {
138     struct HiSysEventParam params[] = {
139         { .name = { "ORG_PKG" },
140             .t = HISYSEVENT_STRING,
141             .v = { .s = const_cast<char *>(ORG_PKG) },
142             .arraySize = 0 },
143         { .name = { "FUNC" },
144             .t = HISYSEVENT_STRING,
145             .v = { .s = const_cast<char *>(func.c_str()) },
146             .arraySize = 0 },
147         { .name = { "BIZ_SCENE" },
148             .t = HISYSEVENT_INT32,
149             .v = { .i32 = scene },
150             .arraySize = 0 },
151         { .name = { "BIZ_STAGE" },
152             .t = HISYSEVENT_INT32,
153             .v = { .i32 = stage },
154             .arraySize = 0 },
155         { .name = { "STAGE_RES" },
156             .t = HISYSEVENT_INT32,
157             .v = { .i32 = stageRes },
158             .arraySize = 0 },
159         { .name = { "ERROR_CODE" },
160             .t = HISYSEVENT_INT32,
161             .v = { .i32 = errorCode },
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 }
173 }
174