Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5d00e377
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5d00e377
编写于
3月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2641 make_shared规范性整改
Merge pull request !2641 from honghecun/master
上级
b79f97ec
d33e91dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
32 deletion
+60
-32
en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
+19
-12
en/device-dev/subsystems/subsys-dfx-hisysevent-query.md
en/device-dev/subsystems/subsys-dfx-hisysevent-query.md
+11
-4
zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
.../device-dev/subsystems/subsys-dfx-hisysevent-listening.md
+19
-12
zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
+11
-4
未找到文件。
en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
浏览文件 @
5d00e377
...
@@ -101,18 +101,25 @@ C++
...
@@ -101,18 +101,25 @@ C++
Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events.
Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events.
```
```
auto demoListener = std::make_shared<DemoListener>();
std::shared_ptr<DemoListener> demoListener = nullptr;
// Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD).
try {
ListenerRule tagRule("dfx");
demoListener = std::make_shared<DemoListener>();
// Add a ListenerRule object based on the event tag, with RuleType set as REGULAR.
} catch(...) {
ListenerRule regRule("dfx.*", RuleType::REGULAR);
// Catch exception thrown by make_shared
// Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX.
}
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
if (demoListener != nullptr) {
std::vector<ListenerRule> sysRules;
// Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD).
sysRules.push_back(tagRule);
ListenerRule tagRule("dfx");
sysRules.push_back(regRule);
// Add a ListenerRule object based on the event tag, with RuleType set as REGULAR.
sysRules.push_back(domainNameRule);
ListenerRule regRule("dfx.*", RuleType::REGULAR);
HiSysEventManager::AddEventListener(demoListener, sysRules);
// Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX.
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
std::vector<ListenerRule> sysRules;
sysRules.push_back(tagRule);
sysRules.push_back(regRule);
sysRules.push_back(domainNameRule);
HiSysEventManager::AddEventListener(demoListener, sysRules);
}
```
```
2.
Configure the
**BUILD.gn**
file.
2.
Configure the
**BUILD.gn**
file.
...
...
en/device-dev/subsystems/subsys-dfx-hisysevent-query.md
浏览文件 @
5d00e377
...
@@ -86,10 +86,17 @@ C++
...
@@ -86,10 +86,17 @@ C++
} // namespace OHOS
} // namespace OHOS
// Invoke the query callback API to obtain system events.
// Invoke the query callback API to obtain system events.
auto queryCallBack = std::make_shared<HiSysEventToolQuery>();
std::shared_ptr<HiSysEventToolQuery> queryCallBack = nullptr;
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
try {
std::vector<QueryRule> mRules;
queryCallBack = std::make_shared<HiSysEventToolQuery>();
HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack);
} catch(...) {
// Catch exception thrown by make_shared
}
if (queryCallBack != nullptr) {
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
std::vector<QueryRule> rules;
HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack);
}
```
```
2.
Modify the
**BUILD.gn**
file.
2.
Modify the
**BUILD.gn**
file.
...
...
zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
浏览文件 @
5d00e377
...
@@ -103,18 +103,25 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接
...
@@ -103,18 +103,25 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接
通过HiSysEventManager类提供的AddEventListener接口注册回调对象,完成对HiSysEvent的订阅:
通过HiSysEventManager类提供的AddEventListener接口注册回调对象,完成对HiSysEvent的订阅:
```
```
auto demoListener = std::make_shared<DemoListener>();
std::shared_ptr<DemoListener> demoListener = nullptr;
// 事件标签规则订阅,规则类型为默认的全词匹配类型
try {
ListenerRule tagRule("dfx");
demoListener = std::make_shared<DemoListener>();
// 事件标签规则订阅,规则类型为正则匹配类型
} catch(...) {
ListenerRule regRule("dfx.*", RuleType::REGULAR);
// 智能指针获取失败异常处理
// 事件领域及事件名称规则订阅,规则类型为前缀匹配类型
}
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
if (demoListener != nullptr) {
std::vector<ListenerRule> sysRules;
// 事件标签规则订阅,规则类型为默认的全词匹配类型
sysRules.push_back(tagRule);
ListenerRule tagRule("dfx");
sysRules.push_back(regRule);
// 事件标签规则订阅,规则类型为正则匹配类型
sysRules.push_back(domainNameRule);
ListenerRule regRule("dfx.*", RuleType::REGULAR);
HiSysEventManager::AddEventListener(demoListener, sysRules);
// 事件领域及事件名称规则订阅,规则类型为前缀匹配类型
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
std::vector<ListenerRule> sysRules;
sysRules.push_back(tagRule);
sysRules.push_back(regRule);
sysRules.push_back(domainNameRule);
HiSysEventManager::AddEventListener(demoListener, sysRules);
}
```
```
2.
编译配置
2.
编译配置
...
...
zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
浏览文件 @
5d00e377
...
@@ -86,10 +86,17 @@ C++接口实例。
...
@@ -86,10 +86,17 @@ C++接口实例。
} // namespace OHOS
} // namespace OHOS
// 调用查询接口获取HiSysEvent事件
// 调用查询接口获取HiSysEvent事件
auto queryCallBack = std::make_shared<HiSysEventToolQuery>();
std::shared_ptr<HiSysEventToolQuery> queryCallBack = nullptr;
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
try {
std::vector<QueryRule> mRules;
queryCallBack = std::make_shared<HiSysEventToolQuery>();
HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack);
} catch (...) {
// 智能指针获取失败处理
}
if (queryCallBack != nullptr) {
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
std::vector<QueryRule> rules;
HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack);
}
```
```
2.
编译设置:
2.
编译设置:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录