• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 "hiappevent_c.h"
17 
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdlib.h>
21 
22 #include "ndk_app_event_processor_service.h"
23 #include "ndk_app_event_watcher_service.h"
24 
OH_HiAppEvent_CreateParamList(void)25 ParamList OH_HiAppEvent_CreateParamList(void)
26 {
27     return HiAppEventCreateParamList();
28 }
29 
OH_HiAppEvent_DestroyParamList(ParamList list)30 void OH_HiAppEvent_DestroyParamList(ParamList list)
31 {
32     HiAppEventDestroyParamList(list);
33 }
34 
OH_HiAppEvent_AddBoolParam(ParamList list,const char * name,bool boolean)35 ParamList OH_HiAppEvent_AddBoolParam(ParamList list, const char* name, bool boolean)
36 {
37     return AddBoolParamValue(list, name, boolean);
38 }
39 
OH_HiAppEvent_AddBoolArrayParam(ParamList list,const char * name,const bool * booleans,int arrSize)40 ParamList OH_HiAppEvent_AddBoolArrayParam(ParamList list, const char* name, const bool* booleans, int arrSize)
41 {
42     return AddBoolArrayParamValue(list, name, booleans, arrSize);
43 }
44 
OH_HiAppEvent_AddInt8Param(ParamList list,const char * name,int8_t num)45 ParamList OH_HiAppEvent_AddInt8Param(ParamList list, const char* name, int8_t num)
46 {
47     return AddInt8ParamValue(list, name, num);
48 }
49 
OH_HiAppEvent_AddInt8ArrayParam(ParamList list,const char * name,const int8_t * nums,int arrSize)50 ParamList OH_HiAppEvent_AddInt8ArrayParam(ParamList list, const char* name, const int8_t* nums, int arrSize)
51 {
52     return AddInt8ArrayParamValue(list, name, nums, arrSize);
53 }
54 
OH_HiAppEvent_AddInt16Param(ParamList list,const char * name,int16_t num)55 ParamList OH_HiAppEvent_AddInt16Param(ParamList list, const char* name, int16_t num)
56 {
57     return AddInt16ParamValue(list, name, num);
58 }
59 
OH_HiAppEvent_AddInt16ArrayParam(ParamList list,const char * name,const int16_t * nums,int arrSize)60 ParamList OH_HiAppEvent_AddInt16ArrayParam(ParamList list, const char* name, const int16_t* nums, int arrSize)
61 {
62     return AddInt16ArrayParamValue(list, name, nums, arrSize);
63 }
64 
OH_HiAppEvent_AddInt32Param(ParamList list,const char * name,int32_t num)65 ParamList OH_HiAppEvent_AddInt32Param(ParamList list, const char* name, int32_t num)
66 {
67     return AddInt32ParamValue(list, name, num);
68 }
69 
OH_HiAppEvent_AddInt32ArrayParam(ParamList list,const char * name,const int32_t * nums,int arrSize)70 ParamList OH_HiAppEvent_AddInt32ArrayParam(ParamList list, const char* name, const int32_t* nums, int arrSize)
71 {
72     return AddInt32ArrayParamValue(list, name, nums, arrSize);
73 }
74 
OH_HiAppEvent_AddInt64Param(ParamList list,const char * name,int64_t num)75 ParamList OH_HiAppEvent_AddInt64Param(ParamList list, const char* name, int64_t num)
76 {
77     return AddInt64ParamValue(list, name, num);
78 }
79 
OH_HiAppEvent_AddInt64ArrayParam(ParamList list,const char * name,const int64_t * nums,int arrSize)80 ParamList OH_HiAppEvent_AddInt64ArrayParam(ParamList list, const char* name, const int64_t* nums, int arrSize)
81 {
82     return AddInt64ArrayParamValue(list, name, nums, arrSize);
83 }
84 
OH_HiAppEvent_AddFloatParam(ParamList list,const char * name,float num)85 ParamList OH_HiAppEvent_AddFloatParam(ParamList list, const char* name, float num)
86 {
87     return AddFloatParamValue(list, name, num);
88 }
89 
OH_HiAppEvent_AddFloatArrayParam(ParamList list,const char * name,const float * nums,int arrSize)90 ParamList OH_HiAppEvent_AddFloatArrayParam(ParamList list, const char* name, const float* nums, int arrSize)
91 {
92     return AddFloatArrayParamValue(list, name, nums, arrSize);
93 }
94 
OH_HiAppEvent_AddDoubleParam(ParamList list,const char * name,double num)95 ParamList OH_HiAppEvent_AddDoubleParam(ParamList list, const char* name, double num)
96 {
97     return AddDoubleParamValue(list, name, num);
98 }
99 
OH_HiAppEvent_AddDoubleArrayParam(ParamList list,const char * name,const double * nums,int arrSize)100 ParamList OH_HiAppEvent_AddDoubleArrayParam(ParamList list, const char* name, const double* nums, int arrSize)
101 {
102     return AddDoubleArrayParamValue(list, name, nums, arrSize);
103 }
104 
OH_HiAppEvent_AddStringParam(ParamList list,const char * name,const char * str)105 ParamList OH_HiAppEvent_AddStringParam(ParamList list, const char* name, const char* str)
106 {
107     return AddStringParamValue(list, name, str);
108 }
109 
OH_HiAppEvent_AddStringArrayParam(ParamList list,const char * name,const char * const * strs,int arrSize)110 ParamList OH_HiAppEvent_AddStringArrayParam(ParamList list, const char* name, const char* const *strs, int arrSize)
111 {
112     return AddStringArrayParamValue(list, name, strs, arrSize);
113 }
114 
OH_HiAppEvent_Configure(const char * name,const char * value)115 bool OH_HiAppEvent_Configure(const char* name, const char* value)
116 {
117     return HiAppEventInnerConfigure(name, value);
118 }
119 
OH_HiAppEvent_CreateWatcher(const char * name)120 struct HiAppEvent_Watcher* OH_HiAppEvent_CreateWatcher(const char *name)
121 {
122     return CreateWatcher(name);
123 }
124 
OH_HiAppEvent_SetAppEventFilter(struct HiAppEvent_Watcher * watcher,const char * domain,uint8_t eventTypes,const char * const * names,int namesLen)125 int OH_HiAppEvent_SetAppEventFilter(struct HiAppEvent_Watcher *watcher, const char *domain, uint8_t eventTypes,
126                                     const char *const *names, int namesLen)
127 {
128     return SetAppEventFilter(watcher, domain, eventTypes, names, namesLen);
129 }
130 
OH_HiAppEvent_SetTriggerCondition(struct HiAppEvent_Watcher * watcher,int row,int size,int timeOut)131 int OH_HiAppEvent_SetTriggerCondition(struct HiAppEvent_Watcher* watcher, int row, int size, int timeOut)
132 {
133     return SetTriggerCondition(watcher, row, size, timeOut);
134 }
135 
OH_HiAppEvent_SetWatcherOnTrigger(struct HiAppEvent_Watcher * watcher,OH_HiAppEvent_OnTrigger onTrigger)136 int OH_HiAppEvent_SetWatcherOnTrigger(struct HiAppEvent_Watcher *watcher, OH_HiAppEvent_OnTrigger onTrigger)
137 {
138     return SetWatcherOnTrigger(watcher, onTrigger);
139 }
140 
OH_HiAppEvent_SetWatcherOnReceive(struct HiAppEvent_Watcher * watcher,OH_HiAppEvent_OnReceive onReceiver)141 int OH_HiAppEvent_SetWatcherOnReceive(struct HiAppEvent_Watcher *watcher, OH_HiAppEvent_OnReceive onReceiver)
142 {
143     return SetWatcherOnReceiver(watcher, onReceiver);
144 }
145 
OH_HiAppEvent_AddWatcher(struct HiAppEvent_Watcher * watcher)146 int OH_HiAppEvent_AddWatcher(struct HiAppEvent_Watcher* watcher)
147 {
148     return AddWatcher(watcher);
149 }
150 
OH_HiAppEvent_TakeWatcherData(struct HiAppEvent_Watcher * watcher,uint32_t size,OH_HiAppEvent_OnTake onTake)151 int OH_HiAppEvent_TakeWatcherData(struct HiAppEvent_Watcher *watcher, uint32_t size, OH_HiAppEvent_OnTake onTake)
152 {
153     return TakeWatcherData(watcher, size, onTake);
154 }
155 
OH_HiAppEvent_ClearData()156 void OH_HiAppEvent_ClearData()
157 {
158     ClearData();
159 }
160 
OH_HiAppEvent_RemoveWatcher(struct HiAppEvent_Watcher * watcher)161 int OH_HiAppEvent_RemoveWatcher(struct HiAppEvent_Watcher *watcher)
162 {
163     return RemoveWatcher(watcher);
164 }
165 
OH_HiAppEvent_DestroyWatcher(struct HiAppEvent_Watcher * watcher)166 void OH_HiAppEvent_DestroyWatcher(struct HiAppEvent_Watcher *watcher)
167 {
168     DestroyWatcher(watcher);
169 }
170 
OH_HiAppEvent_Write(const char * domain,const char * name,enum EventType type,const ParamList list)171 int OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType type, const ParamList list)
172 {
173     return HiAppEventInnerWrite(domain, name, type, list);
174 }
175 
OH_HiAppEvent_CreateProcessor(const char * name)176 struct HiAppEvent_Processor* OH_HiAppEvent_CreateProcessor(const char* name)
177 {
178     return CreateProcessor(name);
179 }
180 
OH_HiAppEvent_SetReportRoute(struct HiAppEvent_Processor * processor,const char * appId,const char * routeInfo)181 int OH_HiAppEvent_SetReportRoute(struct HiAppEvent_Processor* processor, const char* appId, const char* routeInfo)
182 {
183     return SetReportRoute(processor, appId, routeInfo);
184 }
185 
OH_HiAppEvent_SetReportPolicy(struct HiAppEvent_Processor * processor,int periodReport,int batchReport,bool onStartReport,bool onBackgroundReport)186 int OH_HiAppEvent_SetReportPolicy(struct HiAppEvent_Processor* processor, int periodReport, int batchReport,
187     bool onStartReport, bool onBackgroundReport)
188 {
189     return SetReportPolicy(processor, periodReport, batchReport, onStartReport, onBackgroundReport);
190 }
191 
OH_HiAppEvent_SetReportEvent(struct HiAppEvent_Processor * processor,const char * domain,const char * name,bool isRealTime)192 int OH_HiAppEvent_SetReportEvent(struct HiAppEvent_Processor* processor, const char* domain, const char* name,
193     bool isRealTime)
194 {
195     return SetReportEvent(processor, domain, name, isRealTime);
196 }
197 
OH_HiAppEvent_SetCustomConfig(struct HiAppEvent_Processor * processor,const char * key,const char * value)198 int OH_HiAppEvent_SetCustomConfig(struct HiAppEvent_Processor* processor, const char* key, const char* value)
199 {
200     return SetCustomConfig(processor, key, value);
201 }
202 
OH_HiAppEvent_SetConfigId(struct HiAppEvent_Processor * processor,int configId)203 int OH_HiAppEvent_SetConfigId(struct HiAppEvent_Processor* processor, int configId)
204 {
205     return SetConfigId(processor, configId);
206 }
207 
OH_HiAppEvent_SetConfigName(struct HiAppEvent_Processor * processor,const char * configName)208 int OH_HiAppEvent_SetConfigName(struct HiAppEvent_Processor* processor, const char* configName)
209 {
210     return SetConfigName(processor, configName);
211 }
212 
OH_HiAppEvent_SetReportUserId(struct HiAppEvent_Processor * processor,const char * const * userIdNames,int size)213 int OH_HiAppEvent_SetReportUserId(struct HiAppEvent_Processor* processor, const char* const * userIdNames, int size)
214 {
215     return SetReportUserId(processor, userIdNames, size);
216 }
217 
OH_HiAppEvent_SetReportUserProperty(struct HiAppEvent_Processor * processor,const char * const * userPropertyNames,int size)218 int OH_HiAppEvent_SetReportUserProperty(struct HiAppEvent_Processor* processor, const char* const * userPropertyNames,
219     int size)
220 {
221     return SetReportUserProperty(processor, userPropertyNames, size);
222 }
223 
OH_HiAppEvent_AddProcessor(struct HiAppEvent_Processor * processor)224 int64_t OH_HiAppEvent_AddProcessor(struct HiAppEvent_Processor* processor)
225 {
226     return AddProcessor(processor);
227 }
228 
OH_HiAppEvent_DestoryProcessor(struct HiAppEvent_Processor * processor)229 void OH_HiAppEvent_DestoryProcessor(struct HiAppEvent_Processor* processor)
230 {
231     DestroyProcessor(processor);
232 }
233 
OH_HiAppEvent_DestroyProcessor(struct HiAppEvent_Processor * processor)234 void OH_HiAppEvent_DestroyProcessor(struct HiAppEvent_Processor* processor)
235 {
236     DestroyProcessor(processor);
237 }
238 
OH_HiAppEvent_RemoveProcessor(int64_t processorId)239 int OH_HiAppEvent_RemoveProcessor(int64_t processorId)
240 {
241     return RemoveProcessor(processorId);
242 }
243 
OH_HiAppEvent_CreateConfig(void)244 HiAppEvent_Config* OH_HiAppEvent_CreateConfig(void)
245 {
246     return HiAppEventCreateConfig();
247 }
248 
OH_HiAppEvent_SetConfigItem(HiAppEvent_Config * config,const char * itemName,const char * itemValue)249 int OH_HiAppEvent_SetConfigItem(HiAppEvent_Config* config, const char* itemName, const char* itemValue)
250 {
251     return HiAppEventSetConfigItem(config, itemName, itemValue);
252 }
253 
OH_HiAppEvent_SetEventConfig(const char * name,HiAppEvent_Config * config)254 int OH_HiAppEvent_SetEventConfig(const char* name, HiAppEvent_Config* config)
255 {
256     return HiAppEventSetEventConfig(name, config);
257 }
258 
OH_HiAppEvent_DestroyConfig(HiAppEvent_Config * config)259 void OH_HiAppEvent_DestroyConfig(HiAppEvent_Config* config)
260 {
261     HiAppEventDestroyConfig(config);
262 }