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