diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md new file mode 100644 index 0000000000000000000000000000000000000000..9c534aae3b5dee1be7890153cd9eba768d770a64 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -0,0 +1,98 @@ +# Thermal Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 + +``` +import thermal from '@ohos.thermal'; +``` + + +## ThermalLevel + +Represents the thermal level. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| COOL | 0 | The device is cool, and services are not restricted.| +| NORMAL | 1 | The device is operational but is not cool. You need to pay attention to its heating.| +| WARM | 2 | The device is warm. You need to stop or delay some imperceptible services.| +| HOT | 3 | The device is heating up. You need to stop all imperceptible services and downgrade or reduce the load of other services.| +| OVERHEATED | 4 | The device is overheated. You need to stop all imperceptible services and downgrade or reduce the load of major services.| +| WARNING | 5 | The device is overheated and is about to enter the emergency state. You need to stop all imperceptible services and downgrade major services to the maximum extent.| +| EMERGENCY | 6 | The device has entered the emergency state. You need to stop all services except those for the emergency help purposes.| + + +## thermal.subscribeThermalLevel + +subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void + +Subscribes to thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<ThermalLevel> | Yes| Callback used to obtain the return value.
Return value: thermal level| + +**Example** + +``` +thermal.subscribeThermalLevel((lev) => { + console.info("Thermal level is: " + lev); +}) +``` + +## thermal.unsubscribeThermalLevel + +unsubscribeThermalLevel(callback?: AsyncCallback): void + +Unsubscribes from thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | No| Callback without a return value.| + +**Example** + +``` +thermal.unsubscribeThermalLevel(() => { + console.info("Unsubscribe completed."); +}); +``` + +## thermal.getThermalLevel + +getThermalLevel(): ThermalLevel + +Obtains the current thermal level. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Return value** + +| Type| Description| +| -------- | -------- | +| ThermalLevel | Thermal level obtained.| + +**Example** + +``` +var lev = thermal.getThermalLevel(); +console.info("Thermal level is: " + lev); +```