1# HiChecker 2 3- [Introduction](#section11660541593) 4- [Architecture](#section161941989596) 5- [Directory Structure](#section14197309111) 6- [Usage](#section1371113476307) 7- [Repositories Involved](#section1371113476310) 8 9## Introduction<a name="section11660541593"></a> 10 11HiChecker is provided for you to check issues that may be easily ignored during development of OpenHarmony applications (including system-built and third-party applications). Such issues include calling of time-consuming functions by key application threads, event distribution and execution timeout in application processes, and ability resource leakage in application processes. The issues are recorded in logs or lead to process crashes explicitly so that you can find and rectify them. 12 13## Architecture<a name="section161941989596"></a> 14 15 <img src="./figures/HiChecker_architecture.png" style="zoom:100%;" /> 16 17| Dependent Component | Dependency Description | 18| ----------------------------------------------------------- | ------------------------------------------------------------ | 19| Multimedia subsystem: ImagePacker | Invokes the HiChecker API in time-consuming functions to display a notification with the preset prompt message.| 20| Ability subsystem: FeatureAbility| Provides registration for resource leakage detection and notification of the detection results. | 21 22Supported features: 23 24- Time-consuming function call detection 25- Ability leakage detection 26- Addition and removal of check rules 27- Addition and removal of caution rules for logs (default) and app crashes 28- When related detection conditions are met, unwinding of Native stacks to the key trigger point is supported. JS stack unwinding is not supported currently. 29 30## Directory Structure<a name="section14197309111"></a> 31 32``` 33/base/hiviewdfx/hichecker 34├── frameworks # Framework code 35│ └── native # HiChecker Native implementation code 36├── interfaces # APIs 37│ └── native # C++ APIs 38│ └── innerkits # APIs provided for internal subsystems 39| └── js # JS APIs 40│ └── kits # APIs provided for applications 41├── test # Test cases 42│ └── unittest 43``` 44 45 46 47## Usage<a name="section1371113476307"></a> 48### Available APIs 49 50The following table lists the APIs provided by HiChecker. 51 52| Class | API | Description | 53| --------- | :-------------------------------------------------- | -------------------------- | 54| HiChecker | BigInt RULE_CAUTION_PRINT_LOG = 1<<63; | Defines a caution rule, which is programmed to print a log when an alarm is generated. | 55| | BigInt RULE_CAUTION_TRIGGER_CRASH = 1<<62; | Defines a caution rule, which is programmed to force an application to exit when an alarm is generated. | 56| | BigInt RULE_THREAD_CHECK_SLOW_PROCESS = 1; | Defines a check rule, which is programmed to check whether any time-consuming function is called.| 57| | BigInt RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33; | Defines a check rule, which is programmed to check ability leakage. | 58| | BigInt RULE_CHECK_ARKUI_PERFORMANCE = 1<<34; | Defines a check rule, which is programmed to check Arkui performance detection. | 59| | addRule(BigInt rule) : void | Adds one or more rules. | 60| | removeRule(BigInt rule) : void | Removes one or more rules. | 61| | getRule() : BigInt | Obtains all rules. | 62| | contains(BigInt rule) : boolean | Checks whether a rule exists. | 63| | NotifySlowProcess(std::string) : void | Sends a notification of a time-consuming function call. | 64| | NotifySlowEvent(std::string) : void | Sends a notification of a time-consuming function call event. | 65| | NotifyAbilityConnectionLeak(Caution caution) : void | Sends a notification of ability leakage. | 66| | NotifyCaution(uint64_t rule, const std::string& tag, Caution& caution) : void | Common APIs for Rule Detection | 67| Caution | GetTriggerRule() : BigInt | Obtains the rule that triggers the current alarm.| 68| | GetCustomMessage() : String | Obtains the alarm message. | 69| | GetStackTrace() : String | Obtains stack information. | 70 71## Repositories Involved<a name="section1371113476310"></a> 72 73[DFX Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md) 74 75[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README.md) 76 77[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md) 78