• 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 /**
17  * @addtogroup HiAppEvent
18  * @{
19  *
20  * @brief Provides application event logging functions.
21  *
22  * Provides the event logging function for applications to log the fault, statistical, security, and user behavior
23  * events reported during running. Based on event information, you will be able to analyze the running status of
24  * applications.
25  *
26  * @since 8
27  * @version 1.0
28  */
29 
30 /**
31  * @file hiappevent.h
32  *
33  * @brief Defines the application event logging functions of the HiAppEvent module.
34  *
35  * Before performing application event logging, you must construct a ParamList object to store the input
36  * event parameters and specify the event domain, event name, and event type.
37  *
38  * <p>Event domain: a string used to identify the domain of event logging.
39  * <p>Event name: a string used to identify the event name of event logging.
40  * <p>Event type: FAULT, STATISTIC, SECURITY, BEHAVIOR.
41  * <p>ParamList: a linked list used to store event parameters, each of which is comprised of the parameter name and
42  * parameter value.
43  *
44  * Sample code:
45  * 00 Including the header file:
46  * <pre>
47  *     #include "hiappevent/hiappevent.h"
48  * </pre>
49  * 01 create a ParamList pointer.
50  * <pre>
51  *     ParamList list = OH_HiAppEvent_CreateParamList();
52  * </pre>
53  * 02 add params to the ParamList.
54  * <pre>
55  *     bool boolean = true;
56  *     OH_HiAppEvent_AddBoolParam(list, "bool_key", boolean);
57  *     int32_t nums[] = {1, 2, 3};
58  *     OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nums, sizeof(nums) / sizeof(nums[0]));
59  * </pre>
60  * 03 performing event logging.
61  * <pre>
62  *     int res = OH_HiAppEvent_Write("test_domain", "test_event", BEHAVIOR, list);
63  * </pre>
64  * 04 destroy the ParamList pointer.
65  * <pre>
66  *     OH_HiAppEvent_DestroyParamList(list);
67  * </pre>
68  *
69  * @kit PerformanceAnalysisKit
70  * @library libhiappevent_ndk.z.so
71  * @syscap SystemCapability.HiviewDFX.HiAppEvent
72  * @since 8
73  * @version 1.0
74  */
75 
76 #ifndef HIVIEWDFX_HIAPPEVENT_H
77 #define HIVIEWDFX_HIAPPEVENT_H
78 
79 #include <stdbool.h>
80 #include <stdint.h>
81 
82 #include "hiappevent_cfg.h"
83 #include "hiappevent_event.h"
84 #include "hiappevent_param.h"
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89 
90 /**
91  * @brief Defines error code
92  *
93  * @since 15
94  */
95 typedef enum {
96     /** @error The operation is successful. */
97     HIAPPEVENT_SUCCESS = 0,
98     /**
99      * @error Invalid param value length
100      * @since 18
101      */
102     HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH = 4,
103     /**
104      * @error Processor is null
105      * @since 18
106      */
107     HIAPPEVENT_PROCESSOR_IS_NULL = -7,
108     /**
109      * @error Processor not found
110      * @since 18
111      */
112     HIAPPEVENT_PROCESSOR_NOT_FOUND = -8,
113     /** @error Invalid param value */
114     HIAPPEVENT_INVALID_PARAM_VALUE = -9,
115     /** @error event config is null */
116     HIAPPEVENT_EVENT_CONFIG_IS_NULL = -10,
117     /**
118      * @error Operate failed
119      * @since 18
120      */
121     HIAPPEVENT_OPERATE_FAILED = -100,
122     /**
123      * @error Invalid uid
124      * @since 18
125      */
126     HIAPPEVENT_INVALID_UID = -200
127 } HiAppEvent_ErrorCode;
128 
129 /**
130  * @brief Event types.
131  *
132  * You are advised to select event types based on their respective usage scenarios.
133  *
134  * @since 8
135  * @version 1.0
136  */
137 enum EventType {
138     /* Fault event type */
139     FAULT = 1,
140 
141     /* Statistic event type */
142     STATISTIC = 2,
143 
144     /* Security event type */
145     SECURITY = 3,
146 
147     /* Behavior event type */
148     BEHAVIOR = 4
149 };
150 
151 /**
152  * @brief The HiAppEvent_AppEventInfo structure is used to represent event information in an application, including
153  * the event's domain, name, type, and parameters.
154  *
155  * @SystemCapability.HiviewDFX.HiAppEvent
156  * @since 12
157  * @version 1.0
158  */
159 typedef struct HiAppEvent_AppEventInfo {
160     /* The domain of the event. */
161     const char* domain;
162     /* The name of the event. */
163     const char* name;
164     /* The type of the event. */
165     enum EventType type;
166     /* The json string of the parameter. */
167     const char* params;
168 } HiAppEvent_AppEventInfo;
169 
170 /**
171  * @brief The HiAppEvent_AppEventGroup structure represents a group of events in an application. It contains the name
172  * of the event group, an array of HiAppEvent_AppEventInfo structures representing individual events grouped by the
173  * name, and the length of the event array.
174  *
175  * @syscap SystemCapability.HiviewDFX.HiAppEvent
176  * @since 12
177  * @version 1.0
178  */
179 typedef struct HiAppEvent_AppEventGroup {
180     /* The name of the event. */
181     const char* name;
182     /* The event array which is group by the name. */
183     const struct HiAppEvent_AppEventInfo* appEventInfos;
184     /* The length of appEventInfos array. */
185     uint32_t infoLen;
186 } HiAppEvent_AppEventGroup;
187 
188 /**
189  * @brief Event param list node.
190  *
191  * @since 8
192  * @version 1.0
193  */
194 typedef struct ParamListNode* ParamList;
195 
196 /**
197  * @brief The HiAppEvent_Watcher structure is designed for event monitoring, allowing it to be invoked when the event
198  * occurs.
199  *
200  * @syscap SystemCapability.HiviewDFX.HiAppEvent
201  * @since 12
202  * @version 1.0
203  */
204 typedef struct HiAppEvent_Watcher HiAppEvent_Watcher;
205 
206 /**
207  * @brief The HiAppEvent_Processor structure is designed for event report.
208  *
209  * @since 18
210  */
211 typedef struct HiAppEvent_Processor HiAppEvent_Processor;
212 
213 /**
214  * @brief The HiAppEvent_Config structure is designed for configuration.
215  *
216  * @since 15
217  */
218 typedef struct HiAppEvent_Config HiAppEvent_Config;
219 
220 /**
221  * @brief The OH_HiAppEvent_OnReceive function acts as the callback function for the HiAppEvent_Watcher. It is called
222  * when an event occurs.
223  *
224  * @SystemCapability.HiviewDFX.HiAppEvent
225  * @param domain The domain of the event.
226  * @param appEventGroups The event group by the domain.
227  * @param groupLen The length of appEventGroups array.
228  * @since 12
229  * @version 1.0
230  */
231 typedef void (*OH_HiAppEvent_OnReceive)(
232     const char* domain, const struct HiAppEvent_AppEventGroup* appEventGroups, uint32_t groupLen);
233 
234 /**
235  * @brief Called when watcher receive the event meet the condition.
236  *
237  * @SystemCapability.HiviewDFX.HiAppEvent
238  * @param row The row of events received by watcher.
239  * @param size The size of events received by watcher.
240  * @since 12
241  * @version 1.0
242  */
243 typedef void (*OH_HiAppEvent_OnTrigger)(int row, int size);
244 
245 /**
246  * @brief Called when watcher take the events.
247  *
248  * @SystemCapability.HiviewDFX.HiAppEvent
249  * @param events The event json string array.
250  * @param eventLen The length of events array.
251  * @since 12
252  * @version 1.0
253  */
254 typedef void (*OH_HiAppEvent_OnTake)(const char* const *events, uint32_t eventLen);
255 
256 /**
257  * @brief Create a pointer to the ParamList.
258  *
259  * @return Pointer to the ParamList.
260  * @since 8
261  * @version 1.0
262  */
263 ParamList OH_HiAppEvent_CreateParamList(void);
264 
265 /**
266  * @brief Destroy a pointer to the ParamList.
267  *
268  * @param list Event param list.
269  * @since 8
270  * @version 1.0
271  */
272 void OH_HiAppEvent_DestroyParamList(ParamList list);
273 
274 /**
275  * @brief Add bool param to the ParamList.
276  *
277  * @param list The ParamList of params to be added.
278  * @param name The name of the param to be added.
279  * @param boolean The bool value of the param to be added.
280  * @return ParamList after the param is added.
281  * @since 8
282  * @version 1.0
283  */
284 ParamList OH_HiAppEvent_AddBoolParam(ParamList list, const char* name, bool boolean);
285 
286 /**
287  * @brief Add bool array param to the ParamList.
288  *
289  * @param list The ParamList of params to be added.
290  * @param name The name of the param to be added.
291  * @param booleans The bool array value of the param to be added.
292  * @param arrSize The array size of the param to be added.
293  * @return ParamList after the param is added.
294  * @since 8
295  * @version 1.0
296  */
297 ParamList OH_HiAppEvent_AddBoolArrayParam(ParamList list, const char* name, const bool* booleans, int arrSize);
298 
299 /**
300  * @brief Add int8_t param to the ParamList.
301  *
302  * @param list The ParamList of params to be added.
303  * @param name The name of the param to be added.
304  * @param num The int8_t value of the param to be added.
305  * @return ParamList after the param is added.
306  * @since 8
307  * @version 1.0
308  */
309 ParamList OH_HiAppEvent_AddInt8Param(ParamList list, const char* name, int8_t num);
310 
311 /**
312  * @brief Add int8_t array param to the ParamList.
313  *
314  * @param list The ParamList of params to be added.
315  * @param name The name of the param to be added.
316  * @param nums The int8_t array value of the param to be added.
317  * @param arrSize The array size of the param to be added.
318  * @return ParamList after the param is added.
319  * @since 8
320  * @version 1.0
321  */
322 ParamList OH_HiAppEvent_AddInt8ArrayParam(ParamList list, const char* name, const int8_t* nums, int arrSize);
323 
324 /**
325  * @brief Add int16_t param to the ParamList.
326  *
327  * @param list The ParamList of params to be added.
328  * @param name The name of the param to be added.
329  * @param num The int16_t value of the param to be added.
330  * @return ParamList after the param is added.
331  * @since 8
332  * @version 1.0
333  */
334 ParamList OH_HiAppEvent_AddInt16Param(ParamList list, const char* name, int16_t num);
335 
336 /**
337  * @brief Add int16_t array param to the ParamList.
338  *
339  * @param list The ParamList of params to be added.
340  * @param name The name of the param to be added.
341  * @param nums The int16_t array value of the param to be added.
342  * @param arrSize The array size of the param to be added.
343  * @return ParamList after the param is added.
344  * @since 8
345  * @version 1.0
346  */
347 ParamList OH_HiAppEvent_AddInt16ArrayParam(ParamList list, const char* name, const int16_t* nums, int arrSize);
348 
349 /**
350  * @brief Add int32_t param to the ParamList.
351  *
352  * @param list The ParamList of params to be added.
353  * @param name The name of the param to be added.
354  * @param num The int32_t value of the param to be added.
355  * @return ParamList after the param is added.
356  * @since 8
357  * @version 1.0
358  */
359 ParamList OH_HiAppEvent_AddInt32Param(ParamList list, const char* name, int32_t num);
360 
361 /**
362  * @brief Add int32_t array param to the ParamList.
363  *
364  * @param list The ParamList of params to be added.
365  * @param name The name of the param to be added.
366  * @param nums The int32_t array value of the param to be added.
367  * @param arrSize The array size of the param to be added.
368  * @return ParamList after the param is added.
369  * @since 8
370  * @version 1.0
371  */
372 ParamList OH_HiAppEvent_AddInt32ArrayParam(ParamList list, const char* name, const int32_t* nums, int arrSize);
373 
374 /**
375  * @brief Add int64_t param to the ParamList.
376  *
377  * @param list The ParamList of params to be added.
378  * @param name The name of the param to be added.
379  * @param num The int64_t value of the param to be added.
380  * @return ParamList after the param is added.
381  * @since 8
382  * @version 1.0
383  */
384 ParamList OH_HiAppEvent_AddInt64Param(ParamList list, const char* name, int64_t num);
385 
386 /**
387  * @brief Add int64_t array param to the ParamList.
388  *
389  * @param list The ParamList of params to be added.
390  * @param name The name of the param to be added.
391  * @param nums The int64_t array value of the param to be added.
392  * @param arrSize The array size of the param to be added.
393  * @return ParamList after the param is added.
394  * @since 8
395  * @version 1.0
396  */
397 ParamList OH_HiAppEvent_AddInt64ArrayParam(ParamList list, const char* name, const int64_t* nums, int arrSize);
398 
399 /**
400  * @brief Add float param to the ParamList.
401  *
402  * @param list The ParamList of params to be added.
403  * @param name The name of the param to be added.
404  * @param num The float value of the param to be added.
405  * @return ParamList after the param is added.
406  * @since 8
407  * @version 1.0
408  */
409 ParamList OH_HiAppEvent_AddFloatParam(ParamList list, const char* name, float num);
410 
411 /**
412  * @brief Add float array param to the ParamList.
413  *
414  * @param list The ParamList of params to be added.
415  * @param name The name of the param to be added.
416  * @param nums The float array value of the param to be added.
417  * @param arrSize The array size of the param to be added.
418  * @return ParamList after the param is added.
419  * @since 8
420  * @version 1.0
421  */
422 ParamList OH_HiAppEvent_AddFloatArrayParam(ParamList list, const char* name, const float* nums, int arrSize);
423 
424 /**
425  * @brief Add double param to the ParamList.
426  *
427  * @param list The ParamList of params to be added.
428  * @param name The name of the param to be added.
429  * @param num The double value of the param to be added.
430  * @return ParamList after the param is added.
431  * @since 8
432  * @version 1.0
433  */
434 ParamList OH_HiAppEvent_AddDoubleParam(ParamList list, const char* name, double num);
435 
436 /**
437  * @brief Add double array param to the ParamList.
438  *
439  * @param list The ParamList of params to be added.
440  * @param name The name of the param to be added.
441  * @param nums The double array value of the param to be added.
442  * @param arrSize The array size of the param to be added.
443  * @return ParamList after the param is added.
444  * @since 8
445  * @version 1.0
446  */
447 ParamList OH_HiAppEvent_AddDoubleArrayParam(ParamList list, const char* name, const double* nums, int arrSize);
448 
449 /**
450  * @brief Add string param to the ParamList.
451  *
452  * @param list The ParamList of params to be added.
453  * @param name The name of the param to be added.
454  * @param str The string value of the param to be added.
455  * @return ParamList after the param is added.
456  * @since 8
457  * @version 1.0
458  */
459 ParamList OH_HiAppEvent_AddStringParam(ParamList list, const char* name, const char* str);
460 
461 /**
462  * @brief Add string array param to the ParamList.
463  *
464  * @param list The ParamList of params to be added.
465  * @param name The name of the param to be added.
466  * @param strs The string array value of the param to be added.
467  * @param arrSize The array size of the param to be added.
468  * @return ParamList after the param is added.
469  * @since 8
470  * @version 1.0
471  */
472 ParamList OH_HiAppEvent_AddStringArrayParam(ParamList list, const char* name, const char * const *strs, int arrSize);
473 
474 /**
475  * @brief Implements logging of application events whose parameters are of the list type.
476  *
477  * Before logging an application event, this API will first verify parameters of this event.
478  * If the verification is successful, the API will write the event to the event file.
479  *
480  * @param domain Indicates the event domain. You can customize the event domain as needed.
481  * @param name Indicates the event name. You can customize the event name as needed.
482  * @param type Indicates the event type, which is defined in {@link EventType}.
483  * @param list Indicates a linked list of event parameters, each of which is comprised of the parameter name and
484  * parameter value.
485  * @return Returns 0 if the event parameter verification is successful, and the event will be written to
486  * the event file; returns a positive integer if invalid parameters are present in the event, and
487  * the event will be written to the event file after the invalid parameters are ignored; returns a
488  * negative integer if the event parameter verification fails, and the event will not be written to the event file.
489  *         {@code 0} Parameters verification is successful.
490  *         {@code -1} Invalid event name.
491  *         {@code -4} Invalid event domain.
492  *         {@code -99} Function disabled.
493  *         {@code 1} Invalid event parameter name.
494  *         {@code 4} Invalid string length of the event parameter.
495  *         {@code 5} Invalid number of event parameters.
496  *         {@code 6} Invalid array length of the event parameter.
497  *         {@code 8} Duplicate parameter.
498  * @since 8
499  * @version 1.0
500  */
501 int OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType type, const ParamList list);
502 
503 /**
504  * @brief Implements the configuration function of application events logging.
505  *
506  * Application event logging configuration interface, which is used to configure event logging switch,
507  * event file directory storage quota size and other functions.
508  *
509  * @param name Configuration item name.
510  * @param value Configuration item value.
511  * @return Returns true if configuration successful; returns false if configuration failed.
512  * @since 8
513  * @version 1.0
514  */
515 bool OH_HiAppEvent_Configure(const char* name, const char* value);
516 
517 /**
518  * @brief Create a HiAppEvent_Watcher handler pointer to set the property.
519  *
520  * @SystemCapability.HiviewDFX.HiAppEvent
521  * @param name The name of the watcher.
522  * @return Returns a pointer to the HiAppEvent_Watcher instance.
523  * @since 12
524  * @version 1.0
525  */
526 HiAppEvent_Watcher* OH_HiAppEvent_CreateWatcher(const char* name);
527 
528 /**
529  * @brief Destroy the specified HiAppEvent_Watcher handle resource.
530  *
531  * @SystemCapability.HiviewDFX.HiAppEvent
532  * @param watcher The pointer to the HiAppEvent_Watcher instance.
533  * @since 12
534  * @version 1.0
535  */
536 void OH_HiAppEvent_DestroyWatcher(HiAppEvent_Watcher* watcher);
537 
538 /**
539  * @brief The interface to set trigger conditions for the watcher. Three trigger conditions can be set through this
540  * interface and any of the condition which is set over than 0 met, the onTrigger callback set through
541  * OH_HiAppEvent_SetWatcherOnTrigger will be invoked.
542  *
543  * @SystemCapability.HiviewDFX.HiAppEvent
544  * @param watcher The pointer to the HiAppEvent_Watcher instance.
545  * @param row The row of write events that trigger the onTrigger callback.
546  * @param size The size of write events that trigger the onTrigger callback.
547  * @param timeOut The interval for trigger the onTrigger callback.
548  * @return Returns 0 if set TriggerCondition is successful, and returns a
549  * negative integer if set fail.
550  *         {@code 0} Success.
551  *         {@code -5} The watcher is nullptr.
552  * @since 12
553  * @version 1.0
554  */
555 int OH_HiAppEvent_SetTriggerCondition(HiAppEvent_Watcher* watcher, int row, int size, int timeOut);
556 
557 /**
558  * @brief The interface to set the AppEventFilter which defines the kind of app events will be received by  the watcher.
559  *
560  * @SystemCapability.HiviewDFX.HiAppEvent
561  * @param watcher The pointer to the HiAppEvent_Watcher instance.
562  * @param domain The name of the event domain to be monitored by the watcher.
563  * @param eventTypes The types of the events to be monitored by the watcher.0x08 means BEHAVIOR,0x04 means
564  * SECURITY, 0x02 means STATISTIC,0x01 means FAULT, 0xff and 0x00 means all.
565  * @param names The names of the events to be monitored by the watcher.
566  * @param namesLen The length of names array.
567  * @return Returns 0 if set AppEventFilter is successful, and returns a
568  * negative integer if set fail.
569  *         {@code 0} Success.
570  *         {@code -1} Invalid event name.
571  *         {@code -4} Invalid event domain.
572  *         {@code -5} The watcher is nullptr.
573  * @since 12
574  * @version 1.0
575  */
576 int OH_HiAppEvent_SetAppEventFilter(HiAppEvent_Watcher* watcher, const char* domain, uint8_t eventTypes,
577     const char* const *names, int namesLen);
578 
579 /**
580  * @brief The interface to set onTrigger callback for watcher. If the OnReceive callback is not be set or has been set
581  * to nullptr, the app events received by the watcher will be saved. When the new saved appEvents met the conditions set
582  * by OH_HiAppEvent_SetTriggerCondition, the onTrigger callback will be invoked.
583  *
584  * @SystemCapability.HiviewDFX.HiAppEvent
585  * @param watcher The pointer to the HiAppEvent_Watcher instance.
586  * @param onTrigger The callback of the watcher.
587  * @return Returns 0 if set OnTrigger is successful, and returns a
588  * negative integer if set fail.
589  *         {@code 0} Success.
590  *         {@code -5} The watcher is nullptr.
591  * @since 12
592  * @version 1.0
593  */
594 int OH_HiAppEvent_SetWatcherOnTrigger(HiAppEvent_Watcher* watcher, OH_HiAppEvent_OnTrigger onTrigger);
595 
596 /**
597  * @brief The interface to set onReceive callback for watcher. When the watcher received an app event, the onReceive
598  * callback set will be invoked.
599  *
600  * @SystemCapability.HiviewDFX.HiAppEvent
601  * @param watcher The pointer to the HiAppEvent_Watcher instance.
602  * @param onReceive The callback of the watcher.
603  * @return Returns 0 if set OnReceive is successful, and returns a
604  * negative integer if set fail.
605  *         {@code 0} Success.
606  *         {@code -5} The watcher is nullptr.
607  * @since 12
608  * @version 1.0
609  */
610 int OH_HiAppEvent_SetWatcherOnReceive(HiAppEvent_Watcher* watcher, OH_HiAppEvent_OnReceive onReceive);
611 
612 /**
613  * @brief The interface to take saved events data for the watcher.
614  *
615  * @SystemCapability.HiviewDFX.HiAppEvent
616  * @param watcher The pointer to the HiAppEvent_Watcher instance.
617  * @param eventNum The num of events to take.
618  * @param onTake The callback of the watcher.
619  * @return Returns 0 if take events is successful, and returns a
620  * negative integer if take fail.
621  *         {@code 0} Success.
622  *         {@code -5} The watcher is nullptr.
623  *         {@code -6} This interface must be called after OH_HiAppEvent_AddWatcher.
624  * @since 12
625  * @version 1.0
626  */
627 int OH_HiAppEvent_TakeWatcherData(HiAppEvent_Watcher* watcher, uint32_t eventNum, OH_HiAppEvent_OnTake onTake);
628 
629 /**
630  * @brief The interface to add the watcher. The watcher will start receiving app events after it is added.
631  *
632  * @SystemCapability.HiviewDFX.HiAppEvent
633  * @param watcher The pointer to the HiAppEvent_Watcher instance which receive the event.
634  * @return Returns 0 if add watcher is successful, and returns a
635  * negative integer if add fail.
636  *         {@code 0} Success.
637  *         {@code -5} The watcher is nullptr.
638  * @since 12
639  * @version 1.0
640  */
641 int OH_HiAppEvent_AddWatcher(HiAppEvent_Watcher* watcher);
642 
643 /**
644  * @brief The interface to remove the watcher. The watcher will stop receiving app events after it is removed.
645  *
646  * @SystemCapability.HiviewDFX.HiAppEvent
647  * @param watcher The pointer to the HiAppEvent_Watcher instance.
648  * @return Returns 0 if remove watcher is successful, and returns a
649  * negative integer if remove fail.
650  *         {@code 0} Success.
651  *         {@code -5} The watcher is nullptr.
652  *         {@code -6} This interface must be called after OH_HiAppEvent_AddWatcher.
653  * @since 12
654  * @version 1.0
655  */
656 int OH_HiAppEvent_RemoveWatcher(HiAppEvent_Watcher* watcher);
657 
658 /**
659  * @brief Clear all local saved event data of the application.
660  *
661  * @SystemCapability.HiviewDFX.HiAppEvent
662  * @since 12
663  * @version 1.0
664  */
665 void OH_HiAppEvent_ClearData();
666 
667 /**
668  * @brief Create a HiAppEvent_Processor handler pointer to set the property.
669  *
670  * @param name The name of the processor.
671  * @return Returns a pointer to the HiAppEvent_Processor instance.
672  * @since 18
673  */
674 HiAppEvent_Processor* OH_HiAppEvent_CreateProcessor(const char* name);
675 
676 /**
677  * @brief The interface to set route for processor.
678  *
679  * @param processor The pointer to the HiAppEvent_Processor instance.
680  * @param appId The appid of the processor.
681  * @param routeInfo The server location information.
682  * @return set result.
683  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
684  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
685  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
686  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
687  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH} Invalid param value length.
688  * @since 18
689  */
690 int OH_HiAppEvent_SetReportRoute(HiAppEvent_Processor* processor, const char* appId, const char* routeInfo);
691 
692 /**
693  * @brief The interface to set policy for processor.
694  *
695  * @param processor The pointer to the HiAppEvent_Processor instance.
696  * @param periodReport The time interval to report.
697  * @param batchReport The threthold to report.
698  * @param onStartReport The strategy to report.
699  * @param onBackgroundReport The strategy to report.
700  * @return set result.
701  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
702  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
703  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
704  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
705  * @since 18
706  */
707 int OH_HiAppEvent_SetReportPolicy(HiAppEvent_Processor* processor, int periodReport, int batchReport,
708     bool onStartReport, bool onBackgroundReport);
709 
710 /**
711  * @brief The interface to set report event for processor.
712  *
713  * @param processor The pointer to the HiAppEvent_Processor instance.
714  * @param domain The event domain to report.
715  * @param name The event name to report.
716  * @param isRealTime The strategy to report.
717  * @return set result.
718  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
719  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
720  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
721  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
722  * @since 18
723  */
724 int OH_HiAppEvent_SetReportEvent(HiAppEvent_Processor* processor, const char* domain, const char* name,
725     bool isRealTime);
726 
727 /**
728  * @brief The interface to set config for processor.
729  *
730  * @param processor The pointer to the HiAppEvent_Processor instance.
731  * @param key The custom key of processor.
732  * @param value The custom value of processor.
733  * @return set result.
734  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
735  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
736  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
737  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
738  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH} Invalid param value length.
739  * @since 18
740  */
741 int OH_HiAppEvent_SetCustomConfig(HiAppEvent_Processor* processor, const char* key, const char* value);
742 
743 /**
744  * @brief The interface to set configId for processor.
745  *
746  * @param processor The pointer to the HiAppEvent_Processor instance.
747  * @param configId The configId of processor.
748  * @return set result.
749  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
750  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
751  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
752  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
753  * @since 18
754  */
755 int OH_HiAppEvent_SetConfigId(HiAppEvent_Processor* processor, int configId);
756 
757 /**
758  * @brief The interface to set user info for processor.
759  *
760  * @param processor The pointer to the HiAppEvent_Processor instance.
761  * @param userIdNames The userIdNames of processor.
762  * @param size The size of userIdNames array.
763  * @return set result.
764  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
765  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
766  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
767  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
768  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH} Invalid param value length.
769  * @since 18
770  */
771 int OH_HiAppEvent_SetReportUserId(HiAppEvent_Processor* processor, const char* const * userIdNames, int size);
772 
773 /**
774  * @brief The interface to set user property for processor.
775  *
776  * @param processor The pointer to the HiAppEvent_Processor instance.
777  * @param userPropertyNames The userPropertyNames of processor.
778  * @param size The size of userPropertyNames array.
779  * @return set result.
780  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
781  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
782  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
783  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
784  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH} Invalid param value length.
785  * @since 18
786  */
787 int OH_HiAppEvent_SetReportUserProperty(HiAppEvent_Processor* processor, const char* const * userPropertyNames,
788     int size);
789 
790 /**
791  * @brief The interface to add processor.
792  *
793  * @param processor The pointer to the HiAppEvent_Processor instance.
794  * @return process id if set is successful.
795  *         {@link HIAPPEVENT_PROCESSOR_IS_NULL} The processor is nullptr.
796  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} Invalid Param value.
797  *         {@link HIAPPEVENT_OPERATE_FAILED} Name not found or register processor error.
798  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
799  * @since 18
800  */
801 int64_t OH_HiAppEvent_AddProcessor(HiAppEvent_Processor* processor);
802 
803 /**
804  * @brief The interface to destroy processor.
805  *
806  * @param processor The pointer to the HiAppEvent_Processor instance.
807  * @since 18
808  */
809 void OH_HiAppEvent_DestroyProcessor(HiAppEvent_Processor* processor);
810 
811 /**
812  * @brief The interface to remove processor.
813  *
814  * @param processorId The id of the processor.
815  * @return set result.
816  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
817  *         {@link HIAPPEVENT_PROCESSOR_NOT_FOUND} Processor not add.
818  *         {@link HIAPPEVENT_OPERATE_FAILED} The operation is failed.
819  *         {@link HIAPPEVENT_INVALID_UID} Invalid uid.
820  * @since 18
821  */
822 int OH_HiAppEvent_RemoveProcessor(int64_t processorId);
823 
824 /**
825  * @brief Create a HiAppEvent_Config handler pointer to set the config.
826  *
827  * @return Returns a pointer to the HiAppEvent_Config instance.
828  * @since 15
829  */
830 HiAppEvent_Config* OH_HiAppEvent_CreateConfig(void);
831 
832 /**
833  * @brief Destroy the specified HiAppEvent_Config handle resource.
834  *
835  * @param config The pointer to the HiAppEvent_Config instance.
836  * @since 15
837  */
838 void OH_HiAppEvent_DestroyConfig(HiAppEvent_Config* config);
839 
840 /**
841  * @brief The interface to set item to the config.
842  *
843  * @param config The pointer to the HiAppEvent_Config instance.
844  * @param itemName The name of config item.
845  * @param itemValue The value of config item.
846  * @return set result.
847  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
848  *         {@link HIAPPEVENT_EVENT_CONFIG_IS_NULL} The event config is null.
849  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} The item is invalid.
850  * @since 15
851  */
852 int OH_HiAppEvent_SetConfigItem(HiAppEvent_Config* config, const char* itemName, const char* itemValue);
853 
854 /**
855  * @brief The interface to set the config.
856  *
857  * @param name The name of the os event.
858  * @param config The pointer to the HiAppEvent_Config instance.
859  * @return set result.
860  *         {@link HIAPPEVENT_SUCCESS} The operation is successful.
861  *         {@link HIAPPEVENT_INVALID_PARAM_VALUE} The config is invalid.
862  * @since 15
863  */
864 int OH_HiAppEvent_SetEventConfig(const char* name, HiAppEvent_Config* config);
865 #ifdef __cplusplus
866 }
867 #endif
868 /** @} */
869 #endif // HIVIEWDFX_HIAPPEVENT_H