139baaf62Sopenharmony_ci# HiChecker组件
239baaf62Sopenharmony_ci
339baaf62Sopenharmony_ci-   [简介](#section11660541593)
439baaf62Sopenharmony_ci-   [架构](#section161941989596)
539baaf62Sopenharmony_ci-   [目录](#section14197309111)
639baaf62Sopenharmony_ci-   [说明](#section1371113476307)
739baaf62Sopenharmony_ci-   [涉及仓](#section1371113476310)
839baaf62Sopenharmony_ci
939baaf62Sopenharmony_ci## 简介<a name="section11660541593"></a>
1039baaf62Sopenharmony_ci
1139baaf62Sopenharmony_ciHiChecker,可以作为应用开发阶段使用的检测工具,用于检测代码运行过程中部分易忽略的问题,如应用线程出现耗时调用、应用进程中元能力资源泄露等问题。开发者可以通过日志记录或进程crash等形式查看具体问题并进行修改,提升应用的使用体验。
1239baaf62Sopenharmony_ci
1339baaf62Sopenharmony_ci## 架构<a name="section161941989596"></a>
1439baaf62Sopenharmony_ci
1539baaf62Sopenharmony_ci <img src="./figures/HiChecker架构图.png" style="zoom:100%;" />
1639baaf62Sopenharmony_ci
1739baaf62Sopenharmony_ci| 依赖部件                                                    | 依赖描述                                                     |
1839baaf62Sopenharmony_ci| ----------------------------------------------------------- | ------------------------------------------------------------ |
1939baaf62Sopenharmony_ci| 媒体子系统/【image部件】图片基础框架 ImagePacker            | 在比较耗时的函数中调用HiChecker接口,通知有耗时调用,同时传入对应的告警提示字符串 |
2039baaf62Sopenharmony_ci| 元能力子系统/ability_runtime/运行管理支持DFX FeatureAbility | 提供注册泄露检测逻辑,通知检测模式相关结果                   |
2139baaf62Sopenharmony_ci
2239baaf62Sopenharmony_ci支持特性:
2339baaf62Sopenharmony_ci
2439baaf62Sopenharmony_ci- 提供耗时调用检测功能
2539baaf62Sopenharmony_ci- 提供注册(ability) 泄露检测功能
2639baaf62Sopenharmony_ci- 支持应用增加、删除不同的检测规则
2739baaf62Sopenharmony_ci- 支持应用增加、删除不同的告警通知规则,目前支持记录流水日志(默认),应用崩溃两种规则
2839baaf62Sopenharmony_ci- 相关检测条件满足时,支持Native回栈到关键触发点,暂不支持JS回栈
2939baaf62Sopenharmony_ci
3039baaf62Sopenharmony_ci## 目录<a name="section14197309111"></a>
3139baaf62Sopenharmony_ci
3239baaf62Sopenharmony_ci```
3339baaf62Sopenharmony_ci/base/hiviewdfx/hichecker
3439baaf62Sopenharmony_ci├── frameworks          # 框架代码
3539baaf62Sopenharmony_ci│   └── native          # HiChecker native实现代码
3639baaf62Sopenharmony_ci├── interfaces          # 接口
3739baaf62Sopenharmony_ci│   └── native          # C++接口
3839baaf62Sopenharmony_ci│       └── innerkits   # 对内部子系统提供的接口
3939baaf62Sopenharmony_ci|   └── js              # JS接口
4039baaf62Sopenharmony_ci│       └── kits        # 对应用提供的接口
4139baaf62Sopenharmony_ci├── test                # 测试用例
4239baaf62Sopenharmony_ci│   └── unittest            
4339baaf62Sopenharmony_ci```
4439baaf62Sopenharmony_ci
4539baaf62Sopenharmony_ci
4639baaf62Sopenharmony_ci
4739baaf62Sopenharmony_ci## 说明<a name="section1371113476307"></a>
4839baaf62Sopenharmony_ci### 接口说明
4939baaf62Sopenharmony_ci
5039baaf62Sopenharmony_ci主要接口说明
5139baaf62Sopenharmony_ci
5239baaf62Sopenharmony_ci| 类        | 方法                                                | 描述                       |
5339baaf62Sopenharmony_ci| --------- | :-------------------------------------------------- | -------------------------- |
5439baaf62Sopenharmony_ci| HiChecker | BigInt RULE_CAUTION_PRINT_LOG = 1<<63;              | 告警规则,仅记录日志       |
5539baaf62Sopenharmony_ci|           | BigInt RULE_CAUTION_TRIGGER_CRASH = 1<<62;          | 告警规则,让应用退出       |
5639baaf62Sopenharmony_ci|           | BigInt RULE_THREAD_CHECK_SLOW_PROCESS = 1;          | 检测规则,检测耗时函数调用 |
5739baaf62Sopenharmony_ci|           | BigInt RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33;  | 检测规则,检测ability泄露  |
5839baaf62Sopenharmony_ci|           | BigInt RULE_CHECK_ARKUI_PERFORMANCE = 1<<34;        | 检测规则,用于arkui性能检测  |
5939baaf62Sopenharmony_ci|           | addRule(BigInt rule) : void                         | 增加一个或多个检测项       |
6039baaf62Sopenharmony_ci|           | removeRule(BigInt rule) : void                      | 删除一个或多个检测项       |
6139baaf62Sopenharmony_ci|           | getRule() : BigInt                                  | 获取所有检测项             |
6239baaf62Sopenharmony_ci|           | contains(BigInt rule) : boolean                     | 当前是否有某一个检测项     |
6339baaf62Sopenharmony_ci|           | NotifySlowProcess(std::string) : void               | 通知有耗时调用             |
6439baaf62Sopenharmony_ci|           | NotifySlowEvent(std::string) : void                 | 通知有耗时事件             |
6539baaf62Sopenharmony_ci|           | NotifyAbilityConnectionLeak(Caution caution) : void | 通知有ability泄露          |
6639baaf62Sopenharmony_ci|           | NotifyCaution(uint64_t rule, const std::string& tag, Caution& caution) : void | 规则检测通用接口 |
6739baaf62Sopenharmony_ci| Caution   | GetTriggerRule() : BigInt                           | 获取触发当前告警的检测规则 |
6839baaf62Sopenharmony_ci|           | GetCustomMessage() : String                         | 获取更多辅助信息           |
6939baaf62Sopenharmony_ci|           | GetStackTrace() :String                            | 获取堆栈信息               |
7039baaf62Sopenharmony_ci
7139baaf62Sopenharmony_ci## 涉及仓<a name="section1371113476310"></a>
7239baaf62Sopenharmony_ci
7339baaf62Sopenharmony_ci[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX子系统.md)
7439baaf62Sopenharmony_ci
7539baaf62Sopenharmony_ci[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README_zh.md)
7639baaf62Sopenharmony_ci
7739baaf62Sopenharmony_ci[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README_zh.md)
78