1e41f4b71Sopenharmony_ci# HiAppEvent 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciProvides APIs for implementing the application event logging function. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ciThis function allows your application to record fault events, statistics events, security events, and user behavior events reported during system running. Based on the event information, you can analyze the operating status of your application. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**System capability**: SystemCapability.HiviewDFX.HiAppEvent 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**Since**: 8 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Summary 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci### File 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci| Name| Description| 21e41f4b71Sopenharmony_ci| -------- | -------- | 22e41f4b71Sopenharmony_ci| [hiappevent.h](hiappevent_8h.md) | Defines the application event logging functions of the HiAppEvent module.<br>**File to include**: <hiappevent/hiappevent.h><br>**Library**: libhiappevent_ndk.z.so| 23e41f4b71Sopenharmony_ci| [hiappevent_cfg.h](hiappevent__cfg_8h.md) | Defines the configuration items of the event logging configuration function.<br>**File to include**: <hiappevent/hiappevent_event.h><br>**Library**: libhiappevent_ndk.z.so| 24e41f4b71Sopenharmony_ci| [hiappevent_event.h](hiappevent__event_8h.md) | Defines the names of all predefined events.<br>**File to include**: <hiappevent/hiappevent_param.h><br>**Library**: libhiappevent_ndk.z.so| 25e41f4b71Sopenharmony_ci| [hiappevent_param.h](hiappevent__param_8h.md) | Defines the names of all predefined event parameters.<br>**File to include**: <hiappevent/hiappevent_cfg.h><br>**Library**: libhiappevent_ndk.z.so| 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci### Structs 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci| Name| Description| 31e41f4b71Sopenharmony_ci| -------- | -------- | 32e41f4b71Sopenharmony_ci| struct [HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) | Defines information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format. | 33e41f4b71Sopenharmony_ci| struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) | Event array with the same event name. | 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci### Macros 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci| Name| Description| 39e41f4b71Sopenharmony_ci| -------- | -------- | 40e41f4b71Sopenharmony_ci| [DISABLE](#disable) "disable" | Whether to disable event logging. The default value is **false**. The value **true** means to disable the event logging function, and the value **false** means the opposite. | 41e41f4b71Sopenharmony_ci| [MAX_STORAGE](#max_storage) "max_storage" | Storage quota of the event file directory. The default value is **10M**. | 42e41f4b71Sopenharmony_ci| [EVENT_USER_LOGIN](#event_user_login) "hiappevent.user_login" | User login event. | 43e41f4b71Sopenharmony_ci| [EVENT_USER_LOGOUT](#event_user_logout) "hiappevent.user_logout" | User logout event. | 44e41f4b71Sopenharmony_ci| [EVENT_DISTRIBUTED_SERVICE_START](#event_distributed_service_start) "hiappevent.distributed_service_start" | Distributed service event. | 45e41f4b71Sopenharmony_ci| [EVENT_APP_CRASH](#event_app_crash) "APP_CRASH" | Application crash event. | 46e41f4b71Sopenharmony_ci| [EVENT_APP_FREEZE](#event_app_freeze) "APP_FREEZE" | Application freeze event. | 47e41f4b71Sopenharmony_ci| [EVENT_APP_LAUNCH](#event_app_launch) "APP_LAUNCH" | Application loading event. | 48e41f4b71Sopenharmony_ci| [EVENT_SCROLL_JANK](#event_scroll_jank) "SCROLL_JANK" | Event indicating application freeze during swiping. | 49e41f4b71Sopenharmony_ci| [EVENT_CPU_USAGE_HIGH](#event_cpu_usage_high) "CPU_USAGE_HIGH" | Event indicating high CPU usage of an application. | 50e41f4b71Sopenharmony_ci| [EVENT_BATTERY_USAGE](#event_battery_usage) "BATTERY_USAGE" | Application power usage event. | 51e41f4b71Sopenharmony_ci| [EVENT_RESOURCE_OVERLIMIT](#event_resource_overlimit) "RESOURCE_OVERLIMIT" | Application resource threshold-crossing event. | 52e41f4b71Sopenharmony_ci| [DOMAIN_OS](#domain_os) "OS" | OS scope. | 53e41f4b71Sopenharmony_ci| [PARAM_USER_ID](#param_user_id) "user_id" | User ID. | 54e41f4b71Sopenharmony_ci| [PARAM_DISTRIBUTED_SERVICE_NAME](#param_distributed_service_name) "ds_name" | Distributed service name. | 55e41f4b71Sopenharmony_ci| [PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID](#param_distributed_service_instance_id) "ds_instance_id" | Distributed service instance ID. | 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci### Types 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci| Name| Description| 61e41f4b71Sopenharmony_ci| -------- | -------- | 62e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) [HiAppEvent_AppEventInfo](#hiappevent_appeventinfo) | Information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format. | 63e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) [HiAppEvent_AppEventGroup](#hiappevent_appeventgroup) | Event array with the same event name. | 64e41f4b71Sopenharmony_ci| typedef struct ParamListNode \* [ParamList](#paramlist) | Event parameter list node. | 65e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_Watcher](#hiappevent_watcher) [HiAppEvent_Watcher](#hiappevent_watcher) | Watcher for application events. | 66e41f4b71Sopenharmony_ci| typedef void(\* [OH_HiAppEvent_OnReceive](#oh_hiappevent_onreceive)) (const char \*domain, const struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) \*appEventGroups, uint32_t groupLen) | Callback invoked to pass event content to the caller. | 67e41f4b71Sopenharmony_ci| typedef void(\* [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger)) (int row, int size) | Callback invoked if the event received by the watcher meets the conditions specified by **OH_HiAppEvent_SetTriggerCondition**. Specifically, if the **OH_HiAppEvent_OnReceive** callback is not set in the watcher, the event received by the watcher will be saved. If the saved event meets the conditions specified by OH_HiAppEvent_SetTriggerCondition, the callback is invoked. After the callback is complete, if a newly saved event meets the specified condition, the callback is invoked again. | 68e41f4b71Sopenharmony_ci| typedef void(\* [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake)) (const char \*const \*events, uint32_t eventLen) | Callback invoked to pass the events received by the watcher to the caller when OH_HiAppEvent_TakeWatcherData is used to obtain the events. | 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci### Enums 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci| Name| Description| 74e41f4b71Sopenharmony_ci| -------- | -------- | 75e41f4b71Sopenharmony_ci| [EventType](#eventtype) { **FAULT** = 1, **STATISTIC** = 2, **SECURITY** = 3, **BEHAVIOR** = 4 } | Event type. | 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci### Functions 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci| Name| Description| 81e41f4b71Sopenharmony_ci| -------- | -------- | 82e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_CreateParamList](#oh_hiappevent_createparamlist) (void) | Creates a pointer to a parameter list object. | 83e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_DestroyParamList](#oh_hiappevent_destroyparamlist) ([ParamList](#paramlist) list) | Destroys a pointer to a parameter list object and releases its allocated memory. | 84e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolParam](#oh_hiappevent_addboolparam) ([ParamList](#paramlist) list, const char \*name, bool boolean) | Adds an event parameter of the Boolean type to the parameter list. | 85e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolArrayParam](#oh_hiappevent_addboolarrayparam) ([ParamList](#paramlist) list, const char \*name, const bool \*booleans, int arrSize) | Adds an event parameter of the Boolean array type to the parameter list. | 86e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8Param](#oh_hiappevent_addint8param) ([ParamList](#paramlist) list, const char \*name, int8_t num) | Adds an event parameter of the int8_t type to the parameter list. | 87e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8ArrayParam](#oh_hiappevent_addint8arrayparam) ([ParamList](#paramlist) list, const char \*name, const int8_t \*nums, int arrSize) | Adds an event parameter of the int8_t array type to the parameter list. | 88e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16Param](#oh_hiappevent_addint16param) ([ParamList](#paramlist) list, const char \*name, int16_t num) | Adds an event parameter of the int16_t type to the parameter list. | 89e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16ArrayParam](#oh_hiappevent_addint16arrayparam) ([ParamList](#paramlist) list, const char \*name, const int16_t \*nums, int arrSize) | Adds an event parameter of the int16_t array type to the parameter list. | 90e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32Param](#oh_hiappevent_addint32param) ([ParamList](#paramlist) list, const char \*name, int32_t num) | Adds an event parameter of the int32_t type to the parameter list. | 91e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32ArrayParam](#oh_hiappevent_addint32arrayparam) ([ParamList](#paramlist) list, const char \*name, const int32_t \*nums, int arrSize) | Adds an event parameter of the int32_t array type to the parameter list. | 92e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64Param](#oh_hiappevent_addint64param) ([ParamList](#paramlist) list, const char \*name, int64_t num) | Adds an event parameter of the int64_t type to the parameter list. | 93e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64ArrayParam](#oh_hiappevent_addint64arrayparam) ([ParamList](#paramlist) list, const char \*name, const int64_t \*nums, int arrSize) | Adds an event parameter of the int64_t array type to the parameter list. | 94e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatParam](#oh_hiappevent_addfloatparam) ([ParamList](#paramlist) list, const char \*name, float num) | Adds an event parameter of the float type to the parameter list. | 95e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatArrayParam](#oh_hiappevent_addfloatarrayparam) ([ParamList](#paramlist) list, const char \*name, const float \*nums, int arrSize) | Adds an event parameter of the float array type to the parameter list. | 96e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleParam](#oh_hiappevent_adddoubleparam) ([ParamList](#paramlist) list, const char \*name, double num) | Adds an event parameter of the Double type to the parameter list. | 97e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleArrayParam](#oh_hiappevent_adddoublearrayparam) ([ParamList](#paramlist) list, const char \*name, const double \*nums, int arrSize) | Adds an event parameter of the double array type to the parameter list. | 98e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddStringParam](#oh_hiappevent_addstringparam) ([ParamList](#paramlist) list, const char \*name, const char \*str) | Adds a parameter of the string type to the parameter list. | 99e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddStringArrayParam](#oh_hiappevent_addstringarrayparam) ([ParamList](#paramlist) list, const char \*name, const char \*const \*strs, int arrSize) | Adds a parameter of the string array type to the parameter list. | 100e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_Write](#oh_hiappevent_write) (const char \*domain, const char \*name, enum [EventType](#eventtype) type, const [ParamList](#paramlist) list) | Logs application events whose parameters are of the list type. | 101e41f4b71Sopenharmony_ci| bool [OH_HiAppEvent_Configure](#oh_hiappevent_configure) (const char \*name, const char \*value) | Configures the application event logging function. | 102e41f4b71Sopenharmony_ci| [HiAppEvent_Watcher](#hiappevent_watcher) \* [OH_HiAppEvent_CreateWatcher](#oh_hiappevent_createwatcher) (const char \*name) | Creates a watcher for application events. | 103e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_DestroyWatcher](#oh_hiappevent_destroywatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Destroys a created watcher. | 104e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetTriggerCondition](#oh_hiappevent_settriggercondition) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, int row, int size, int timeOut) | Sets the conditions for triggering the **OH_HiAppEvent_OnTrigger** callback, including the number and size of newly received events and the timeout interval for triggering **onTrigger**. Ensure that at least one of the trigger conditions is set on the caller side. | 105e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetAppEventFilter](#oh_hiappevent_setappeventfilter) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, const char \*domain, uint8_t eventTypes, const char \*const \*names, int namesLen) | Sets the type of events to listen for. | 106e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetWatcherOnTrigger](#oh_hiappevent_setwatcherontrigger) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger) onTrigger) | Sets the **onTrigger** callback. | 107e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetWatcherOnReceive](#oh_hiappevent_setwatcheronreceive) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnReceive](#oh_hiappevent_onreceive) onReceive) | Sets the **onReceive** callback. When the listener detects the corresponding event, the onReceive callback is called. | 108e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_TakeWatcherData](#oh_hiappevent_takewatcherdata) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, uint32_t eventNum, [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake) onTake) | Obtains the event saved by the watcher. | 109e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_AddWatcher](#oh_hiappevent_addwatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Adds a watcher. Once a watcher is added, it starts to listen for system messages. | 110e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_RemoveWatcher](#oh_hiappevent_removewatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Removes a watcher. Once a watcher is removed, it stops listening for system messages. | 111e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_ClearData](#oh_hiappevent_cleardata) (void) | Clears the events saved by all watchers. | 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci## Macro Description 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci### DISABLE 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci``` 120e41f4b71Sopenharmony_ci#define DISABLE "disable" 121e41f4b71Sopenharmony_ci``` 122e41f4b71Sopenharmony_ci**Description** 123e41f4b71Sopenharmony_ciWhether to disable event logging. The default value is **false**. The value **true** means to disable the event logging function, and the value **false** means the opposite. 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci**Since**: 8 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci### DOMAIN_OS 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci``` 131e41f4b71Sopenharmony_ci#define DOMAIN_OS "OS" 132e41f4b71Sopenharmony_ci``` 133e41f4b71Sopenharmony_ci**Description** 134e41f4b71Sopenharmony_ciOS scope. 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**Since**: 12 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci### EVENT_APP_CRASH 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci``` 142e41f4b71Sopenharmony_ci#define EVENT_APP_CRASH "APP_CRASH" 143e41f4b71Sopenharmony_ci``` 144e41f4b71Sopenharmony_ci**Description** 145e41f4b71Sopenharmony_ciDefines an application crash event. 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Since**: 12 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci### EVENT_APP_FREEZE 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci``` 153e41f4b71Sopenharmony_ci#define EVENT_APP_FREEZE "APP_FREEZE" 154e41f4b71Sopenharmony_ci``` 155e41f4b71Sopenharmony_ci**Description** 156e41f4b71Sopenharmony_ciDefines an application freeze event. 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**Since**: 12 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci### EVENT_APP_LAUNCH 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci``` 164e41f4b71Sopenharmony_ci#define EVENT_APP_LAUNCH "APP_LAUNCH" 165e41f4b71Sopenharmony_ci``` 166e41f4b71Sopenharmony_ci**Description** 167e41f4b71Sopenharmony_ciDefines an application loading event. 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ci**Since**: 12 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci### EVENT_BATTERY_USAGE 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci``` 175e41f4b71Sopenharmony_ci#define EVENT_BATTERY_USAGE "BATTERY_USAGE" 176e41f4b71Sopenharmony_ci``` 177e41f4b71Sopenharmony_ci**Description** 178e41f4b71Sopenharmony_ciDefines an application power usage event. 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci**Since**: 12 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci### EVENT_CPU_USAGE_HIGH 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci``` 186e41f4b71Sopenharmony_ci#define EVENT_CPU_USAGE_HIGH "CPU_USAGE_HIGH" 187e41f4b71Sopenharmony_ci``` 188e41f4b71Sopenharmony_ci**Description** 189e41f4b71Sopenharmony_ciDefines an event indicating high CPU usage of an application. 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci**Since**: 12 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci### EVENT_DISTRIBUTED_SERVICE_START 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci``` 197e41f4b71Sopenharmony_ci#define EVENT_DISTRIBUTED_SERVICE_START "hiappevent.distributed_service_start" 198e41f4b71Sopenharmony_ci``` 199e41f4b71Sopenharmony_ci**Description** 200e41f4b71Sopenharmony_ciDistributed service event. 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Since**: 8 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci### EVENT_RESOURCE_OVERLIMIT 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci``` 208e41f4b71Sopenharmony_ci#define EVENT_RESOURCE_OVERLIMIT "RESOURCE_OVERLIMIT" 209e41f4b71Sopenharmony_ci``` 210e41f4b71Sopenharmony_ci**Description** 211e41f4b71Sopenharmony_ciDefines an application resource threshold-crossing event. 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci**Since**: 12 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci### EVENT_SCROLL_JANK 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci``` 219e41f4b71Sopenharmony_ci#define EVENT_SCROLL_JANK "SCROLL_JANK" 220e41f4b71Sopenharmony_ci``` 221e41f4b71Sopenharmony_ci**Description** 222e41f4b71Sopenharmony_ciDefines an event indicating application freeze during swiping. 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci**Since**: 12 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci### EVENT_USER_LOGIN 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci``` 230e41f4b71Sopenharmony_ci#define EVENT_USER_LOGIN "hiappevent.user_login" 231e41f4b71Sopenharmony_ci``` 232e41f4b71Sopenharmony_ci**Description** 233e41f4b71Sopenharmony_ciUser login event. 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**Since**: 8 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci### EVENT_USER_LOGOUT 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci``` 241e41f4b71Sopenharmony_ci#define EVENT_USER_LOGOUT "hiappevent.user_logout" 242e41f4b71Sopenharmony_ci``` 243e41f4b71Sopenharmony_ci**Description** 244e41f4b71Sopenharmony_ciUser logout event. 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**Since**: 8 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci### MAX_STORAGE 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci``` 252e41f4b71Sopenharmony_ci#define MAX_STORAGE "max_storage" 253e41f4b71Sopenharmony_ci``` 254e41f4b71Sopenharmony_ci**Description** 255e41f4b71Sopenharmony_ciStorage quota of the event file directory. The default value is **10M**. 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci**Since**: 8 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci### PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci``` 263e41f4b71Sopenharmony_ci#define PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID "ds_instance_id" 264e41f4b71Sopenharmony_ci``` 265e41f4b71Sopenharmony_ci**Description** 266e41f4b71Sopenharmony_ciDistributed service instance ID. 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ci**Since**: 8 269e41f4b71Sopenharmony_ci 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci### PARAM_DISTRIBUTED_SERVICE_NAME 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci``` 274e41f4b71Sopenharmony_ci#define PARAM_DISTRIBUTED_SERVICE_NAME "ds_name" 275e41f4b71Sopenharmony_ci``` 276e41f4b71Sopenharmony_ci**Description** 277e41f4b71Sopenharmony_ciDistributed service name. 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci**Since**: 8 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci### PARAM_USER_ID 283e41f4b71Sopenharmony_ci 284e41f4b71Sopenharmony_ci``` 285e41f4b71Sopenharmony_ci#define PARAM_USER_ID "user_id" 286e41f4b71Sopenharmony_ci``` 287e41f4b71Sopenharmony_ci**Description** 288e41f4b71Sopenharmony_ciUser ID. 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci**Since**: 8 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci## Type Description 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci### HiAppEvent_AppEventGroup 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci``` 299e41f4b71Sopenharmony_citypedef struct HiAppEvent_AppEventGroupHiAppEvent_AppEventGroup 300e41f4b71Sopenharmony_ci``` 301e41f4b71Sopenharmony_ci**Description** 302e41f4b71Sopenharmony_ciDefines an event array with the same event name. 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**System capability**: SystemCapability.HiviewDFX.HiAppEvent 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci**Since**: 12 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci### HiAppEvent_AppEventInfo 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci``` 312e41f4b71Sopenharmony_citypedef struct HiAppEvent_AppEventInfoHiAppEvent_AppEventInfo 313e41f4b71Sopenharmony_ci``` 314e41f4b71Sopenharmony_ci**Description** 315e41f4b71Sopenharmony_ciDefines information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format. 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci**Since**: 12 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci### HiAppEvent_Watcher 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci``` 325e41f4b71Sopenharmony_citypedef struct HiAppEvent_WatcherHiAppEvent_Watcher 326e41f4b71Sopenharmony_ci``` 327e41f4b71Sopenharmony_ci**Description** 328e41f4b71Sopenharmony_ciDefines the watcher for application events. 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci**System capability**: SystemCapability.HiviewDFX.HiAppEvent 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**Since**: 12 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci### OH_HiAppEvent_OnReceive 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci``` 338e41f4b71Sopenharmony_citypedef void(* OH_HiAppEvent_OnReceive) (const char *domain, const struct HiAppEvent_AppEventGroup *appEventGroups, uint32_t groupLen) 339e41f4b71Sopenharmony_ci``` 340e41f4b71Sopenharmony_ci**Description** 341e41f4b71Sopenharmony_ciDefines the callback invoked to pass event content to the caller. 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ciNote: The lifecycle of the object pointed by the pointer in the callback is limited to the callback function. Do not use the pointer outside of the callback function. If the information needs to be cached, perform a deep copy of the content pointed by the pointer. 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci**Since**: 12 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci**Parameters** 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci| Name| Description| 352e41f4b71Sopenharmony_ci| -------- | -------- | 353e41f4b71Sopenharmony_ci| domain | Domain of the received application event. | 354e41f4b71Sopenharmony_ci| appEventGroups | Event group array. | 355e41f4b71Sopenharmony_ci| groupLen | Length of the event group array. | 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci### OH_HiAppEvent_OnTake 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci``` 361e41f4b71Sopenharmony_citypedef void(* OH_HiAppEvent_OnTake) (const char *const *events, uint32_t eventLen) 362e41f4b71Sopenharmony_ci``` 363e41f4b71Sopenharmony_ci**Description** 364e41f4b71Sopenharmony_ciDefines the callback invoked to pass the events received by the watcher to the caller when OH_HiAppEvent_TakeWatcherData is used to obtain the events. 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ciNote: The lifecycle of the object pointed by the pointer in the callback is limited to the callback function. Do not use the pointer outside of the callback function. If the information needs to be cached, perform a deep copy of the content pointed by the pointer. 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci**Since**: 12 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci**Parameters** 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci| Name| Description| 375e41f4b71Sopenharmony_ci| -------- | -------- | 376e41f4b71Sopenharmony_ci| events | Event array in JSON string format. | 377e41f4b71Sopenharmony_ci| eventLen | Size of the event array. | 378e41f4b71Sopenharmony_ci 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ci### OH_HiAppEvent_OnTrigger 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci``` 383e41f4b71Sopenharmony_citypedef void(* OH_HiAppEvent_OnTrigger) (int row, int size) 384e41f4b71Sopenharmony_ci``` 385e41f4b71Sopenharmony_ci**Description** 386e41f4b71Sopenharmony_ciDefines the callback invoked if the event received by the watcher meets the conditions specified by **OH_HiAppEvent_SetTriggerCondition**. Specifically, if the **OH_HiAppEvent_OnReceive** callback is not set in the watcher, the event received by the watcher will be saved. If the saved event meets the conditions specified by OH_HiAppEvent_SetTriggerCondition, the callback is invoked. After the callback is complete, if a newly saved event meets the specified condition, the callback is invoked again. 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci**Since**: 12 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci**Parameters** 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci| Name| Description| 395e41f4b71Sopenharmony_ci| -------- | -------- | 396e41f4b71Sopenharmony_ci| row | Number of events newly received by the watcher. | 397e41f4b71Sopenharmony_ci| size | Total size of events newly received by the watcher. The size of a single event is the length of the JSON string converted from the event. | 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci### ParamList 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci``` 403e41f4b71Sopenharmony_citypedef struct ParamListNode* ParamList 404e41f4b71Sopenharmony_ci``` 405e41f4b71Sopenharmony_ci**Description** 406e41f4b71Sopenharmony_ciEvent parameter list node. 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**Since**: 8 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci## Enum Description 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci### EventType 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci``` 417e41f4b71Sopenharmony_cienum EventType 418e41f4b71Sopenharmony_ci``` 419e41f4b71Sopenharmony_ci**Description** 420e41f4b71Sopenharmony_ciEnumerates the event types. 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ciYou are advised to select different event types based on application scenarios. 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci**Since**: 8 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci| Value| Description| 427e41f4b71Sopenharmony_ci| -------- | -------- | 428e41f4b71Sopenharmony_ci| FAULT | Fault event.| 429e41f4b71Sopenharmony_ci| STATISTIC | Statistics event.| 430e41f4b71Sopenharmony_ci| SECURITY | Security event.| 431e41f4b71Sopenharmony_ci| BEHAVIOR | Behavior event.| 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ci## Function Description 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddBoolArrayParam() 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci``` 440e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddBoolArrayParam (ParamList list, const char * name, const bool * booleans, int arrSize ) 441e41f4b71Sopenharmony_ci``` 442e41f4b71Sopenharmony_ci**Description** 443e41f4b71Sopenharmony_ciAdds an event parameter of the Boolean array type to the parameter list. 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci**Since**: 8 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci**Parameters** 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci| Name| Description| 450e41f4b71Sopenharmony_ci| -------- | -------- | 451e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 452e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 453e41f4b71Sopenharmony_ci| booleans | Value of the parameter to be added. | 454e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci**Returns** 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci 461e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddBoolParam() 462e41f4b71Sopenharmony_ci 463e41f4b71Sopenharmony_ci``` 464e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddBoolParam (ParamList list, const char * name, bool boolean ) 465e41f4b71Sopenharmony_ci``` 466e41f4b71Sopenharmony_ci**Description** 467e41f4b71Sopenharmony_ciAdds an event parameter of the Boolean type to the parameter list. 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci**Since**: 8 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci**Parameters** 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci| Name| Description| 474e41f4b71Sopenharmony_ci| -------- | -------- | 475e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 476e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 477e41f4b71Sopenharmony_ci| boolean | Value of the parameter to be added. | 478e41f4b71Sopenharmony_ci 479e41f4b71Sopenharmony_ci**Returns** 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddDoubleArrayParam() 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ci``` 487e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddDoubleArrayParam (ParamList list, const char * name, const double * nums, int arrSize ) 488e41f4b71Sopenharmony_ci``` 489e41f4b71Sopenharmony_ci**Description** 490e41f4b71Sopenharmony_ciAdds an event parameter of the double array type to the parameter list. 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**Since**: 8 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci**Parameters** 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci| Name| Description| 497e41f4b71Sopenharmony_ci| -------- | -------- | 498e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 499e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 500e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 501e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**Returns** 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 506e41f4b71Sopenharmony_ci 507e41f4b71Sopenharmony_ci 508e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddDoubleParam() 509e41f4b71Sopenharmony_ci 510e41f4b71Sopenharmony_ci``` 511e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddDoubleParam (ParamList list, const char * name, double num ) 512e41f4b71Sopenharmony_ci``` 513e41f4b71Sopenharmony_ci**Description** 514e41f4b71Sopenharmony_ciAdds an event parameter of the Double type to the parameter list. 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ci**Since**: 8 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ci**Parameters** 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci| Name| Description| 521e41f4b71Sopenharmony_ci| -------- | -------- | 522e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 523e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 524e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ci**Returns** 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddFloatArrayParam() 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci``` 534e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddFloatArrayParam (ParamList list, const char * name, const float * nums, int arrSize ) 535e41f4b71Sopenharmony_ci``` 536e41f4b71Sopenharmony_ci**Description** 537e41f4b71Sopenharmony_ciAdds an event parameter of the float array type to the parameter list. 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci**Since**: 8 540e41f4b71Sopenharmony_ci 541e41f4b71Sopenharmony_ci**Parameters** 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ci| Name| Description| 544e41f4b71Sopenharmony_ci| -------- | -------- | 545e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 546e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 547e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 548e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci**Returns** 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_ci 555e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddFloatParam() 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci``` 558e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddFloatParam (ParamList list, const char * name, float num ) 559e41f4b71Sopenharmony_ci``` 560e41f4b71Sopenharmony_ci**Description** 561e41f4b71Sopenharmony_ciAdds an event parameter of the float type to the parameter list. 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_ci**Since**: 8 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_ci**Parameters** 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci| Name| Description| 568e41f4b71Sopenharmony_ci| -------- | -------- | 569e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 570e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 571e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci**Returns** 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt16ArrayParam() 579e41f4b71Sopenharmony_ci 580e41f4b71Sopenharmony_ci``` 581e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt16ArrayParam (ParamList list, const char * name, const int16_t * nums, int arrSize ) 582e41f4b71Sopenharmony_ci``` 583e41f4b71Sopenharmony_ci**Description** 584e41f4b71Sopenharmony_ciAdds an event parameter of the int16_t array type to the parameter list. 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci**Since**: 8 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci**Parameters** 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ci| Name| Description| 591e41f4b71Sopenharmony_ci| -------- | -------- | 592e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 593e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 594e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 595e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_ci**Returns** 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt16Param() 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci``` 605e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt16Param (ParamList list, const char * name, int16_t num ) 606e41f4b71Sopenharmony_ci``` 607e41f4b71Sopenharmony_ci**Description** 608e41f4b71Sopenharmony_ciAdds an event parameter of the int16_t type to the parameter list. 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci**Since**: 8 611e41f4b71Sopenharmony_ci 612e41f4b71Sopenharmony_ci**Parameters** 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci| Name| Description| 615e41f4b71Sopenharmony_ci| -------- | -------- | 616e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 617e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 618e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci**Returns** 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 623e41f4b71Sopenharmony_ci 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt32ArrayParam() 626e41f4b71Sopenharmony_ci 627e41f4b71Sopenharmony_ci``` 628e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt32ArrayParam (ParamList list, const char * name, const int32_t * nums, int arrSize ) 629e41f4b71Sopenharmony_ci``` 630e41f4b71Sopenharmony_ci**Description** 631e41f4b71Sopenharmony_ciAdds an event parameter of the int32_t array type to the parameter list. 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci**Since**: 8 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ci**Parameters** 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci| Name| Description| 638e41f4b71Sopenharmony_ci| -------- | -------- | 639e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 640e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 641e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 642e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 643e41f4b71Sopenharmony_ci 644e41f4b71Sopenharmony_ci**Returns** 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ci 649e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt32Param() 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci``` 652e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt32Param (ParamList list, const char * name, int32_t num ) 653e41f4b71Sopenharmony_ci``` 654e41f4b71Sopenharmony_ci**Description** 655e41f4b71Sopenharmony_ciAdds an event parameter of the int32_t type to the parameter list. 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci**Since**: 8 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci**Parameters** 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci| Name| Description| 662e41f4b71Sopenharmony_ci| -------- | -------- | 663e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 664e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 665e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 666e41f4b71Sopenharmony_ci 667e41f4b71Sopenharmony_ci**Returns** 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ci 672e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt64ArrayParam() 673e41f4b71Sopenharmony_ci 674e41f4b71Sopenharmony_ci``` 675e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt64ArrayParam (ParamList list, const char * name, const int64_t * nums, int arrSize ) 676e41f4b71Sopenharmony_ci``` 677e41f4b71Sopenharmony_ci**Description** 678e41f4b71Sopenharmony_ciAdds an event parameter of the int64_t array type to the parameter list. 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ci**Since**: 8 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci**Parameters** 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ci| Name| Description| 685e41f4b71Sopenharmony_ci| -------- | -------- | 686e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 687e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 688e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 689e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 690e41f4b71Sopenharmony_ci 691e41f4b71Sopenharmony_ci**Returns** 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 694e41f4b71Sopenharmony_ci 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt64Param() 697e41f4b71Sopenharmony_ci 698e41f4b71Sopenharmony_ci``` 699e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt64Param (ParamList list, const char * name, int64_t num ) 700e41f4b71Sopenharmony_ci``` 701e41f4b71Sopenharmony_ci**Description** 702e41f4b71Sopenharmony_ciAdds an event parameter of the int64_t type to the parameter list. 703e41f4b71Sopenharmony_ci 704e41f4b71Sopenharmony_ci**Since**: 8 705e41f4b71Sopenharmony_ci 706e41f4b71Sopenharmony_ci**Parameters** 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_ci| Name| Description| 709e41f4b71Sopenharmony_ci| -------- | -------- | 710e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 711e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 712e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_ci**Returns** 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 717e41f4b71Sopenharmony_ci 718e41f4b71Sopenharmony_ci 719e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt8ArrayParam() 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ci``` 722e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt8ArrayParam (ParamList list, const char * name, const int8_t * nums, int arrSize ) 723e41f4b71Sopenharmony_ci``` 724e41f4b71Sopenharmony_ci**Description** 725e41f4b71Sopenharmony_ciAdds an event parameter of the int8_t array type to the parameter list. 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**Since**: 8 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci**Parameters** 730e41f4b71Sopenharmony_ci 731e41f4b71Sopenharmony_ci| Name| Description| 732e41f4b71Sopenharmony_ci| -------- | -------- | 733e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 734e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 735e41f4b71Sopenharmony_ci| nums | Value of the parameter to be added. | 736e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci**Returns** 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 741e41f4b71Sopenharmony_ci 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddInt8Param() 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ci``` 746e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddInt8Param (ParamList list, const char * name, int8_t num ) 747e41f4b71Sopenharmony_ci``` 748e41f4b71Sopenharmony_ci**Description** 749e41f4b71Sopenharmony_ciAdds an event parameter of the int8_t type to the parameter list. 750e41f4b71Sopenharmony_ci 751e41f4b71Sopenharmony_ci**Since**: 8 752e41f4b71Sopenharmony_ci 753e41f4b71Sopenharmony_ci**Parameters** 754e41f4b71Sopenharmony_ci 755e41f4b71Sopenharmony_ci| Name| Description| 756e41f4b71Sopenharmony_ci| -------- | -------- | 757e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 758e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 759e41f4b71Sopenharmony_ci| num | Value of the parameter to be added. | 760e41f4b71Sopenharmony_ci 761e41f4b71Sopenharmony_ci**Returns** 762e41f4b71Sopenharmony_ci 763e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 764e41f4b71Sopenharmony_ci 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddStringArrayParam() 767e41f4b71Sopenharmony_ci 768e41f4b71Sopenharmony_ci``` 769e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddStringArrayParam (ParamList list, const char * name, const char *const * strs, int arrSize ) 770e41f4b71Sopenharmony_ci``` 771e41f4b71Sopenharmony_ci**Description** 772e41f4b71Sopenharmony_ciAdds a parameter of the string array type to the parameter list. 773e41f4b71Sopenharmony_ci 774e41f4b71Sopenharmony_ci**Since**: 8 775e41f4b71Sopenharmony_ci 776e41f4b71Sopenharmony_ci**Parameters** 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_ci| Name| Description| 779e41f4b71Sopenharmony_ci| -------- | -------- | 780e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 781e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 782e41f4b71Sopenharmony_ci| strs | Value of the parameter to be added. | 783e41f4b71Sopenharmony_ci| arrSize | Size of the parameter array to be added. | 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci**Returns** 786e41f4b71Sopenharmony_ci 787e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 788e41f4b71Sopenharmony_ci 789e41f4b71Sopenharmony_ci 790e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddStringParam() 791e41f4b71Sopenharmony_ci 792e41f4b71Sopenharmony_ci``` 793e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_AddStringParam (ParamList list, const char * name, const char * str ) 794e41f4b71Sopenharmony_ci``` 795e41f4b71Sopenharmony_ci**Description** 796e41f4b71Sopenharmony_ciAdds a parameter of the string type to the parameter list. 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci**Since**: 8 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_ci**Parameters** 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ci| Name| Description| 803e41f4b71Sopenharmony_ci| -------- | -------- | 804e41f4b71Sopenharmony_ci| list | Pointer to the parameter list to which parameters need to be added. | 805e41f4b71Sopenharmony_ci| name | Name of the parameter to be added. | 806e41f4b71Sopenharmony_ci| str | Value of the parameter to be added. | 807e41f4b71Sopenharmony_ci 808e41f4b71Sopenharmony_ci**Returns** 809e41f4b71Sopenharmony_ci 810e41f4b71Sopenharmony_ciPointer to the parameter list that contains the parameters added. 811e41f4b71Sopenharmony_ci 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci### OH_HiAppEvent_AddWatcher() 814e41f4b71Sopenharmony_ci 815e41f4b71Sopenharmony_ci``` 816e41f4b71Sopenharmony_ciint OH_HiAppEvent_AddWatcher (HiAppEvent_Watcher * watcher) 817e41f4b71Sopenharmony_ci``` 818e41f4b71Sopenharmony_ci**Description** 819e41f4b71Sopenharmony_ciAdds a watcher. Once a watcher is added, it starts to listen for system messages. 820e41f4b71Sopenharmony_ci 821e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ci**Since**: 12 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_ci**Parameters** 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ci| Name| Description| 828e41f4b71Sopenharmony_ci| -------- | -------- | 829e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 830e41f4b71Sopenharmony_ci 831e41f4b71Sopenharmony_ci**Returns** 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null. 834e41f4b71Sopenharmony_ci 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ci### OH_HiAppEvent_ClearData() 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci``` 839e41f4b71Sopenharmony_civoid OH_HiAppEvent_ClearData (void ) 840e41f4b71Sopenharmony_ci``` 841e41f4b71Sopenharmony_ci**Description** 842e41f4b71Sopenharmony_ciClears the events saved by all watchers. 843e41f4b71Sopenharmony_ci 844e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 845e41f4b71Sopenharmony_ci 846e41f4b71Sopenharmony_ci**Since**: 12 847e41f4b71Sopenharmony_ci 848e41f4b71Sopenharmony_ci 849e41f4b71Sopenharmony_ci### OH_HiAppEvent_Configure() 850e41f4b71Sopenharmony_ci 851e41f4b71Sopenharmony_ci``` 852e41f4b71Sopenharmony_cibool OH_HiAppEvent_Configure (const char * name, const char * value ) 853e41f4b71Sopenharmony_ci``` 854e41f4b71Sopenharmony_ci**Description** 855e41f4b71Sopenharmony_ciConfigures the application event logging function. 856e41f4b71Sopenharmony_ci 857e41f4b71Sopenharmony_ciThis function is used to configure the event logging function and the storage quota of the event file directory. 858e41f4b71Sopenharmony_ci 859e41f4b71Sopenharmony_ci**Since**: 8 860e41f4b71Sopenharmony_ci 861e41f4b71Sopenharmony_ci**Parameters** 862e41f4b71Sopenharmony_ci 863e41f4b71Sopenharmony_ci| Name| Description| 864e41f4b71Sopenharmony_ci| -------- | -------- | 865e41f4b71Sopenharmony_ci| name | Configuration item name. The value can be set to [DISABLE](#disable) or [MAX_STORAGE](#max_storage). | 866e41f4b71Sopenharmony_ci| value | Configuration item value. If the configuration item name is [DISABLE](#disable), the value can be **true** or **false**. If the configuration item name is [MAX_STORAGE](#max_storage), the quota value can contain only digits and a unit, which can be one of [b\|k\|kb\|m\|mb\|g\|gb\|t\|tb] and is case insensitive. The quota value string must start with a digit and can end with or without a unit. If no unit is specified, byte is used by default. | 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci**Returns** 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_ciConfiguration result. The value **true** indicates that the configuration is successful, and the value **false** indicates the opposite. 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci 873e41f4b71Sopenharmony_ci### OH_HiAppEvent_CreateParamList() 874e41f4b71Sopenharmony_ci 875e41f4b71Sopenharmony_ci``` 876e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_CreateParamList (void ) 877e41f4b71Sopenharmony_ci``` 878e41f4b71Sopenharmony_ci**Description** 879e41f4b71Sopenharmony_ciCreates a pointer to a parameter list object. 880e41f4b71Sopenharmony_ci 881e41f4b71Sopenharmony_ci**Since**: 8 882e41f4b71Sopenharmony_ci 883e41f4b71Sopenharmony_ci**Returns** 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ciPointer to the parameter list object. 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_ci 888e41f4b71Sopenharmony_ci### OH_HiAppEvent_CreateWatcher() 889e41f4b71Sopenharmony_ci 890e41f4b71Sopenharmony_ci``` 891e41f4b71Sopenharmony_ciHiAppEvent_Watcher* OH_HiAppEvent_CreateWatcher (const char * name) 892e41f4b71Sopenharmony_ci``` 893e41f4b71Sopenharmony_ci**Description** 894e41f4b71Sopenharmony_ciCreates a watcher for application events. 895e41f4b71Sopenharmony_ci 896e41f4b71Sopenharmony_ciNote: If a created watcher is no longer used, you are required to destroy it by calling OH_HiAppEvent_DestroyWatcher. 897e41f4b71Sopenharmony_ci 898e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 899e41f4b71Sopenharmony_ci 900e41f4b71Sopenharmony_ci**Since**: 12 901e41f4b71Sopenharmony_ci 902e41f4b71Sopenharmony_ci**Parameters** 903e41f4b71Sopenharmony_ci 904e41f4b71Sopenharmony_ci| Name| Description| 905e41f4b71Sopenharmony_ci| -------- | -------- | 906e41f4b71Sopenharmony_ci| name | Watcher name. | 907e41f4b71Sopenharmony_ci 908e41f4b71Sopenharmony_ci**Returns** 909e41f4b71Sopenharmony_ci 910e41f4b71Sopenharmony_ciPointer to the new watcher if the API is called successfully; **nullptr** if the **name** parameter is invalid. 911e41f4b71Sopenharmony_ci 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ci### OH_HiAppEvent_DestroyParamList() 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci``` 916e41f4b71Sopenharmony_civoid OH_HiAppEvent_DestroyParamList (ParamList list) 917e41f4b71Sopenharmony_ci``` 918e41f4b71Sopenharmony_ci**Description** 919e41f4b71Sopenharmony_ciDestroys a pointer to a parameter list object and releases its allocated memory. 920e41f4b71Sopenharmony_ci 921e41f4b71Sopenharmony_ci**Since**: 8 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_ci**Parameters** 924e41f4b71Sopenharmony_ci 925e41f4b71Sopenharmony_ci| Name| Description| 926e41f4b71Sopenharmony_ci| -------- | -------- | 927e41f4b71Sopenharmony_ci| list | Pointer to the parameter list object. | 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci 930e41f4b71Sopenharmony_ci### OH_HiAppEvent_DestroyWatcher() 931e41f4b71Sopenharmony_ci 932e41f4b71Sopenharmony_ci``` 933e41f4b71Sopenharmony_civoid OH_HiAppEvent_DestroyWatcher (HiAppEvent_Watcher * watcher) 934e41f4b71Sopenharmony_ci``` 935e41f4b71Sopenharmony_ci**Description** 936e41f4b71Sopenharmony_ciDestroys a created watcher. 937e41f4b71Sopenharmony_ci 938e41f4b71Sopenharmony_ciNote: If a created watcher is no longer used, destroy it to release memory to prevent memory leakage. After the watcher is destroyed, set its pointer to null. 939e41f4b71Sopenharmony_ci 940e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 941e41f4b71Sopenharmony_ci 942e41f4b71Sopenharmony_ci**Since**: 12 943e41f4b71Sopenharmony_ci 944e41f4b71Sopenharmony_ci**Parameters** 945e41f4b71Sopenharmony_ci 946e41f4b71Sopenharmony_ci| Name| Description| 947e41f4b71Sopenharmony_ci| -------- | -------- | 948e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 949e41f4b71Sopenharmony_ci 950e41f4b71Sopenharmony_ci 951e41f4b71Sopenharmony_ci### OH_HiAppEvent_RemoveWatcher() 952e41f4b71Sopenharmony_ci 953e41f4b71Sopenharmony_ci``` 954e41f4b71Sopenharmony_ciint OH_HiAppEvent_RemoveWatcher (HiAppEvent_Watcher * watcher) 955e41f4b71Sopenharmony_ci``` 956e41f4b71Sopenharmony_ci**Description** 957e41f4b71Sopenharmony_ciRemoves a watcher. Once a watcher is removed, it stops listening for system messages. 958e41f4b71Sopenharmony_ci 959e41f4b71Sopenharmony_ciNote: This API only enables the watcher to stop listening for system messages. It does not destroy the watcher. The watcher still resides in the memory until the OH_HiAppEvent_DestroyWatcher API is called. 960e41f4b71Sopenharmony_ci 961e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 962e41f4b71Sopenharmony_ci 963e41f4b71Sopenharmony_ci**Since**: 12 964e41f4b71Sopenharmony_ci 965e41f4b71Sopenharmony_ci**Parameters** 966e41f4b71Sopenharmony_ci 967e41f4b71Sopenharmony_ci| Name| Description| 968e41f4b71Sopenharmony_ci| -------- | -------- | 969e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 970e41f4b71Sopenharmony_ci 971e41f4b71Sopenharmony_ci**Returns** 972e41f4b71Sopenharmony_ci 973e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null; **-6** if **OH_HiAppEvent_AddWatcher** has not been called to add a watcher. 974e41f4b71Sopenharmony_ci 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci### OH_HiAppEvent_SetAppEventFilter() 977e41f4b71Sopenharmony_ci 978e41f4b71Sopenharmony_ci``` 979e41f4b71Sopenharmony_ciint OH_HiAppEvent_SetAppEventFilter (HiAppEvent_Watcher * watcher, const char * domain, uint8_t eventTypes, const char *const * names, int namesLen ) 980e41f4b71Sopenharmony_ci``` 981e41f4b71Sopenharmony_ci**Description** 982e41f4b71Sopenharmony_ciSets the type of events to listen for. 983e41f4b71Sopenharmony_ci 984e41f4b71Sopenharmony_ciThis function can be called repeatedly. You can add multiple filtering conditions instead of replacing them. The watcher will receive notifications of events that meet any of the filtering conditions. 985e41f4b71Sopenharmony_ci 986e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 987e41f4b71Sopenharmony_ci 988e41f4b71Sopenharmony_ci**Since**: 12 989e41f4b71Sopenharmony_ci 990e41f4b71Sopenharmony_ci**Parameters** 991e41f4b71Sopenharmony_ci 992e41f4b71Sopenharmony_ci| Name| Description| 993e41f4b71Sopenharmony_ci| -------- | -------- | 994e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 995e41f4b71Sopenharmony_ci| domain | Domain of events to be listened for. | 996e41f4b71Sopenharmony_ci| eventTypes | Types of events to be listened for. The bitwise AND matching mode is used. Multiple types of events can be intercepted. If the first bit is 1 (the value is 1), fault events can be intercepted. If the second bit is 1 (the value is 2), statistics events can be intercepted. If the third bit is 1 (the value is 4), security events can be intercepted, if the fourth digit is 1 (the value is 8), events of the listening behavior type are supported. If the fourth digit is 1 (the value is 15) or 0 (the value is 0), events of all types are supported. | 997e41f4b71Sopenharmony_ci| names | Array of the event names. | 998e41f4b71Sopenharmony_ci| namesLen | Length of the event name array. | 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci**Returns** 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-1** if the **names** parameter is invalid; **-4** if the **domain** parameter is invalid; **-5** if the pointer of an input parameter is null. 1003e41f4b71Sopenharmony_ci 1004e41f4b71Sopenharmony_ci 1005e41f4b71Sopenharmony_ci### OH_HiAppEvent_SetTriggerCondition() 1006e41f4b71Sopenharmony_ci 1007e41f4b71Sopenharmony_ci``` 1008e41f4b71Sopenharmony_ciint OH_HiAppEvent_SetTriggerCondition (HiAppEvent_Watcher * watcher, int row, int size, int timeOut ) 1009e41f4b71Sopenharmony_ci``` 1010e41f4b71Sopenharmony_ci**Description** 1011e41f4b71Sopenharmony_ciSets the conditions for triggering the **OH_HiAppEvent_OnTrigger** callback, including the number and size of newly received events and the timeout interval for triggering **onTrigger**. Ensure that at least one of the trigger conditions is set on the caller side. 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1014e41f4b71Sopenharmony_ci 1015e41f4b71Sopenharmony_ci**Since**: 12 1016e41f4b71Sopenharmony_ci 1017e41f4b71Sopenharmony_ci**Parameters** 1018e41f4b71Sopenharmony_ci 1019e41f4b71Sopenharmony_ci| Name| Description| 1020e41f4b71Sopenharmony_ci| -------- | -------- | 1021e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 1022e41f4b71Sopenharmony_ci| row | Row count. If the input value is greater than 0 and the number of newly received events is greater than or equal to the value of this parameter, the configured onTrigger callback is called. If the input value is less than or equal to 0, the number of received events is not used as the condition to trigger the onTrigger callback. | 1023e41f4b71Sopenharmony_ci| size | Size value. If the input value is greater than 0 and the size of the newly received event is greater than or equal to the value of this parameter, the configured onTrigger callback is called. The size of a single event is the length of the JSON string converted from the event. If the input value is less than or equal to 0, the size of received events is not used as the condition to trigger the onTrigger callback. | 1024e41f4b71Sopenharmony_ci| timeOut | Timeout value, in seconds. If the input value is greater than 0, the system checks the watcher for newly received events based on the timeout interval. If there are any newly received events, the configured onTrigger callback is triggered. After the callback is complete, the system checks the watcher for newly received events when the timeout value expires. If the input value is less than or equal to 0, the timeout interval is not used as the condition to trigger the onTrigger callback. | 1025e41f4b71Sopenharmony_ci 1026e41f4b71Sopenharmony_ci**Returns** 1027e41f4b71Sopenharmony_ci 1028e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null. 1029e41f4b71Sopenharmony_ci 1030e41f4b71Sopenharmony_ci 1031e41f4b71Sopenharmony_ci### OH_HiAppEvent_SetWatcherOnReceive() 1032e41f4b71Sopenharmony_ci 1033e41f4b71Sopenharmony_ci``` 1034e41f4b71Sopenharmony_ciint OH_HiAppEvent_SetWatcherOnReceive (HiAppEvent_Watcher * watcher, OH_HiAppEvent_OnReceive onReceive ) 1035e41f4b71Sopenharmony_ci``` 1036e41f4b71Sopenharmony_ci**Description** 1037e41f4b71Sopenharmony_ciSets the **onReceive** callback. When the listener detects the corresponding event, the onReceive callback is called. 1038e41f4b71Sopenharmony_ci 1039e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_ci**Since**: 12 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ci**Parameters** 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci| Name| Description| 1046e41f4b71Sopenharmony_ci| -------- | -------- | 1047e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 1048e41f4b71Sopenharmony_ci| onReceive | Pointer to the callback function. | 1049e41f4b71Sopenharmony_ci 1050e41f4b71Sopenharmony_ci**Returns** 1051e41f4b71Sopenharmony_ci 1052e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null. 1053e41f4b71Sopenharmony_ci 1054e41f4b71Sopenharmony_ci 1055e41f4b71Sopenharmony_ci### OH_HiAppEvent_SetWatcherOnTrigger() 1056e41f4b71Sopenharmony_ci 1057e41f4b71Sopenharmony_ci``` 1058e41f4b71Sopenharmony_ciint OH_HiAppEvent_SetWatcherOnTrigger (HiAppEvent_Watcher * watcher, OH_HiAppEvent_OnTrigger onTrigger ) 1059e41f4b71Sopenharmony_ci``` 1060e41f4b71Sopenharmony_ci**Description** 1061e41f4b71Sopenharmony_ciSets the **onTrigger** callback. 1062e41f4b71Sopenharmony_ci 1063e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1064e41f4b71Sopenharmony_ci 1065e41f4b71Sopenharmony_ci**Since**: 12 1066e41f4b71Sopenharmony_ci 1067e41f4b71Sopenharmony_ci**Parameters** 1068e41f4b71Sopenharmony_ci 1069e41f4b71Sopenharmony_ci| Name| Description| 1070e41f4b71Sopenharmony_ci| -------- | -------- | 1071e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 1072e41f4b71Sopenharmony_ci| onTrigger | Callback to be set. | 1073e41f4b71Sopenharmony_ci 1074e41f4b71Sopenharmony_ci**Returns** 1075e41f4b71Sopenharmony_ci 1076e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null. 1077e41f4b71Sopenharmony_ci 1078e41f4b71Sopenharmony_ci 1079e41f4b71Sopenharmony_ci### OH_HiAppEvent_TakeWatcherData() 1080e41f4b71Sopenharmony_ci 1081e41f4b71Sopenharmony_ci``` 1082e41f4b71Sopenharmony_ciint OH_HiAppEvent_TakeWatcherData (HiAppEvent_Watcher * watcher, uint32_t eventNum, OH_HiAppEvent_OnTake onTake ) 1083e41f4b71Sopenharmony_ci``` 1084e41f4b71Sopenharmony_ci**Description** 1085e41f4b71Sopenharmony_ciObtains the event saved by the watcher. 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_ci**Since**: 12 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ci**Parameters** 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci| Name| Description| 1094e41f4b71Sopenharmony_ci| -------- | -------- | 1095e41f4b71Sopenharmony_ci| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). | 1096e41f4b71Sopenharmony_ci| eventNum | If the input value is less than or equal to **0**, all saved events are obtained. If the input value is greater than **0**, events are sorted by time in descending order and a specified number of saved events are obtained. | 1097e41f4b71Sopenharmony_ci| onTake | Pointer to the callback. The event information is returned through this callback. | 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ci**Returns** 1100e41f4b71Sopenharmony_ci 1101e41f4b71Sopenharmony_ci**0** if the API is called successfully; **-5** if the pointer of an input parameter is null; **-6** if **OH_HiAppEvent_AddWatcher** has not been called to add a watcher. 1102e41f4b71Sopenharmony_ci 1103e41f4b71Sopenharmony_ci 1104e41f4b71Sopenharmony_ci### OH_HiAppEvent_Write() 1105e41f4b71Sopenharmony_ci 1106e41f4b71Sopenharmony_ci``` 1107e41f4b71Sopenharmony_ciint OH_HiAppEvent_Write (const char * domain, const char * name, enum EventType type, const ParamList list ) 1108e41f4b71Sopenharmony_ci``` 1109e41f4b71Sopenharmony_ci**Description** 1110e41f4b71Sopenharmony_ciLogs application events whose parameters are of the list type. 1111e41f4b71Sopenharmony_ci 1112e41f4b71Sopenharmony_ciBefore application event logging, use this API to verify parameters of the events. If the verification is successful, the API writes the events to the event file. 1113e41f4b71Sopenharmony_ci 1114e41f4b71Sopenharmony_ci**Since**: 8 1115e41f4b71Sopenharmony_ci 1116e41f4b71Sopenharmony_ci**Parameters** 1117e41f4b71Sopenharmony_ci 1118e41f4b71Sopenharmony_ci| Name| Description| 1119e41f4b71Sopenharmony_ci| -------- | -------- | 1120e41f4b71Sopenharmony_ci| domain | Event domain. You can customize event domains as required. The value is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (_). | 1121e41f4b71Sopenharmony_ci| name | Event name. You can customize event names as required. The value is string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), underscore (_), and dollar sign ($). It must start with a letter or dollar sign ($) and end with a digit or letter. | 1122e41f4b71Sopenharmony_ci| type | Event type, which is defined in [EventType](#eventtype). | 1123e41f4b71Sopenharmony_ci| list | List of event parameters, each of which consists of a parameter name and a parameter value. The specifications are as follows:<br>1. A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), underscore (_), and dollar sign ($). It must start with a letter or dollar sign ($) and end with a digit or letter.<br>2. The parameter value can be string, number, Boolean, or array. The length of a parameter of the string type must be less than 8 × 1024 characters. If this limit is exceeded, the parameter will be discarded. The element type of an array parameter can only be string, number, or Boolean, and the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>3. The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.| 1124e41f4b71Sopenharmony_ci 1125e41f4b71Sopenharmony_ci**Returns** 1126e41f4b71Sopenharmony_ci 1127e41f4b71Sopenharmony_ciThe value **0** indicates that the event parameter is valid, and the event will be written to the event file asynchronously. A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. A value smaller than **0** indicates that the event parameter verification fails, and the event will not be written to the event file. 0 The event parameter is valid. -1 The event name is invalid. -4 The event domain name is invalid. -99 The application event logging is disabled. 1 The event parameter name is invalid. 4 The length of the event parameter string is invalid. 5 The number of event parameters is invalid. 6 The length of the event parameter array is invalid. 8 The event parameter name is duplicate. 1128