update hiviewdfx/hiappevent/include/hiappevent/hiappevent.h.

Signed-off-by: yuhaoqiang <yuhaoqiang@huawei.com>
This commit is contained in:
yuhaoqiang 2024-02-21 10:45:57 +08:00
parent 531cd93d92
commit 89673a1f0f
2 changed files with 268 additions and 0 deletions

View File

@ -107,6 +107,40 @@ enum EventType {
BEHAVIOR = 4
};
/**
* @brief Definition of HiAppEvent_AppEventInfo object.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @since 12
* @version 1.0
*/
struct HiAppEvent_AppEventInfo {
/* The domain of the event. */
const char* domain;
/* The name of the event. */
const char* name;
/* The type of the event. */
enum EventType type;
/* The json string of the parameter. */
const char* params;
};
/**
* @brief Defines the event group.
*
* @syscap SystemCapability.HiviewDFX.HiAppEvent
* @since 12
* @version 1.0
*/
struct HiAppEvent_AppEventGroup {
/* The name of the event. */
const char* name;
/* The event array which is group by the name. */
const struct HiAppEvent_AppEventInfo* appEventInfos;
/* The length of appEventInfos array. */
uint32_t infoLen;
};
/**
* @brief Event param list node.
*
@ -115,6 +149,50 @@ enum EventType {
*/
typedef struct ParamListNode* ParamList;
/**
* @brief HiAppEvent_Watcher node.
*
* @syscap SystemCapability.HiviewDFX.HiAppEvent
* @since 12
* @version 1.0
*/
typedef struct HiAppEvent_Watcher HiAppEvent_Watcher;
/**
* @brief Called when watcher receive the event.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param domain The domain of the event.
* @param appEventGroups The event group by the domain.
* @param groupLen The length of appEventGroups array.
* @since 12
* @version 1.0
*/
typedef void (*OH_HiAppEvent_OnReceive)(
const char* domain, const struct HiAppEvent_AppEventGroup* appEventGroups, uint32_t groupLen);
/**
* @brief Called when watcher receive the event meet the condition.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param row The row of events received by watcher.
* @param size The size of events received by watcher.
* @since 12
* @version 1.0
*/
typedef void (*OH_HiAppEvent_OnTrigger)(int32_t row, int32_t size);
/**
* @brief Called when watcher take the events.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param events The event json string array.
* @param eventLen The length of events array.
* @since 12
* @version 1.0
*/
typedef void (*OH_HiAppEvent_OnTake)(const char* const *events, int32_t eventLen);
/**
* @brief Create a pointer to the ParamList.
*
@ -367,6 +445,132 @@ int OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType typ
*/
bool OH_HiAppEvent_Configure(const char* name, const char* value);
/**
* @brief Create a HiAppEvent_Watcher handler pointer to set the property.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param name The name of the watcher.
* @return Returns a pointer to the HiAppEvent_Watcher instance.
* @since 12
* @version 1.0
*/
HiAppEvent_Watcher* OH_HiAppEvent_CreateWatcher(const char* name);
/**
* @brief Destroy the specified HiAppEvent_Watcher handle resource.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @since 12
* @version 1.0
*/
void OH_HiAppEvent_DestroyWatcher(HiAppEvent_Watcher* watcher);
/**
* @brief Set the TriggerCondition to trigger the onTrigger callback.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @param row The row of write events that trigger the onTrigger callback.
* @param size The size of write events that trigger the onTrigger callback.
* @param timeOut The interval for trigger the onTrigger callback.
* @return Returns {@code 0} if set TriggerCondition is successful, and returns a
* negative integer if set fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_SetTriggerCondition(HiAppEvent_Watcher* watcher, uint32_t row, uint32_t size, uint32_t timeOut);
/**
* @brief Set the AppEventFilter, which is used to filter events monitored by the watcher.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @param domain The name of the event domain to be monitored by the watcher..
* @param eventTypes The types of the events to be monitored by the watcher.0x08 means BEHAVIOR,0x04 means
* SECURITY, 0x02 means STATISTIC,0x01 means FAULT, 0xff and 0x00 means all.
* @param names The names of the events to be monitored by the watcher.
* @param namesLen The length of names array.
* @return Returns {@code 0} if set AppEventFilter is successful, and returns a
* negative integer if set fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_SetAppEventFilter(HiAppEvent_Watcher* watcher, const char* domain, uint8_t eventTypes,
const char* const *names, int namesLen);
/**
* @brief Set the onTrigger callback.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @param onTrigger The callback of the watcher.
* @return Returns {@code 0} if set OnTrigger is successful, and returns a
* negative integer if set fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_SetWatcherOnTrigger(HiAppEvent_Watcher* watcher, OH_HiAppEvent_OnTrigger onTrigger);
/**
* @brief Set the OnReceive callback.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @param onReceive The callback of the watcher.
* @return Returns {@code 0} if set OnReceive is successful, and returns a
* negative integer if set fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_SetWatcherOnReceive(HiAppEvent_Watcher* watcher, OH_HiAppEvent_OnReceive onReceive);
/**
* @brief Set the AppEventFilter, which is used to filter events monitored by the watcher.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @param size The the threshold size per read.
* @param onTake The callback of the watcher.
* @return Returns {@code 0} if remove watcher is successful, and returns a
* negative integer if remove fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_TakeWatcherData(HiAppEvent_Watcher* watcher, uint32_t size, OH_HiAppEvent_OnTake onTake);
/**
* @brief Add watcher to receive the event.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance which receive the event.
* @return Returns {@code 0} if add watcher is successful, and returns a
* negative integer if add fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_AddWatcher(HiAppEvent_Watcher* watcher);
/**
* @brief Remove watcher.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @param watcher The pointer to the HiAppEvent_Watcher instance.
* @return Returns {@code 0} if remove watcher is successful, and returns a
* negative integer if remove fail.
* @since 12
* @version 1.0
*/
int OH_HiAppEvent_RemoveWatcher(HiAppEvent_Watcher* watcher);
/**
* @brief Clear all local logging data of the application.
*
* @SystemCapability.HiviewDFX.HiAppEvent
* @since 12
* @version 1.0
*/
void OH_HiAppEvent_ClearData();
#ifdef __cplusplus
}
#endif

View File

@ -79,6 +79,70 @@ extern "C" {
*/
#define EVENT_DISTRIBUTED_SERVICE_START "hiappevent.distributed_service_start"
/**
* @brief app crash event.
*
* @since 12
* @version 1.0
*/
#define EVENT_APP_CRASH "APP_CRASH"
/**
* @brief app freeze event.
*
* @since 12
* @version 1.0
*/
#define EVENT_APP_FREEZE "APP_FREEZE"
/**
* @brief app launch event.
*
* @since 12
* @version 1.0
*/
#define EVENT_APP_LAUNCH "APP_LAUNCH"
/**
* @brief app scroll jank event.
*
* @since 12
* @version 1.0
*/
#define EVENT_SCROLL_JANK "SCROLL_JANK"
/**
* @brief app cpu usage high event.
*
* @since 12
* @version 1.0
*/
#define EVENT_CPU_USAGE_HIGH "CPU_USAGE_HIGH"
/**
* @brief app battery usage event.
*
* @since 12
* @version 1.0
*/
#define EVENT_BATTERY_USAGE "BATTERY_USAGE"
/**
* @brief app resource overlimit event.
*
* @since 12
* @version 1.0
*/
#define EVENT_RESOURCE_OVERLIMIT "RESOURCE_OVERLIMIT"
/**
* @brief OS domain.
*
* @since 12
* @version 1.0
*/
#define DOMAIN_OS "OS"
#ifdef __cplusplus
}
#endif