diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index b7106bf6f4ea8d0b0dab99470c598d42edfd9970..5df286d2676a52bb60d097feb926e00b2f2525b2 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -21,34 +21,34 @@ Before subscribing to system events, you need to configure HiSysEvent logging. F ### Available APIs -**Table 1** EventListener APIs +**Table 1** Description of EventListener APIs -| API| Description| +| Name| Description | | -------- | --------- | -|bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBackBase> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments: Return value:| -|bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBackBase> listener)|Removes the listener for system events.

Input argument: Return value:
  None.| +|bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments: Return value:| +|bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener)|Removes the listener for system events.

Input arguments: Return value:
None.| **Table 2** Description of ListenerRule -| API| Description| +| API| Description | | -------- | --------- | -|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:| -|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments: | -|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:| +|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:| +|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments: | +|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:| **Table 3** Description of RuleType -| Enum| Description| +| Value | Description | | ------------ | ------------- | -| WHOLE_WORD | Whole word matching| -| PREFIX | Prefix matching| -| REGULAR | Regular expression matching| +| WHOLE_WORD | Whole word matching | +| PREFIX | Prefix matching | +| REGULAR | Regular expression matching | -**Table 4** Description of HiSysEventSubscribeCallBackBase +**Table 4** Description of HiSysEventSubscribeCallBack -| API| Description| +| API| Description | | -------- | --------- | -|void HiSysEventSubscribeCallBackBase::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments: Return value:
  None.| +|void HiSysEventSubscribeCallBack::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments: Return value:
None.| ### Development Example @@ -66,16 +66,16 @@ C++ #include - class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBackNative { + class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBack { public: - explicit DemoListener() : HiSysEventSubscribeCallBackNative() {} + explicit DemoListener() : HiSysEventSubscribeCallBack() {} void OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail); virtual ~DemoListener() {} void OnServiceDied(); }; - #endif DEMO_LISTENER_H + #endif // DEMO_LISTENER_H ``` Create the **DemoListener.cpp** file, and add the implementation logic of the custom event callback API in the **DemoListener** class. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 03660c682780e822f41b93dd8394d480ddfa3994..8401862dae6b3bcdf4824334889bb9f6d28a37b6 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -13,16 +13,16 @@ HiSysEvent provides an API for you to query system events. You can query concern ### Available APIs -**Table 1** HiSysEvent query API +**Table 1** Description of the HiSysEvent query API -| API| Description| +| Name| Description | | -------- | --------- | -| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBackBase> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:Return value: | +| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:Return value: | **Table 2** Description of QueryArg -| Attribute| Description| +| Attribute| Description | | -------- | --------- | | beginTime | Start time, in the **long long int** format.| | endTime | End time, in the **long long int** format.| @@ -30,16 +30,16 @@ HiSysEvent provides an API for you to query system events. You can query concern **Table 3** Description of QueryRule -| API| Description| +| API| Description | | -------- | --------- | -| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object based on domain and event name list.

Input arguments: | +| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object.

Input arguments: | -**Table 4** Description of HiSysEventQueryCallBackBase +**Table 4** Description of HiSysEventQueryCallBack -| API| Description| +| API| Description | | -------- | --------- | -| void HiSysEventQueryCallBackBase::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:Return value:
  None.| -| void HiSysEventQueryCallBackBase::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:Return value:
  None.| +| void HiSysEventQueryCallBack::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:Return value:
None.| +| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:Return value:
None.| ### Development Example @@ -53,13 +53,13 @@ C++ - Implement the callback API. - void HiSysEventQueryCallBackBase::OnQuery\(const ::std::vector& sysEvent, const ::std::vector& seq\) + void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string>& sysEvent, const ::std::vector& seq\) - void HiSysEventQueryCallBackBase::OnComplete\(int32\_t reason, int32\_t total\) + void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) - Invoke the query API in the corresponding service logic. - HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) + HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) ```