1e41f4b71Sopenharmony_ci# HiAppEvent 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 概述 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciHiAppEvent模块提供应用事件打点功能。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci为应用程序提供事件打点功能,记录运行过程中上报的故障事件、统计事件、安全事件和用户行为事件。基于事件信息,开发者可以分析应用的运行状态。 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.HiviewDFX.HiAppEvent 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**起始版本:** 8 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## 汇总 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci### 文件 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci| 名称 | 描述 | 21e41f4b71Sopenharmony_ci| -------- | -------- | 22e41f4b71Sopenharmony_ci| [hiappevent.h](hiappevent_8h.md) | HiAppEvent模块的应用事件打点函数定义。<br/>**引用文件**:<hiappevent/hiappevent.h><br/>**库**:libhiappevent_ndk.z.so | 23e41f4b71Sopenharmony_ci| [hiappevent_cfg.h](hiappevent__cfg_8h.md) | 定义事件打点配置函数的所有配置项名称。<br/>**引用文件**:<hiappevent/hiappevent_event.h><br/>**库**:libhiappevent_ndk.z.so | 24e41f4b71Sopenharmony_ci| [hiappevent_event.h](hiappevent__event_8h.md) | 定义所有预定义事件的事件名称。<br/>**引用文件**:<hiappevent/hiappevent_param.h><br/>**库**:libhiappevent_ndk.z.so | 25e41f4b71Sopenharmony_ci| [hiappevent_param.h](hiappevent__param_8h.md) | 定义所有预定义事件的参数名称。<br/>**引用文件**:<hiappevent/hiappevent_cfg.h><br/>**库**:libhiappevent_ndk.z.so | 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci### 结构体 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci| 名称 | 描述 | 31e41f4b71Sopenharmony_ci| -------- | -------- | 32e41f4b71Sopenharmony_ci| struct [HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) | 单个事件信息,包含事件领域,事件名称,事件类型和json格式字符串表示的事件中携带的自定义参数列表。 | 33e41f4b71Sopenharmony_ci| struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) | 具有相同事件名称的事件组。 | 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci### 宏定义 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci| 名称 | 描述 | 39e41f4b71Sopenharmony_ci| -------- | -------- | 40e41f4b71Sopenharmony_ci| [DISABLE](#disable) "disable" | 事件打点开关。默认值为false。true:关闭打点功能,false:不关闭打点功能。 | 41e41f4b71Sopenharmony_ci| [MAX_STORAGE](#max_storage) "max_storage" | 事件文件目录存储配额大小。默认值为“10M”。 | 42e41f4b71Sopenharmony_ci| [EVENT_USER_LOGIN](#event_user_login) "hiappevent.user_login" | 用户登录事件。 | 43e41f4b71Sopenharmony_ci| [EVENT_USER_LOGOUT](#event_user_logout) "hiappevent.user_logout" | 用户登出事件。 | 44e41f4b71Sopenharmony_ci| [EVENT_DISTRIBUTED_SERVICE_START](#event_distributed_service_start) "hiappevent.distributed_service_start" | 分布式服务事件。 | 45e41f4b71Sopenharmony_ci| [EVENT_APP_CRASH](#event_app_crash) "APP_CRASH" | 应用崩溃事件。 | 46e41f4b71Sopenharmony_ci| [EVENT_APP_FREEZE](#event_app_freeze) "APP_FREEZE" | 应用卡顿事件。 | 47e41f4b71Sopenharmony_ci| [EVENT_APP_LAUNCH](#event_app_launch) "APP_LAUNCH" | 应用加载事件。 | 48e41f4b71Sopenharmony_ci| [EVENT_SCROLL_JANK](#event_scroll_jank) "SCROLL_JANK" | 应用滑动卡顿事件。 | 49e41f4b71Sopenharmony_ci| [EVENT_CPU_USAGE_HIGH](#event_cpu_usage_high) "CPU_USAGE_HIGH" | 应用CPU资源占用高事件。 | 50e41f4b71Sopenharmony_ci| [EVENT_BATTERY_USAGE](#event_battery_usage) "BATTERY_USAGE" | 应用电源使用率事件。 | 51e41f4b71Sopenharmony_ci| [EVENT_RESOURCE_OVERLIMIT](#event_resource_overlimit) "RESOURCE_OVERLIMIT" | 应用资源超限事件。 | 52e41f4b71Sopenharmony_ci| [DOMAIN_OS](#domain_os) "OS" | OS作用域。 | 53e41f4b71Sopenharmony_ci| [PARAM_USER_ID](#param_user_id) "user_id" | 用户ID。 | 54e41f4b71Sopenharmony_ci| [PARAM_DISTRIBUTED_SERVICE_NAME](#param_distributed_service_name) "ds_name" | 分布式服务名称。 | 55e41f4b71Sopenharmony_ci| [PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID](#param_distributed_service_instance_id) "ds_instance_id" | 分布式服务实例ID。 | 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci### 类型定义 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci| 名称 | 描述 | 61e41f4b71Sopenharmony_ci| -------- | -------- | 62e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) [HiAppEvent_AppEventInfo](#hiappevent_appeventinfo) | 单个事件信息,包含事件领域,事件名称,事件类型和json格式字符串表示的事件中携带的自定义参数列表。 | 63e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) [HiAppEvent_AppEventGroup](#hiappevent_appeventgroup) | 具有相同事件名称的事件组。 | 64e41f4b71Sopenharmony_ci| typedef struct ParamListNode \* [ParamList](#paramlist) | 事件参数列表节点。 | 65e41f4b71Sopenharmony_ci| typedef struct [HiAppEvent_Watcher](#hiappevent_watcher) [HiAppEvent_Watcher](#hiappevent_watcher) | 用于接收app事件的监听器。 | 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) | 监听器接收到事件后,将触发该回调,将事件内容传递给调用方。 | 67e41f4b71Sopenharmony_ci| typedef void(\* [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger)) (int row, int size) | 监听器收到事件后,若监听器中未设置OH_HiAppEvent_OnReceive回调,将保存该事件。当保存的事件满足通过 OH_HiAppEvent_SetTriggerCondition设定的条件后,将触发该回调。回调结束后,当新保存的事件消息再次满足设定的条件后,将再次进行回调。 | 68e41f4b71Sopenharmony_ci| typedef void(\* [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake)) (const char \*const \*events, uint32_t eventLen) | 使用OH_HiAppEvent_TakeWatcherData获取监听器接收到的事件时,监听器接收到的事件将通过该回调函数传递给调用者。 | 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci### 枚举 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci| 名称 | 描述 | 74e41f4b71Sopenharmony_ci| -------- | -------- | 75e41f4b71Sopenharmony_ci| [EventType](#eventtype) { **FAULT** = 1, **STATISTIC** = 2, **SECURITY** = 3, **BEHAVIOR** = 4 } | 事件类型。 | 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci### 函数 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci| 名称 | 描述 | 81e41f4b71Sopenharmony_ci| -------- | -------- | 82e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_CreateParamList](#oh_hiappevent_createparamlist) (void) | 创建一个指向参数列表对象的指针。 | 83e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_DestroyParamList](#oh_hiappevent_destroyparamlist) ([ParamList](#paramlist) list) | 销毁一个指向参数列表对象的指针,释放其分配内存。 | 84e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolParam](#oh_hiappevent_addboolparam) ([ParamList](#paramlist) list, const char \*name, bool boolean) | 添加一个布尔参数到参数列表中。 | 85e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolArrayParam](#oh_hiappevent_addboolarrayparam) ([ParamList](#paramlist) list, const char \*name, const bool \*booleans, int arrSize) | 添加一个布尔数组参数到参数列表中。 | 86e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8Param](#oh_hiappevent_addint8param) ([ParamList](#paramlist) list, const char \*name, int8_t num) | 添加一个int8_t参数到参数列表中。 | 87e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8ArrayParam](#oh_hiappevent_addint8arrayparam) ([ParamList](#paramlist) list, const char \*name, const int8_t \*nums, int arrSize) | 添加一个int8_t数组参数到参数列表中。 | 88e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16Param](#oh_hiappevent_addint16param) ([ParamList](#paramlist) list, const char \*name, int16_t num) | 添加一个int16_t参数到参数列表中。 | 89e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16ArrayParam](#oh_hiappevent_addint16arrayparam) ([ParamList](#paramlist) list, const char \*name, const int16_t \*nums, int arrSize) | 添加一个int16_t数组参数到参数列表中。 | 90e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32Param](#oh_hiappevent_addint32param) ([ParamList](#paramlist) list, const char \*name, int32_t num) | 添加一个int32_t参数到参数列表中。 | 91e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32ArrayParam](#oh_hiappevent_addint32arrayparam) ([ParamList](#paramlist) list, const char \*name, const int32_t \*nums, int arrSize) | 添加一个int32_t数组参数到参数列表中。 | 92e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64Param](#oh_hiappevent_addint64param) ([ParamList](#paramlist) list, const char \*name, int64_t num) | 添加一个int64_t参数到参数列表中。 | 93e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64ArrayParam](#oh_hiappevent_addint64arrayparam) ([ParamList](#paramlist) list, const char \*name, const int64_t \*nums, int arrSize) | 添加一个int64_t数组参数到参数列表中。 | 94e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatParam](#oh_hiappevent_addfloatparam) ([ParamList](#paramlist) list, const char \*name, float num) | 添加一个float参数到参数列表中。 | 95e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatArrayParam](#oh_hiappevent_addfloatarrayparam) ([ParamList](#paramlist) list, const char \*name, const float \*nums, int arrSize) | 添加一个float数组参数到参数列表中。 | 96e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleParam](#oh_hiappevent_adddoubleparam) ([ParamList](#paramlist) list, const char \*name, double num) | 添加一个double参数到参数列表中。 | 97e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleArrayParam](#oh_hiappevent_adddoublearrayparam) ([ParamList](#paramlist) list, const char \*name, const double \*nums, int arrSize) | 添加一个double数组参数到参数列表中。 | 98e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddStringParam](#oh_hiappevent_addstringparam) ([ParamList](#paramlist) list, const char \*name, const char \*str) | 添加一个字符串参数到参数列表中。 | 99e41f4b71Sopenharmony_ci| [ParamList](#paramlist) [OH_HiAppEvent_AddStringArrayParam](#oh_hiappevent_addstringarrayparam) ([ParamList](#paramlist) list, const char \*name, const char \*const \*strs, int arrSize) | 添加一个字符串数组参数到参数列表中。 | 100e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_Write](#oh_hiappevent_write) (const char \*domain, const char \*name, enum [EventType](#eventtype) type, const [ParamList](#paramlist) list) | 实现对参数为列表类型的应用事件打点。 | 101e41f4b71Sopenharmony_ci| bool [OH_HiAppEvent_Configure](#oh_hiappevent_configure) (const char \*name, const char \*value) | 实现应用事件打点的配置功能。 | 102e41f4b71Sopenharmony_ci| [HiAppEvent_Watcher](#hiappevent_watcher) \* [OH_HiAppEvent_CreateWatcher](#oh_hiappevent_createwatcher) (const char \*name) | 创建一个用于监听app事件的监听器。 | 103e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_DestroyWatcher](#oh_hiappevent_destroywatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | 销毁已创建的监听器。 | 104e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetTriggerCondition](#oh_hiappevent_settriggercondition) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, int row, int size, int timeOut) | 用于设置监听器OH_HiAppEvent_OnTrigger回调的触发条件,分别可以从监视器新接收事件数量,新接收事件大小,onTrigger触发超时时间 设置触发条件,调用方应至少保证从一个方面设置触发条件。 | 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) | 用于设置监听器需要监听的事件的类型。 | 106e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetWatcherOnTrigger](#oh_hiappevent_setwatcherontrigger) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger) onTrigger) | 用于设置监听器onTrigger回调的接口。 | 107e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_SetWatcherOnReceive](#oh_hiappevent_setwatcheronreceive) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnReceive](#oh_hiappevent_onreceive) onReceive) | 用于设置监听器onReceive回调函数的接口。当监听器监听到相应事件后,onReceive回调函数将被调用。 | 108e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_TakeWatcherData](#oh_hiappevent_takewatcherdata) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, uint32_t eventNum, [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake) onTake) | 用于获取监听器收到后保存的事件。 | 109e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_AddWatcher](#oh_hiappevent_addwatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | 添加监听器的接口,监听器开始监听系统消息。 | 110e41f4b71Sopenharmony_ci| int [OH_HiAppEvent_RemoveWatcher](#oh_hiappevent_removewatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | 移除监听器的接口,监听器停止监听系统消息。 | 111e41f4b71Sopenharmony_ci| void [OH_HiAppEvent_ClearData](#oh_hiappevent_cleardata) (void) | 清除所有监视器保存的所有事件。 | 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci## 宏定义说明 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci### DISABLE 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci``` 120e41f4b71Sopenharmony_ci#define DISABLE "disable" 121e41f4b71Sopenharmony_ci``` 122e41f4b71Sopenharmony_ci**描述** 123e41f4b71Sopenharmony_ci事件打点开关。默认值为false。true:关闭打点功能,false:不关闭打点功能。 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci**起始版本:** 8 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci### DOMAIN_OS 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci``` 131e41f4b71Sopenharmony_ci#define DOMAIN_OS "OS" 132e41f4b71Sopenharmony_ci``` 133e41f4b71Sopenharmony_ci**描述** 134e41f4b71Sopenharmony_ciOS作用域。 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 145e41f4b71Sopenharmony_ci应用崩溃事件。 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 156e41f4b71Sopenharmony_ci应用卡顿事件。 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 167e41f4b71Sopenharmony_ci应用加载事件。 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 178e41f4b71Sopenharmony_ci应用电源使用率事件。 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 189e41f4b71Sopenharmony_ci应用CPU资源占用高事件。 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 200e41f4b71Sopenharmony_ci分布式服务事件。 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 211e41f4b71Sopenharmony_ci应用资源超限事件。 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 222e41f4b71Sopenharmony_ci应用滑动卡顿事件。 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 233e41f4b71Sopenharmony_ci用户登录事件。 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 244e41f4b71Sopenharmony_ci用户登出事件。 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**起始版本:** 8 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci### MAX_STORAGE 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci``` 252e41f4b71Sopenharmony_ci#define MAX_STORAGE "max_storage" 253e41f4b71Sopenharmony_ci``` 254e41f4b71Sopenharmony_ci**描述** 255e41f4b71Sopenharmony_ci事件文件目录存储配额大小。默认值为“10M”。 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 266e41f4b71Sopenharmony_ci分布式服务实例ID。 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 277e41f4b71Sopenharmony_ci分布式服务名称。 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 288e41f4b71Sopenharmony_ci用户ID。 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci**起始版本:** 8 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci## 类型定义说明 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci### HiAppEvent_AppEventGroup 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci``` 299e41f4b71Sopenharmony_citypedef struct HiAppEvent_AppEventGroupHiAppEvent_AppEventGroup 300e41f4b71Sopenharmony_ci``` 301e41f4b71Sopenharmony_ci**描述** 302e41f4b71Sopenharmony_ci具有相同事件名称的事件组。 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.HiviewDFX.HiAppEvent 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci**起始版本:** 12 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci### HiAppEvent_AppEventInfo 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci``` 312e41f4b71Sopenharmony_citypedef struct HiAppEvent_AppEventInfoHiAppEvent_AppEventInfo 313e41f4b71Sopenharmony_ci``` 314e41f4b71Sopenharmony_ci**描述** 315e41f4b71Sopenharmony_ci单个事件信息,包含事件领域,事件名称,事件类型和json格式字符串表示的事件中携带的自定义参数列表。 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci**起始版本:** 12 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci### HiAppEvent_Watcher 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci``` 325e41f4b71Sopenharmony_citypedef struct HiAppEvent_WatcherHiAppEvent_Watcher 326e41f4b71Sopenharmony_ci``` 327e41f4b71Sopenharmony_ci**描述** 328e41f4b71Sopenharmony_ci用于接收app事件的监听器。 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.HiviewDFX.HiAppEvent 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 341e41f4b71Sopenharmony_ci监听器接收到事件后,将触发该回调,将事件内容传递给调用方。 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci注意:回调中的指针所指对象的生命周期仅限于该回调函数内,请勿在该回调函数外直接使用该指针,若需缓存该信息,请对指针指向的内容进行深拷贝。 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci**起始版本:** 12 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci**参数:** 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci| 名称 | 描述 | 352e41f4b71Sopenharmony_ci| -------- | -------- | 353e41f4b71Sopenharmony_ci| domain | 接收到的app事件的领域。 | 354e41f4b71Sopenharmony_ci| appEventGroups | 按照不同事件名称分组的事件组数组。 | 355e41f4b71Sopenharmony_ci| groupLen | 事件组数组的长度。 | 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**描述** 364e41f4b71Sopenharmony_ci使用OH_HiAppEvent_TakeWatcherData获取监听器接收到的事件时,监听器接收到的事件将通过该回调函数传递给调用者。 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci注意:回调中的指针所指对象的生命周期仅限于该回调函数内,请勿在该回调函数外直接使用该指针,若需缓存该信息,请对指针指向的内容进行深拷贝。 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci**起始版本:** 12 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci**参数:** 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci| 名称 | 描述 | 375e41f4b71Sopenharmony_ci| -------- | -------- | 376e41f4b71Sopenharmony_ci| events | json字符串格式的事件数组。 | 377e41f4b71Sopenharmony_ci| eventLen | 事件数组大小。 | 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**描述** 386e41f4b71Sopenharmony_ci监听器收到事件后,若监听器中未设置OH_HiAppEvent_OnReceive回调,将保存该事件。当保存的事件满足通过 OH_HiAppEvent_SetTriggerCondition设定的条件后,将触发该回调。回调结束后,当新保存的事件消息再次满足设定的条件后,将再次进行回调。 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci**起始版本:** 12 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci**参数:** 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci| 名称 | 描述 | 395e41f4b71Sopenharmony_ci| -------- | -------- | 396e41f4b71Sopenharmony_ci| row | 监听器新接收到的事件消息的数量。 | 397e41f4b71Sopenharmony_ci| size | 监听器新接收的事件消息的大小总和(单个事件大小计算方式为,将消息转换为json字符串后,字符串的长度)。 | 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci### ParamList 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci``` 403e41f4b71Sopenharmony_citypedef struct ParamListNode* ParamList 404e41f4b71Sopenharmony_ci``` 405e41f4b71Sopenharmony_ci**描述** 406e41f4b71Sopenharmony_ci事件参数列表节点。 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**起始版本:** 8 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci## 枚举类型说明 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci### EventType 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci``` 417e41f4b71Sopenharmony_cienum EventType 418e41f4b71Sopenharmony_ci``` 419e41f4b71Sopenharmony_ci**描述** 420e41f4b71Sopenharmony_ci事件类型。 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci建议开发者根据不同的使用场景选择不同的事件类型。 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci**起始版本:** 8 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 427e41f4b71Sopenharmony_ci| -------- | -------- | 428e41f4b71Sopenharmony_ci| FAULT | 故障事件类型 | 429e41f4b71Sopenharmony_ci| STATISTIC | 统计事件类型 | 430e41f4b71Sopenharmony_ci| SECURITY | 安全事件类型 | 431e41f4b71Sopenharmony_ci| BEHAVIOR | 行为事件类型 | 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ci## 函数说明 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**描述** 443e41f4b71Sopenharmony_ci添加一个布尔数组参数到参数列表中。 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci**起始版本:** 8 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci**参数:** 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci| 名称 | 描述 | 450e41f4b71Sopenharmony_ci| -------- | -------- | 451e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 452e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 453e41f4b71Sopenharmony_ci| booleans | 需要添加的布尔数组参数值。 | 454e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci**返回:** 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 467e41f4b71Sopenharmony_ci添加一个布尔参数到参数列表中。 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci**起始版本:** 8 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci**参数:** 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci| 名称 | 描述 | 474e41f4b71Sopenharmony_ci| -------- | -------- | 475e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 476e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 477e41f4b71Sopenharmony_ci| boolean | 需要添加的布尔参数值。 | 478e41f4b71Sopenharmony_ci 479e41f4b71Sopenharmony_ci**返回:** 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 490e41f4b71Sopenharmony_ci添加一个double数组参数到参数列表中。 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**起始版本:** 8 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci**参数:** 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci| 名称 | 描述 | 497e41f4b71Sopenharmony_ci| -------- | -------- | 498e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 499e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 500e41f4b71Sopenharmony_ci| nums | 需要添加的double数组参数值。 | 501e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**返回:** 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 514e41f4b71Sopenharmony_ci添加一个double参数到参数列表中。 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ci**起始版本:** 8 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ci**参数:** 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci| 名称 | 描述 | 521e41f4b71Sopenharmony_ci| -------- | -------- | 522e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 523e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 524e41f4b71Sopenharmony_ci| num | 需要添加的double参数值。 | 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ci**返回:** 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 537e41f4b71Sopenharmony_ci添加一个float数组参数到参数列表中。 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci**起始版本:** 8 540e41f4b71Sopenharmony_ci 541e41f4b71Sopenharmony_ci**参数:** 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ci| 名称 | 描述 | 544e41f4b71Sopenharmony_ci| -------- | -------- | 545e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 546e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 547e41f4b71Sopenharmony_ci| nums | 需要添加的float数组参数值。 | 548e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci**返回:** 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 561e41f4b71Sopenharmony_ci添加一个float参数到参数列表中。 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_ci**起始版本:** 8 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_ci**参数:** 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci| 名称 | 描述 | 568e41f4b71Sopenharmony_ci| -------- | -------- | 569e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 570e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 571e41f4b71Sopenharmony_ci| num | 需要添加的float参数值。 | 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci**返回:** 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 584e41f4b71Sopenharmony_ci添加一个int16_t数组参数到参数列表中。 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci**起始版本:** 8 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci**参数:** 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ci| 名称 | 描述 | 591e41f4b71Sopenharmony_ci| -------- | -------- | 592e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 593e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 594e41f4b71Sopenharmony_ci| nums | 需要添加的int16_t数组参数值。 | 595e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_ci**返回:** 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 608e41f4b71Sopenharmony_ci添加一个int16_t参数到参数列表中。 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci**起始版本:** 8 611e41f4b71Sopenharmony_ci 612e41f4b71Sopenharmony_ci**参数:** 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci| 名称 | 描述 | 615e41f4b71Sopenharmony_ci| -------- | -------- | 616e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 617e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 618e41f4b71Sopenharmony_ci| num | 需要添加的int16_t参数值。 | 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci**返回:** 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 631e41f4b71Sopenharmony_ci添加一个int32_t数组参数到参数列表中。 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci**起始版本:** 8 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ci**参数:** 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci| 名称 | 描述 | 638e41f4b71Sopenharmony_ci| -------- | -------- | 639e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 640e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 641e41f4b71Sopenharmony_ci| nums | 需要添加的int32_t数组参数值。 | 642e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 643e41f4b71Sopenharmony_ci 644e41f4b71Sopenharmony_ci**返回:** 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 655e41f4b71Sopenharmony_ci添加一个int32_t参数到参数列表中。 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci**起始版本:** 8 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci**参数:** 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci| 名称 | 描述 | 662e41f4b71Sopenharmony_ci| -------- | -------- | 663e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 664e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 665e41f4b71Sopenharmony_ci| num | 需要添加的int32_t参数值。 | 666e41f4b71Sopenharmony_ci 667e41f4b71Sopenharmony_ci**返回:** 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 678e41f4b71Sopenharmony_ci添加一个int64_t数组参数到参数列表中。 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ci**起始版本:** 8 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci**参数:** 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ci| 名称 | 描述 | 685e41f4b71Sopenharmony_ci| -------- | -------- | 686e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 687e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 688e41f4b71Sopenharmony_ci| nums | 需要添加的int64_t数组参数值。 | 689e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 690e41f4b71Sopenharmony_ci 691e41f4b71Sopenharmony_ci**返回:** 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 702e41f4b71Sopenharmony_ci添加一个int64_t参数到参数列表中。 703e41f4b71Sopenharmony_ci 704e41f4b71Sopenharmony_ci**起始版本:** 8 705e41f4b71Sopenharmony_ci 706e41f4b71Sopenharmony_ci**参数:** 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_ci| 名称 | 描述 | 709e41f4b71Sopenharmony_ci| -------- | -------- | 710e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 711e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 712e41f4b71Sopenharmony_ci| num | 需要添加的int64_t参数值。 | 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_ci**返回:** 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 725e41f4b71Sopenharmony_ci添加一个int8_t数组参数到参数列表中。 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**起始版本:** 8 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci**参数:** 730e41f4b71Sopenharmony_ci 731e41f4b71Sopenharmony_ci| 名称 | 描述 | 732e41f4b71Sopenharmony_ci| -------- | -------- | 733e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 734e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 735e41f4b71Sopenharmony_ci| nums | 需要添加的int8_t数组参数值。 | 736e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci**返回:** 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 749e41f4b71Sopenharmony_ci添加一个int8_t参数到参数列表中。 750e41f4b71Sopenharmony_ci 751e41f4b71Sopenharmony_ci**起始版本:** 8 752e41f4b71Sopenharmony_ci 753e41f4b71Sopenharmony_ci**参数:** 754e41f4b71Sopenharmony_ci 755e41f4b71Sopenharmony_ci| 名称 | 描述 | 756e41f4b71Sopenharmony_ci| -------- | -------- | 757e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 758e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 759e41f4b71Sopenharmony_ci| num | 需要添加的int8_t参数值。 | 760e41f4b71Sopenharmony_ci 761e41f4b71Sopenharmony_ci**返回:** 762e41f4b71Sopenharmony_ci 763e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 772e41f4b71Sopenharmony_ci添加一个字符串数组参数到参数列表中。 773e41f4b71Sopenharmony_ci 774e41f4b71Sopenharmony_ci**起始版本:** 8 775e41f4b71Sopenharmony_ci 776e41f4b71Sopenharmony_ci**参数:** 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_ci| 名称 | 描述 | 779e41f4b71Sopenharmony_ci| -------- | -------- | 780e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 781e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 782e41f4b71Sopenharmony_ci| strs | 需要添加的字符串数组参数值。 | 783e41f4b71Sopenharmony_ci| arrSize | 需要添加的参数数组大小。 | 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci**返回:** 786e41f4b71Sopenharmony_ci 787e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 796e41f4b71Sopenharmony_ci添加一个字符串参数到参数列表中。 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci**起始版本:** 8 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_ci**参数:** 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ci| 名称 | 描述 | 803e41f4b71Sopenharmony_ci| -------- | -------- | 804e41f4b71Sopenharmony_ci| list | 需要添加参数的参数列表指针。 | 805e41f4b71Sopenharmony_ci| name | 需要添加的参数名称。 | 806e41f4b71Sopenharmony_ci| str | 需要添加的字符串参数值。 | 807e41f4b71Sopenharmony_ci 808e41f4b71Sopenharmony_ci**返回:** 809e41f4b71Sopenharmony_ci 810e41f4b71Sopenharmony_ci添加参数后的参数列表指针。 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**描述** 819e41f4b71Sopenharmony_ci添加监听器的接口,监听器开始监听系统消息。 820e41f4b71Sopenharmony_ci 821e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ci**起始版本:** 12 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_ci**参数:** 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ci| 名称 | 描述 | 828e41f4b71Sopenharmony_ci| -------- | -------- | 829e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 830e41f4b71Sopenharmony_ci 831e41f4b71Sopenharmony_ci**返回:** 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针。 834e41f4b71Sopenharmony_ci 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ci### OH_HiAppEvent_ClearData() 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci``` 839e41f4b71Sopenharmony_civoid OH_HiAppEvent_ClearData (void ) 840e41f4b71Sopenharmony_ci``` 841e41f4b71Sopenharmony_ci**描述** 842e41f4b71Sopenharmony_ci清除所有监视器保存的所有事件。 843e41f4b71Sopenharmony_ci 844e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 845e41f4b71Sopenharmony_ci 846e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 855e41f4b71Sopenharmony_ci实现应用事件打点的配置功能。 856e41f4b71Sopenharmony_ci 857e41f4b71Sopenharmony_ci应用事件打点配置接口,用于配置事件打点开关、事件文件目录存储配额大小等功能。 858e41f4b71Sopenharmony_ci 859e41f4b71Sopenharmony_ci**起始版本:** 8 860e41f4b71Sopenharmony_ci 861e41f4b71Sopenharmony_ci**参数:** 862e41f4b71Sopenharmony_ci 863e41f4b71Sopenharmony_ci| 名称 | 描述 | 864e41f4b71Sopenharmony_ci| -------- | -------- | 865e41f4b71Sopenharmony_ci| name | 配置项名称。名称可填[DISABLE](#disable)和[MAX_STORAGE](#max_storage)。 | 866e41f4b71Sopenharmony_ci| value | 配置项值。如果配置项名称是[DISABLE](#disable),值可以填“true”或者“false”;如果配置项名称是[MAX_STORAGE](#max_storage), 配额值字符串只由数字字符和大小单位字符(单位字符支持[b\|k\|kb\|m\|mb\|g\|gb\|t\|tb],不区分大小写)构成, 配额值字符串必须以数字开头,后面可以选择不传单位字符(默认使用byte作为单位),或者以单位字符结尾。 | 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci**返回:** 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_ci配置结果。如果配置成功,则返回true;如果配置失败则返回false。 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci 873e41f4b71Sopenharmony_ci### OH_HiAppEvent_CreateParamList() 874e41f4b71Sopenharmony_ci 875e41f4b71Sopenharmony_ci``` 876e41f4b71Sopenharmony_ciParamList OH_HiAppEvent_CreateParamList (void ) 877e41f4b71Sopenharmony_ci``` 878e41f4b71Sopenharmony_ci**描述** 879e41f4b71Sopenharmony_ci创建一个指向参数列表对象的指针。 880e41f4b71Sopenharmony_ci 881e41f4b71Sopenharmony_ci**起始版本:** 8 882e41f4b71Sopenharmony_ci 883e41f4b71Sopenharmony_ci**返回:** 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ci指向参数列表对象的指针。 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**描述** 894e41f4b71Sopenharmony_ci创建一个用于监听app事件的监听器。 895e41f4b71Sopenharmony_ci 896e41f4b71Sopenharmony_ci注意:创建的监听器不再使用后必须通过调用OH_HiAppEvent_DestroyWatcher接口进行销毁。 897e41f4b71Sopenharmony_ci 898e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 899e41f4b71Sopenharmony_ci 900e41f4b71Sopenharmony_ci**起始版本:** 12 901e41f4b71Sopenharmony_ci 902e41f4b71Sopenharmony_ci**参数:** 903e41f4b71Sopenharmony_ci 904e41f4b71Sopenharmony_ci| 名称 | 描述 | 905e41f4b71Sopenharmony_ci| -------- | -------- | 906e41f4b71Sopenharmony_ci| name | 监听器名称。 | 907e41f4b71Sopenharmony_ci 908e41f4b71Sopenharmony_ci**返回:** 909e41f4b71Sopenharmony_ci 910e41f4b71Sopenharmony_ci接口调用成功时返回指向的新建监听器的指针,name参数异常时返回nullptr。 911e41f4b71Sopenharmony_ci 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ci### OH_HiAppEvent_DestroyParamList() 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci``` 916e41f4b71Sopenharmony_civoid OH_HiAppEvent_DestroyParamList (ParamList list) 917e41f4b71Sopenharmony_ci``` 918e41f4b71Sopenharmony_ci**描述** 919e41f4b71Sopenharmony_ci销毁一个指向参数列表对象的指针,释放其分配内存。 920e41f4b71Sopenharmony_ci 921e41f4b71Sopenharmony_ci**起始版本:** 8 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_ci**参数:** 924e41f4b71Sopenharmony_ci 925e41f4b71Sopenharmony_ci| 名称 | 描述 | 926e41f4b71Sopenharmony_ci| -------- | -------- | 927e41f4b71Sopenharmony_ci| list | 参数列表对象指针。 | 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**描述** 936e41f4b71Sopenharmony_ci销毁已创建的监听器。 937e41f4b71Sopenharmony_ci 938e41f4b71Sopenharmony_ci注意:已创建的监听器不再使用后,需要将其销毁,释放内存,防止内存泄漏,销毁后需将对应指针置空。 939e41f4b71Sopenharmony_ci 940e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 941e41f4b71Sopenharmony_ci 942e41f4b71Sopenharmony_ci**起始版本:** 12 943e41f4b71Sopenharmony_ci 944e41f4b71Sopenharmony_ci**参数:** 945e41f4b71Sopenharmony_ci 946e41f4b71Sopenharmony_ci| 名称 | 描述 | 947e41f4b71Sopenharmony_ci| -------- | -------- | 948e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即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**描述** 957e41f4b71Sopenharmony_ci移除监听器的接口,监听器停止监听系统消息。 958e41f4b71Sopenharmony_ci 959e41f4b71Sopenharmony_ci注意:该接口仅仅使监听器停止监听系统消息,并未销毁该监听器,该监听器依然常驻内存,直至调用OH_HiAppEvent_DestroyWatcher接口,内存才会释放。 960e41f4b71Sopenharmony_ci 961e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 962e41f4b71Sopenharmony_ci 963e41f4b71Sopenharmony_ci**起始版本:** 12 964e41f4b71Sopenharmony_ci 965e41f4b71Sopenharmony_ci**参数:** 966e41f4b71Sopenharmony_ci 967e41f4b71Sopenharmony_ci| 名称 | 描述 | 968e41f4b71Sopenharmony_ci| -------- | -------- | 969e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 970e41f4b71Sopenharmony_ci 971e41f4b71Sopenharmony_ci**返回:** 972e41f4b71Sopenharmony_ci 973e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针;-6:还未调用OH_HiAppEvent_AddWatcher,操作顺序有误。 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**描述** 982e41f4b71Sopenharmony_ci用于设置监听器需要监听的事件的类型。 983e41f4b71Sopenharmony_ci 984e41f4b71Sopenharmony_ci该函数可以重复调用,可添加多个过滤规则,而非替换,监听器将收到满足任一过滤规则的事件的通知。 985e41f4b71Sopenharmony_ci 986e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 987e41f4b71Sopenharmony_ci 988e41f4b71Sopenharmony_ci**起始版本:** 12 989e41f4b71Sopenharmony_ci 990e41f4b71Sopenharmony_ci**参数:** 991e41f4b71Sopenharmony_ci 992e41f4b71Sopenharmony_ci| 名称 | 描述 | 993e41f4b71Sopenharmony_ci| -------- | -------- | 994e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 995e41f4b71Sopenharmony_ci| domain | 需要监听事件的领域。 | 996e41f4b71Sopenharmony_ci| eventTypes | 需要监听事件的事件类型。使用按位与方式进行匹配,可支持监听多种类型的事件, 第一位为1(数值为1)表示支持监听故障类型的事件,第二位为1(数值为2)表示支持监听统计类型的事件, 第三位为1(数值为4)表示支持监听安全类型的事件,第四位为1(数值为8)表示支持监听行为类型的事件, 都为1(数值为15)或者都为0(数值为0)表示支持所有类型事件。 | 997e41f4b71Sopenharmony_ci| names | 需要监听的事件名称数组。 | 998e41f4b71Sopenharmony_ci| namesLen | 监听的事件名称的数组长度。 | 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci**返回:** 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ci0:接口调用成功;-1:names参数异常;-4:domain参数异常;-5:watcher入参空指针。 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**描述** 1011e41f4b71Sopenharmony_ci用于设置监听器OH_HiAppEvent_OnTrigger回调的触发条件,分别可以从监视器新接收事件数量,新接收事件大小,onTrigger触发超时时间 设置触发条件,调用方应至少保证从一个方面设置触发条件。 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1014e41f4b71Sopenharmony_ci 1015e41f4b71Sopenharmony_ci**起始版本:** 12 1016e41f4b71Sopenharmony_ci 1017e41f4b71Sopenharmony_ci**参数:** 1018e41f4b71Sopenharmony_ci 1019e41f4b71Sopenharmony_ci| 名称 | 描述 | 1020e41f4b71Sopenharmony_ci| -------- | -------- | 1021e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 1022e41f4b71Sopenharmony_ci| row | 当输入值大于0,且新接收事件的数量大于等于该值时,将调用设置的onTrigger回调函数吗,当输入值小于等于0时,不再以接收数量多少为维度 来触发onTrigger回调。 | 1023e41f4b71Sopenharmony_ci| size | 当输入值大于0,且新接收事件的大小(单个事件大小计算方式为,将事件转换为json字符串后,字符串的长度)大于等于该值时,将调用设置的 onTrigger回调函数,当输入值小于等于0时,不再以新接收事件大小为维度触发onTrigger回调。 | 1024e41f4b71Sopenharmony_ci| timeOut | 单位秒,当输入值大于0,每经过timeout秒,将检查监视器是否存在新接收到的事件,如果存在将触发onTrigger回调。触发onTrigger 后,经过timeOut秒后将再次检查是否存在新接收到的事件。当输入值小于等于0,不以超时时间为维度触发onTrigger回调。 | 1025e41f4b71Sopenharmony_ci 1026e41f4b71Sopenharmony_ci**返回:** 1027e41f4b71Sopenharmony_ci 1028e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针。 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**描述** 1037e41f4b71Sopenharmony_ci用于设置监听器onReceive回调函数的接口。当监听器监听到相应事件后,onReceive回调函数将被调用。 1038e41f4b71Sopenharmony_ci 1039e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_ci**起始版本:** 12 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ci**参数:** 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci| 名称 | 描述 | 1046e41f4b71Sopenharmony_ci| -------- | -------- | 1047e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 1048e41f4b71Sopenharmony_ci| onReceive | 回调函数的函数指针。 | 1049e41f4b71Sopenharmony_ci 1050e41f4b71Sopenharmony_ci**返回:** 1051e41f4b71Sopenharmony_ci 1052e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针。 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**描述** 1061e41f4b71Sopenharmony_ci用于设置监听器onTrigger回调的接口。 1062e41f4b71Sopenharmony_ci 1063e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1064e41f4b71Sopenharmony_ci 1065e41f4b71Sopenharmony_ci**起始版本:** 12 1066e41f4b71Sopenharmony_ci 1067e41f4b71Sopenharmony_ci**参数:** 1068e41f4b71Sopenharmony_ci 1069e41f4b71Sopenharmony_ci| 名称 | 描述 | 1070e41f4b71Sopenharmony_ci| -------- | -------- | 1071e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 1072e41f4b71Sopenharmony_ci| onTrigger | 需要设置的回调。 | 1073e41f4b71Sopenharmony_ci 1074e41f4b71Sopenharmony_ci**返回:** 1075e41f4b71Sopenharmony_ci 1076e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针。 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**描述** 1085e41f4b71Sopenharmony_ci用于获取监听器收到后保存的事件。 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ci\@SystemCapability.HiviewDFX.HiAppEvent 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_ci**起始版本:** 12 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ci**参数:** 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci| 名称 | 描述 | 1094e41f4b71Sopenharmony_ci| -------- | -------- | 1095e41f4b71Sopenharmony_ci| watcher | 指向监听器的指针(即OH_HiAppEvent_CreateWatcher接口返回的指针)。 | 1096e41f4b71Sopenharmony_ci| eventNum | 当输入值小于等于0时,取全部已保存事件;当输入值大于0时,按照事件发生时间倒序排列,取指定数量的已保存事件。 | 1097e41f4b71Sopenharmony_ci| onTake | 回调函数指针,事件通过调用该函数返回事件信息。 | 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ci**返回:** 1100e41f4b71Sopenharmony_ci 1101e41f4b71Sopenharmony_ci0:接口调用成功;-5:watcher入参空指针;-6:还未调用OH_HiAppEvent_AddWatcher,操作顺序有误。 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**描述** 1110e41f4b71Sopenharmony_ci实现对参数为列表类型的应用事件打点。 1111e41f4b71Sopenharmony_ci 1112e41f4b71Sopenharmony_ci在应用事件打点前,该接口会先对该事件的参数进行校验。如果校验成功,则接口会将事件写入事件文件。 1113e41f4b71Sopenharmony_ci 1114e41f4b71Sopenharmony_ci**起始版本:** 8 1115e41f4b71Sopenharmony_ci 1116e41f4b71Sopenharmony_ci**参数:** 1117e41f4b71Sopenharmony_ci 1118e41f4b71Sopenharmony_ci| 名称 | 描述 | 1119e41f4b71Sopenharmony_ci| -------- | -------- | 1120e41f4b71Sopenharmony_ci| domain | 事件领域。您可以根据需要自定义事件领域。事件领域名称支持数字、字母、下划线字符, 需要以字母开头且不能以下划线结尾,长度非空且不超过32个字符。 | 1121e41f4b71Sopenharmony_ci| name | 事件名称。您可以根据需要自定义事件名称。首字符必须为字母字符或$字符,中间字符必须为数字字符、 字母字符或下划线字符,结尾字符必须为数字字符或字母字符,长度非空且不超过48个字符。 | 1122e41f4b71Sopenharmony_ci| type | 事件类型,在[EventType](#eventtype)中定义。 | 1123e41f4b71Sopenharmony_ci| list | 事件参数列表,每个参数由参数名和参数值组成,其规格定义如下:<br/>1、参数名为字符串类型,首字符必须为字母字符或$字符,中间字符必须为数字字符、字母字符或下划线字符, 结尾字符必须为数字字符或字母字符,长度非空且不超过32个字符。<br/>2、参数值支持字符串、数值、布尔、数组类型,字符串类型参数长度需在8\*1024个字符以内,超出会做丢弃处理; 数组类型参数中的元素类型只能为字符串、数值、布尔中的一种,且元素个数需在100以内,超出会做丢弃处理。<br/>3、参数个数需在32个以内,超出的参数会做丢弃处理。 | 1124e41f4b71Sopenharmony_ci 1125e41f4b71Sopenharmony_ci**返回:** 1126e41f4b71Sopenharmony_ci 1127e41f4b71Sopenharmony_ci如果事件参数校验成功,则返回0,将事件写入事件文件;如果事件中存在无效参数,则返回正值,丢弃 无效参数后将事件写入事件文件;如果事件参数校验失败,则返回负值,并且事件将不会写入事件文件。 0 事件参数校验成功。 -1 非法的事件名称。 -4 非法的事件领域名称。 -99 打点功能被关闭。 1 非法的事件参数名称。 4 非法的事件参数字符串长度。 5 非法的事件参数数量。 6 非法的事件参数数组长度。 8 重复的事件参数名称。 1128