diff --git a/en/application-dev/reference/apis/js-apis-hichecker.md b/en/application-dev/reference/apis/js-apis-hichecker.md index eef977c21d3d9248d28961a7eebe482769573119..d22899779e9791f098effbc5185b811b969fc98a 100644 --- a/en/application-dev/reference/apis/js-apis-hichecker.md +++ b/en/application-dev/reference/apis/js-apis-hichecker.md @@ -1,17 +1,19 @@ # HiChecker -> **NOTE** +HiChecker 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. + +> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import -``` +```js import hichecker from '@ohos.hichecker'; ``` -## Constants +## Constant Provides the constants of all rule types. @@ -19,16 +21,15 @@ Provides the constants of all rule types. | Name | Type| Description | | ---------------------------------- | -------- | ------------------------------------------------------ | -| RULE\_CAUTION\_PRINT\_LOG | BigInt | Alarm rule, which is programmed to print a log when an alarm is generated. | -| RULE\_CAUTION\_TRIGGER\_CRASH | BigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. | -| RULE\_THREAD\_CHECK\_SLOW\_PROCESS | BigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. | -| RULE\_CHECK\_SLOW\_EVENT | BigInt | Caution rule, which is programmed to detect whether the event distribution or processing time has exceeded the specified time threshold.| -| RULE\_CHECK\_ABILITY\_CONNECTION\_LEAK| BigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. | +| RULE_CAUTION_PRINT_LOG | bigInt | Alarm rule, which is programmed to print a log when an alarm is generated. | +| RULE_CAUTION_TRIGGER_CRASH | bigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. | +| RULE_THREAD_CHECK_SLOW_PROCESS | bigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. | +| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. | ## hichecker.addRule -addRule(rule: BigInt): void +addRule(rule: bigInt): void Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules. @@ -38,11 +39,11 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be added.| +| rule | bigInt | Yes | Rule to be added.| **Example** -``` +```js // Add a rule. hichecker.addRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -53,7 +54,7 @@ hichecker.addRule( ## hichecker.removeRule -removeRule(rule: BigInt): void +removeRule(rule: bigInt): void Removes one or more rules. The removed rules will become ineffective. @@ -63,11 +64,11 @@ Removes one or more rules. The removed rules will become ineffective. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be removed.| +| rule | bigInt | Yes | Rule to be removed.| **Example** -``` +```js // Remove a rule. hichecker.removeRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -78,7 +79,7 @@ hichecker.removeRule( ## hichecker.getRule -getRule(): BigInt +getRule(): bigInt Obtains a collection of thread, process, and alarm rules that have been added. @@ -88,21 +89,21 @@ Obtains a collection of thread, process, and alarm rules that have been added. | Type | Description | | ------ | ---------------------- | -| BigInt | Collection of added rules.| +| bigInt | Collection of added rules.| **Example** -``` +```js // Add a rule. hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Obtain the collection of added rules. -hichecker.getRule(); // Return 1n. +hichecker.getRule(); // return 1n; ``` ## hichecker.contains -contains(rule: BigInt): boolean +contains(rule: bigInt): boolean Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread. @@ -112,7 +113,7 @@ Checks whether the specified rule exists in the collection of added rules. If th | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be checked.| +| rule | bigInt | Yes | Rule to be checked.| **Return value** @@ -122,11 +123,11 @@ Checks whether the specified rule exists in the collection of added rules. If th **Example** -``` +```js // Add a rule. hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Check whether the added rule exists in the collection of added rules. -hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Return true. -hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // Return false. +hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; +hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // return false; ``` diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index e874588b5e209f5386a34c4fc8e10f2b5fc6aef0..ddfd8217c499a5686cd4629f50fb70b759d8df33 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -12,7 +12,7 @@ import sms from '@ohos.telephony.sms'; ## sms.createMessage -createMessage\(pdu: Array, specification: string, callback: AsyncCallback\): void +createMessage\(pdu: Array<number>, specification: string, callback: AsyncCallback\): void Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This API uses an asynchronous callback to return the result. @@ -40,7 +40,7 @@ sms.createMessage(pdu, specification, (err, data) => { ## sms.createMessage -createMessage\(pdu: Array, specification: string\): Promise +createMessage\(pdu: Array<number>, specification: string\): Promise Creates an SMS message instance based on the PDU and the specified SMS protocol. This API uses a promise to return the result. @@ -110,7 +110,7 @@ sms.sendMessage(options); ## sms.getDefaultSmsSlotId7+ -getDefaultSmsSlotId\(callback: AsyncCallback\): void +getDefaultSmsSlotId\(callback: AsyncCallback<number>\): void Obtains the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. @@ -133,7 +133,7 @@ sms.getDefaultSmsSlotId((err, data) => { ## sms.getDefaultSmsSlotId7+ -getDefaultSmsSlotId\(\): Promise +getDefaultSmsSlotId\(\): Promise<number> Obtains the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result. @@ -143,7 +143,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use | Type | Description | | --------------- | ------------------------------------------------------------ | -| Promise | Promise used to return the result.
- **0**: card slot 1
- **1**: card slot 2| +| Promise<number> | Promise used to return the result.
- **0**: card slot 1
- **1**: card slot 2| **Example**