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