diff --git a/en/application-dev/reference/apis/js-apis-battery-info.md b/en/application-dev/reference/apis/js-apis-battery-info.md
index 2d7e9fab8a62e7d68dae92e66359a2704414bc01..197e25cfce48edc49798b438745adc13c35ab9d5 100644
--- a/en/application-dev/reference/apis/js-apis-battery-info.md
+++ b/en/application-dev/reference/apis/js-apis-battery-info.md
@@ -1,11 +1,10 @@
# Battery Info
->**NOTE**
->
->The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
The Battery Info module provides APIs for querying the charger type, battery health status, and battery charging status.
+> **NOTE**
+> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
## Modules to Import
@@ -13,67 +12,100 @@ The Battery Info module provides APIs for querying the charger type, battery hea
import batteryInfo from '@ohos.batteryInfo';
```
-## System Capabilities
-
-SystemCapability.PowerManager.BatteryManager
-
## Attributes
Describes battery information.
-| Name | Type | Readable | Writable | Description |
-| ----------------------------- | ----------------------------------------- | -------- | -------- | ------------------------------------------------------------ |
-| batterySOC | number | Yes | No | Battery state of charge (SoC) of the current device, in unit of percentage. |
-| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the current device. |
-| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the current device. |
-| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the current device. |
-| voltage | number | Yes | No | Battery voltage of the current device, in unit of microvolt. |
-| technology | string | Yes | No | Battery technology of the current device. |
-| batteryTemperature | number | Yes | No | Battery temperature of the current device, in unit of 0.1°C. |
-| isBatteryPresent7+ | boolean | Yes | No | Whether the battery is supported or present. |
-
-**Example**
-
-```js
-import batteryInfo from '@ohos.batteryInfo';
-var batterySoc = batteryInfo.batterySOC;
-```
-
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+
+| Name | Type | Readable| Writable| Description |
+| --------------- | ------------------- | ---- | ---- | ---------------------|
+| batterySOC | number | Yes | No | Battery state of charge (SoC) of the device, in unit of percentage. |
+| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the device. |
+| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the device. |
+| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the device. |
+| voltage | number | Yes | No | Battery voltage of the device, in unit of microvolt. |
+| technology | string | Yes | No | Battery technology of the device. |
+| batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. |
+| isBatteryPresent7+ | boolean | Yes | No | Whether the battery is supported or present. |
+| batteryCapacityLevel9+ | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. |
+| estimatedRemainingChargeTime9+ | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. |
+| totalEnergy9+ | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. |
+| nowCurrent9+ | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. |
+| remainingEnergy9+ | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.|
## BatteryPluggedType
Enumerates charger types.
-| Name | Default Value | Description |
-| -------- | ------------- | ----------------- |
-| NONE | 0 | Unknown type. |
-| AC | 1 | AC charger. |
-| USB | 2 | USB charger. |
-| WIRELESS | 3 | Wireless charger. |
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+| Name | Value | Description |
+| -------- | ---- | ----------------- |
+| NONE | 0 | Unknown type |
+| AC | 1 | AC charger|
+| USB | 2 | USB charger |
+| WIRELESS | 3 | Wireless charger|
## BatteryChargeState
Enumerates charging states.
-| Name | Default Value | Description |
-| ------- | ------------- | --------------------------------- |
-| NONE | 0 | Unknown state. |
-| ENABLE | 1 | The battery is being charged. |
-| DISABLE | 2 | The battery is not being charged. |
-| FULL | 3 | The battery is fully charged. |
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+| Name | Value | Description |
+| ------- | ---- | --------------- |
+| NONE | 0 | Unknown state. |
+| ENABLE | 1 | The battery is being charged. |
+| DISABLE | 2 | The battery is not being charged. |
+| FULL | 3 | The battery is fully charged.|
## BatteryHealthState
Enumerates battery health states.
-| Name | Default Value | Description |
-| ----------- | ------------- | ------------------------------------ |
-| UNKNOWN | 0 | Unknown state. |
-| GOOD | 1 | The battery is in the healthy state. |
-| OVERHEAT | 2 | The battery is overheated. |
-| OVERVOLTAGE | 3 | The battery voltage is over high. |
-| COLD | 4 | The battery temperature is low. |
-| DEAD | 5 | The battery is dead. |
-
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+
+| Name | Value | Description |
+| ----------- | ---- | -------------- |
+| UNKNOWN | 0 | Unknown state. |
+| GOOD | 1 | The battery is in the healthy state. |
+| OVERHEAT | 2 | The battery is overheated. |
+| OVERVOLTAGE | 3 | The battery voltage is over high. |
+| COLD | 4 | The battery temperature is low. |
+| DEAD | 5 | The battery is dead.|
+
+## BatteryCapacityLevel9+
+
+Enumerates battery levels.
+
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+
+| Name | Value| Description |
+| -------------- | ------ | ---------------------------- |
+| LEVEL_NONE | 0 | Unknown battery level. |
+| LEVEL_FULL | 1 | Full battery level. |
+| LEVEL_HIGH | 2 | High battery level. |
+| LEVEL_NORMAL | 3 | Normal battery level.|
+| LEVEL_LOW | 4 | Low battery level. |
+| LEVEL_CRITICAL | 5 | Ultra-low battery level.|
+
+## CommonEventBatteryChangedCode9+
+
+Enumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event.
+
+**System capability**: SystemCapability.PowerManager.BatteryManager.Core
+
+| Name | Value| Description |
+| -------------------- | ------ | -------------------------------------------------- |
+| EXTRA_SOC | 0 | Remaining battery level in percentage. |
+| EXTRA_VOLTAGE | 1 | Battery voltage of the device. |
+| EXTRA_TEMPERATURE | 2 | Battery temperature of the device. |
+| EXTRA_HEALTH_STATE | 3 | Battery health status of the device. |
+| EXTRA_PLUGGED_TYPE | 4 | Type of the charger connected to the device. |
+| EXTRA_MAX_CURRENT | 5 | Maximum battery current of the device. |
+| EXTRA_MAX_VOLTAGE | 6 | Maximum battery voltage of the device. |
+| EXTRA_CHARGE_STATE | 7 | Battery charging status of the device. |
+| EXTRA_CHARGE_COUNTER | 8 | Number of battery charging times of the device. |
+| EXTRA_PRESENT | 9 | Whether the battery is supported by the device or installed.|
+| EXTRA_TECHNOLOGY | 10 | Battery technology of the device. |
diff --git a/en/application-dev/reference/apis/js-apis-batteryStatistics.md b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
new file mode 100644
index 0000000000000000000000000000000000000000..917bc81d2f3eecef3f25d609db686b0d9dae44a2
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
@@ -0,0 +1,287 @@
+# Battery Statistics
+
+This module provides APIs for querying software and hardware power consumption statistics.
+
+> **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.
+>
+> - The APIs provided by this module are system APIs.
+
+## Modules to Import
+
+```js
+import batteryStats from '@ohos.batteryStatistics';
+```
+
+## batteryStats.getBatteryStats
+
+getBatteryStats(): Promise
+
+Obtains the power consumption information list, using a promise to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------- | ------------------------------- |
+| Promise> | Promise used to return the power consumption information list.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+batteryStats.getBatteryStats()
+.then(data => {
+ console.info('battery statistics info: ' + data);
+})
+.catch(err => {
+ console.error('get battery statisitics failed, err: ' + err);
+});
+```
+
+## batteryStats.getBatteryStats
+
+getBatteryStats(callback: AsyncCallback): void
+
+Obtains the power consumption information list. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained. If the operation failed, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+batteryStats.getBatteryStats((err, data) => {
+ if (typeof err === 'undefined') {
+ console.info('battery statistics info: ' + data);
+ } else {
+ console.error('get battery statisitics failed, err: ' + err);
+ }
+});
+```
+
+## batteryStats.getAppPowerValue
+
+getAppPowerValue(uid: number): number
+
+Obtains the power consumption of an application.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ----------- |
+| uid | number | Yes | Application UID.|
+
+**Return value**
+
+| Type | Description |
+| ------ | --------------------------------- |
+| number | Power consumption of the application with this UID, in unit of mAh.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var value = batteryStats.getAppPowerValue(10021);
+ console.info('battery statistics value of app is: ' + value);
+} catch(err) {
+ console.error('get battery statisitics value of app failed, err: ' + err);
+}
+```
+
+## batteryStats.getAppPowerPercent
+
+getAppPowerPercent(uid: number): number
+
+Obtains the proportion of the power consumption of an application.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ----------- |
+| uid | number | Yes | Application UID.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------------------- |
+| number | Proportion of the power consumption of an application with this UID.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var percent = batteryStats.getAppPowerPercent(10021);
+ console.info('battery statistics percent of app is: ' + percent);
+} catch(err) {
+ console.error('get battery statisitics percent of app failed, err: ' + err);
+}
+```
+
+## batteryStats.getHardwareUnitPowerValue
+
+getHardwareUnitPowerValue(type: ConsumptionType): number
+
+Obtains the power consumption of a hardware unit according to the consumption type.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | -------------- |
+| type | [ConsumptionType](#consumptiontype) | Yes | Power consumption type.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------------------------------------ |
+| number | Power consumption of the hardware unit corresponding to the power consumption type, in unit of mAh.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var value = batteryStats.getHardwareUnitPowerValue(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
+ console.info('battery statistics percent of hardware is: ' + percent);
+} catch(err) {
+ console.error('get battery statisitics percent of hardware failed, err: ' + err);
+}
+```
+
+## batteryStats.getHardwareUnitPowerPercent
+
+getHardwareUnitPowerPercent(type: ConsumptionType): number
+
+Obtains the proportion of the power consumption of a hardware unit according to the power consumption type.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | -------------- |
+| type | [ConsumptionType](#consumptiontype) | Yes | Power consumption type.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ---------------------------------- |
+| number | Proportion of the power consumption of the hardware unit corresponding to the power consumption type.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
+
+| Code| Error Message |
+| -------- | -------------- |
+| 4600101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var value = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
+ console.info('battery statistics percent of hardware is: ' + percent);
+} catch(err) {
+ console.error('get battery statisitics percent of hardware failed, err: ' + err);
+}
+```
+
+## BatteryStatsInfo
+
+Describes the device power consumption information.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+### Attributes
+
+| Name | Type | Readable| Writable| Description |
+| ----- | ----------------------------------- | ---- | ---- | ---------------------- |
+| uid | number | Yes | No | UID related to power consumption information. |
+| type | [ConsumptionType](#consumptiontype) | Yes | No | Power consumption type. |
+| power | number | Yes | No | Power consumption, in unit of mAh.|
+
+## ConsumptionType
+
+Enumerates power consumption types.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.PowerManager.BatteryStatistics
+
+| Name | Value | Description |
+| -------------------------- | ---- | ----------------------------- |
+| CONSUMPTION_TYPE_INVALID | -17 | Unknown type. |
+| CONSUMPTION_TYPE_APP | -16 | Power consumption of an application. |
+| CONSUMPTION_TYPE_BLUETOOTH | -15 | Power consumption of Bluetooth. |
+| CONSUMPTION_TYPE_IDLE | -14 | Power consumption when the CPU is idle.|
+| CONSUMPTION_TYPE_PHONE | -13 | Power consumption of a phone call. |
+| CONSUMPTION_TYPE_RADIO | -12 | Power consumption of wireless communication. |
+| CONSUMPTION_TYPE_SCREEN | -11 | Power consumption of the screen. |
+| CONSUMPTION_TYPE_USER | -10 | Power consumption of the user. |
+| CONSUMPTION_TYPE_WIFI | -9 | Power consumption of Wi-Fi. |
diff --git a/en/application-dev/reference/apis/js-apis-brightness.md b/en/application-dev/reference/apis/js-apis-brightness.md
index 6bbea8b08a752972bcc9354b63841831ae837a88..df783bbda132f5da29e152e146cc6cb56316f083 100644
--- a/en/application-dev/reference/apis/js-apis-brightness.md
+++ b/en/application-dev/reference/apis/js-apis-brightness.md
@@ -1,10 +1,12 @@
-# Brightness
-
->  **NOTE**
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+# Screen Brightness
The Brightness module provides an API for setting the screen brightness.
+> **NOTE**
+>
+> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> - The APIs provided by this module are system APIs.
## Modules to Import
@@ -18,18 +20,30 @@ setValue(value: number): void
Sets the screen brightness.
-This is a system API and cannot be called by third-party applications.
+**System API**: This is a system API.
-**System capability:** SystemCapability.PowerManager.DisplayPowerManager
+**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----- | ------ | ---- | ----------- |
-| value | number | Yes | Brightness value, ranging from **0** to **255**.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ----------------------- |
+| value | number | Yes | Brightness value. The value ranges from 0 to 255.|
+
+**Error codes**
+
+For details about the error codes, see [Screen Brightness Error Codes](../errorcodes/errorcode-brightness.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4700101 | Operation failed. Cannot connect to service.|
**Example**
```js
-brightness.setValue(128);
+try {
+ brightness.setValue(128);
+} catch(err) {
+ console.error('set brightness failed, err: ' + err);
+}
```
diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md
index ad6e437f09767e362b2787f5ee78dd58d1a65165..1c78452681d08db91a4aa3ee4cf2aea785072191 100644
--- a/en/application-dev/reference/apis/js-apis-power.md
+++ b/en/application-dev/reference/apis/js-apis-power.md
@@ -1,10 +1,9 @@
# Power Manager
->  **NOTE**
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
The Power Manager module provides APIs for rebooting and shutting down the system, as well as querying the screen status.
+> **NOTE**
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -12,42 +11,294 @@ The Power Manager module provides APIs for rebooting and shutting down the syste
import power from '@ohos.power';
```
-## System Capability
-
-SystemCapability.PowerManager.PowerManager.Core
-
+## power.shutdown
-## power.shutdownDevice
-
-shutdownDevice(reason: string): void
+shutdown(reason: string): void
Shuts down the system.
-This is a system API and cannot be called by third-party applications.
+**System API**: This is a system API.
**Required permission**: ohos.permission.REBOOT
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| reason | string | Yes | Reason for system shutdown.|
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
**Example**
```js
-power.shutdownDevice("shutdown_test");
-console.info('power_shutdown_device_test success')
+try {
+ power.shutdown('shutdown_test');
+} catch(err) {
+ console.error('shutdown failed, err: ' + err);
+}
```
+## power.reboot9+
+
+reboot(reason: string): void
+
+Reboots the system.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.REBOOT
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------- |
+| reason | string | Yes | Reason for system reboot.|
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ power.reboot('reboot_test');
+} catch(err) {
+ console.error('reboot failed, err: ' + err);
+}
+```
+
+## power.isActive9+
+
+isActive(): boolean
+
+Checks whether the current device is active.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var isActive = power.isActive();
+ console.info('power is active: ' + isActive);
+} catch(err) {
+ console.error('check active status failed, err: ' + err);
+}
+```
+
+## power.wakeup9+
+
+wakeup(detail: string): void
+
+Wakes up a device.
+
+**System API**: This is a system API.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------- |
+| detail | string | Yes | Reason for wakeup.|
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ power.wakeup('wakeup_test');
+} catch(err) {
+ console.error('wakeup failed, err: ' + err);
+}
+```
+
+## power.suspend9+
+
+suspend(): void
+
+Hibernates a device.
+
+**System API**: This is a system API.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ power.suspend();
+} catch(err) {
+ console.error('suspend failed, err: ' + err);
+}
+```
-## power.rebootDevice
+## power.getPowerMode9+
+
+getPowerMode(): DevicePowerMode
+
+Obtains the power mode of this device.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------ | ---------- |
+| [DevicePowerMode](#devicepowermode9) | Power mode.|
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var mode = power.getPowerMode();
+ console.info('power mode: ' + mode);
+} catch(err) {
+ console.error('get power mode failed, err: ' + err);
+}
+```
+
+## power.setPowerMode9+
+
+setPowerMode(mode: DevicePowerMode, callback: AsyncCallback<void>): void
+
+Sets the power mode of this device. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.POWER_OPTIMIZATION
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
+| mode | [DevicePowerMode](#devicepowermode9) | Yes | Power mode. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the power mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, err => {
+ if (typeof err === 'undefined') {
+ console.info('set power mode to MODE_PERFORMANCE');
+ } else {
+ console.error('set power mode failed, err: ' + err);
+ }
+});
+```
+
+## power.setPowerMode9+
+
+setPowerMode(mode: DevicePowerMode): Promise<void>
+
+Sets the power mode of this device. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.POWER_OPTIMIZATION
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------------------ | ---- | ---------- |
+| mode | [DevicePowerMode](#devicepowermode9) | Yes | Power mode.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | -------------------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE)
+.then(() => {
+ console.info('set power mode to MODE_PERFORMANCE');
+})
+.catch(err => {
+ console.error('set power mode failed, err: ' + err);
+});
+```
+
+## power.rebootDevice(deprecated)
rebootDevice(reason: string): void
+> This API is deprecated since API version 9. You are advised to use [power.reboot](#powerreboot9) instead.
+
Reboots the system.
-**Required permission**: ohos.permission.REBOOT (to reboot) or ohos.permission.REBOOT_RECOVERY (to reboot and enter the recovery or updater mode)
+**Required permission**: ohos.permission.REBOOT
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
@@ -58,55 +309,73 @@ Reboots the system.
**Example**
```js
-power.rebootDevice("reboot_test");
-console.info('power_reboot_device_test success')
+power.rebootDevice('reboot_test');
```
-
-## power.isScreenOn
+## power.isScreenOn(deprecated)
isScreenOn(callback: AsyncCallback<boolean>): void
-Checks the screen status of the current device.
+> This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9) instead.
+
+Checks the screen status of the current device. This API uses an asynchronous callback to return the result.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------- | ---- | ---------------------------------------- |
-| callback | AsyncCallback<boolean> | Yes | Callback used to obtain the return value.
Return value: The value **true** indicates that the screen is on, and the value **false** indicates the opposite.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the screen status obtained, where the value **true** indicates on and the value **false** indicates the opposite. Otherwise, **err** is an error object.|
**Example**
```js
-power.isScreenOn((error, screenOn) => {
- if (typeof error === "undefined") {
- console.info('screenOn status is ' + screenOn);
+power.isScreenOn((err, data) => {
+ if (typeof err === 'undefined') {
+ console.info('screen on status is ' + data);
} else {
- console.log('error: ' + error);
+ console.error('check screen status failed, err: ' + err);
}
})
```
-
-## power.isScreenOn
+## power.isScreenOn(deprecated)
isScreenOn(): Promise<boolean>
-Checks the screen status of the current device.
+> This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9) instead.
+
+Checks the screen status of the current device. This API uses a promise to return the result.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return value**
-| Type | Description |
-| ---------------------- | --------------------------------------- |
-| Promise<boolean> | Promise used to obtain the return value.
Return value: The value **true** indicates that the screen is on, and the value **false** indicates the opposite.|
+| Type | Description |
+| ---------------------- | -------------------------------------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** indicates that the screen is on, and the value **false** indicates the opposite.|
**Example**
```js
power.isScreenOn()
-.then(screenOn => {
- console.info('screenOn status is ' + screenOn);
+.then(data => {
+ console.info('screen on status is ' + data);
})
-.catch(error => {
- console.log('error: ' + error);
+.catch(err => {
+ console.error('check screen status failed, err: ' + err);
})
```
+
+## DevicePowerMode9+
+
+Enumerates power modes.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+| Name | Value | Description |
+| ----------------------- | ---- | ---------------------- |
+| MODE_NORMAL | 600 | Standard mode. It is the default value.|
+| MODE_POWER_SAVE | 601 | Power saving mode. |
+| MODE_PERFORMANCE | 602 | Performance mode. |
+| MODE_EXTREME_POWER_SAVE | 603 | Ultra power saving mode. |
diff --git a/en/application-dev/reference/apis/js-apis-runninglock.md b/en/application-dev/reference/apis/js-apis-runninglock.md
index 1b25989357a2e101b5b6e95d05b5ca60dab2fb6f..e3718c5878ccae3e63f8bdfae8b37061599fffda 100644
--- a/en/application-dev/reference/apis/js-apis-runninglock.md
+++ b/en/application-dev/reference/apis/js-apis-runninglock.md
@@ -1,95 +1,205 @@
-# Running Lock
+# RunningLock
->  **NOTE**
+The RunningLock module provides APIs for creating, querying, holding, and releasing running locks.
+
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-The Running Lock module provides APIs for creating, querying, holding, and releasing running locks.
+## Modules to Import
+```js
+import runningLock from '@ohos.runningLock';
+```
-## Modules to Import
+## runningLock.isSupported9+
+
+isSupported(type: RunningLockType): boolean;
+
+Checks whether a specified type of **RunningLock** is supported.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | -------------------- |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
+
+**Return value**
+
+| Type | Description |
+| ------- | --------------------------------------- |
+| boolean | The value **true** indicates that the specified type of **RunningLock** is supported, and the value **false** indicates the opposite.|
+
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+```js
+try {
+ var isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND);
+ console.info('BACKGROUND type supported: ' + isSupported);
+} catch(err) {
+ console.error('check supported failed, err: ' + err);
+}
```
-import runningLock from '@ohos.runningLock';
+
+## runningLock.create9+
+
+create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
+
+Creates a **RunningLock** object.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Required permission:** ohos.permission.RUNNING_LOCK
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
+| name | string | Yes | Name of the **RunningLock** object. |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created. |
+| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes | Callback used to return the result. If a lock is successfully created, **err** is **undefined** and **data** is the created **RunningLock**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|----------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => {
+ if (typeof err === 'undefined') {
+ console.info('created running lock: ' + lock);
+ } else {
+ console.error('create running lock failed, err: ' + err);
+ }
+});
```
+## runningLock.create9+
-## RunningLockType
+create(name: string, type: RunningLockType): Promise<RunningLock>
-Enumerates the types of **RunningLock** objects.
+Creates a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
-| Name | Default Value | Description |
-| ------------------------ | ---- | ------------------- |
-| BACKGROUND | 1 | A lock that prevents the system from hibernating when the screen is off. |
-| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen.|
+**Required permission:** ohos.permission.RUNNING_LOCK
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | ------------------ |
+| name | string | Yes | Name of the **RunningLock** object. |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------ | ------------------------------------ |
+| Promise<[RunningLock](#runninglock)> | Promise used to return the result.|
-## isRunningLockTypeSupported
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|----------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ console.info('created running lock: ' + lock);
+})
+.catch(err => {
+ console.error('create running lock failed, error: ' + err);
+});
+```
+
+## runningLock.isRunningLockTypeSupported(deprecated)
isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boolean>): void
-Checks whether a specified type of **RunningLock** is supported. This function uses an asynchronous callback to return the result.
+> This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9) instead.
+
+Checks whether a specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------- | ---- | ---------------------------------------- |
-| type | RunningLockType | Yes | Type of the **RunningLock** object. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to obtain the return value.
Return value: The value **true** indicates that the specified type of **RunningLock** is supported, and the value **false** indicates the opposite.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the query result obtained, where the value **true** indicates that **RunningLock** is supported and **false** indicates the opposite. Otherwise, **err** is an error object.|
**Example**
-```
-runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => {
- if (typeof error === "undefined") {
- console.info('BACKGROUND support status is ' + supported);
+```js
+runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err, data) => {
+ if (typeof err === 'undefined') {
+ console.info('BACKGROUND lock support status: ' + data);
} else {
- console.log('error: ' + error);
+ console.log('check BACKGROUND lock support status failed, err: ' + err);
}
-})
+});
```
+## runningLock.isRunningLockTypeSupported(deprecated)
-## isRunningLockTypeSupported
+isRunningLockTypeSupported(type: RunningLockType): Promise<boolean>
-isRunningLockTypeSupported(type: RunningLockType): Promise<boolean>
+> This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9) instead.
-Checks whether a specified type of **RunningLock** is supported. This function uses an asynchronous callback to return the result.
+Checks whether a specified type of **RunningLock** is supported. This API uses a promise to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | --------------- | ---- | ---------- |
-| type | RunningLockType | Yes | Type of the **RunningLock** object.|
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | -------------------- |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
-**Return Value**
+**Return value**
-| Type | Description |
-| ---------------------- | ---------------------------------------- |
-| Promise<boolean> | Promise used to asynchronously obtain the return value.
Return value: The value **true** indicates that the specified type of **RunningLock** is supported, and the value **false** indicates the opposite.|
+| Type | Description |
+| ---------------------- | ---------------------------------------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** indicates that the specified type of **RunningLock** is supported, and the value **false** indicates the opposite.|
**Example**
-```
-runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
-.then(supported => {
- console.info('PROXIMITY_SCREEN_CONTROL support status is ' + supported);
+```js
+runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND)
+.then(data => {
+ console.info('BACKGROUND lock support status: ' + data);
})
-.catch(error => {
- console.log('error: ' + error);
+.catch(err => {
+ console.log('check BACKGROUND lock support status failed, err: ' + err);
});
```
-
-## createRunningLock
+## runningLock.createRunningLock(deprecated)
createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void
+> This API is deprecated since API version 9. You are advised to use [runningLock.create](#runninglockcreate9) instead.
+
Creates a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
@@ -98,33 +208,30 @@ Creates a **RunningLock** object.
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | -------------------------------------- |
-| name | string | Yes | Name of the **RunningLock** object. |
-| type | RunningLockType | Yes | Type of the **RunningLock** object to be created. |
-| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes | Callback used to obtain the return value.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
+| name | string | Yes | Name of the **RunningLock** object. |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created. |
+| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes | Callback used to return the result. If a lock is successfully created, **err** is **undefined** and **data** is the created **RunningLock**. Otherwise, **err** is an error object.|
**Example**
-```
-runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND, (error, lockIns) => {
- if (typeof error === "undefined") {
- var used = lockIns.isUsed();
- console.info('runninglock is used: ' + used);
- lockIns.lock(500);
- used = lockIns.isUsed();
- console.info('after lock runninglock is used ' + used);
+```js
+runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => {
+ if (typeof err === 'undefined') {
+ console.info('created running lock: ' + lock);
} else {
- console.log('create runningLock test error: ' + error);
+ console.error('create running lock failed, err: ' + err);
}
-})
+});
```
-
-## createRunningLock
+## runningLock.createRunningLock(deprecated)
createRunningLock(name: string, type: RunningLockType): Promise<RunningLock>
+> This API is deprecated since API version 9. You are advised to use [runningLock.create](#runninglockcreate9) instead.
+
Creates a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
@@ -133,39 +240,157 @@ Creates a **RunningLock** object.
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | --------------- | ---- | --------- |
-| name | string | Yes | Name of the **RunningLock** object. |
-| type | RunningLockType | Yes | Type of the **RunningLock** object to be created.|
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | ------------------ |
+| name | string | Yes | Name of the **RunningLock** object. |
+| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
-**Return Value**
+**Return value**
| Type | Description |
-| ---------------------------------------- | ---------------------------------- |
-| Promise<[RunningLock](#runninglock)> | Promise used to asynchronously obtain the returned **RunningLock** object.|
+| ------------------------------------------ | ------------------------------------ |
+| Promise<[RunningLock](#runninglock)> | Promise used to return the result.|
**Example**
+```js
+runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ console.info('created running lock: ' + lock);
+})
+.catch(err => {
+ console.log('create running lock failed, err: ' + err);
+});
```
-runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
-.then(runninglock => {
- console.info('create runningLock success');
+
+## RunningLock
+
+Represents a **RunningLock** object.
+
+### hold9+
+
+hold(timeout: number): void
+
+Locks and holds a **RunningLock** object.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Required permission:** ohos.permission.RUNNING_LOCK
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ----------------------------------------- |
+| timeout | number | Yes | Duration for locking and holding the **RunningLock** object, in ms.|
+
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|----------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ console.info('create running lock success');
+ try {
+ lock.hold(500);
+ console.info('hold running lock success');
+ } catch(err) {
+ console.error('hold running lock failed, err: ' + err);
+ }
})
-.catch(error => {
- console.log('create runningLock test error: ' + error);
+.catch(err => {
+ console.error('create running lock failed, err: ' + err);
+});
+```
+
+### unhold9+
+
+unhold(): void
+
+Releases a **RunningLock** object.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+**Required permission:** ohos.permission.RUNNING_LOCK
+
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|----------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ console.info('create running lock success');
+ try {
+ lock.unhold();
+ console.info('unhold running lock success');
+ } catch(err) {
+ console.error('unhold running lock failed, err: ' + err);
+ }
})
+.catch(err => {
+ console.error('create running lock failed, err: ' + err);
+});
```
+### isHolding9+
-## RunningLock
+isHolding(): boolean
+
+Checks the hold status of the **Runninglock** object.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
-Defines a **RunningLock** object.
+**Return value**
+| Type | Description |
+| ------- | ------------------------------------------------------------ |
+| boolean | The value **true** indicates that the **Runninglock** object is held; and the value **false** indicates that the **Runninglock** object is released.|
-### lock
+**Error codes**
+
+For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4900101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ console.info('create running lock success');
+ try {
+ var isHolding = lock.isHolding();
+ console.info('check running lock holding status: ' + isHolding);
+ } catch(err) {
+ console.error('check running lock holding status failed, err: ' + err);
+ }
+})
+.catch(err => {
+ console.error('create running lock failed, err: ' + err);
+});
+```
+
+### lock(deprecated)
lock(timeout: number): void
+> This API is deprecated since API version 9. You are advised to use [RunningLock.hold](#hold9) instead.
+
Locks and holds a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
@@ -174,29 +399,30 @@ Locks and holds a **RunningLock** object.
**Parameters**
-| Name | Type | Mandatory | Description |
-| ------- | ------ | ---- | -------------------------- |
-| timeout | number | No | Duration for locking and holding the **RunningLock** object, in ms.|
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ----------------------------------------- |
+| timeout | number | Yes | Duration for locking and holding the **RunningLock** object, in ms.|
**Example**
-```
-runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
-.then(runningLock => {
- runningLock.lock(100)
- console.info('create runningLock success')
+```js
+runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ lock.lock(500);
+ console.info('create running lock and lock success');
})
-.catch(error => {
- console.log('create runningLock test error: ' + error)
+.catch(err => {
+ console.error('create running lock failed, err: ' + err);
});
```
-
-### unlock
+### unlock(deprecated)
unlock(): void
-Releases a **Runninglock** object.
+> This API is deprecated since API version 9. You are advised to use [RunningLock.unhold](#unhold9) instead.
+
+Releases a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
@@ -204,40 +430,52 @@ Releases a **Runninglock** object.
**Example**
-```
-runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
-.then(runningLock => {
- runningLock.unlock()
- console.info('create and unLock runningLock success')
+```js
+runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ lock.unlock();
+ console.info('create running lock and unlock success');
})
-.catch(error => {
- console.log('create runningLock test error: ' + error)
+.catch(err => {
+ console.error('create running lock failed, err: ' + err);
});
```
-
-### isUsed
+### isUsed(deprecated)
isUsed(): boolean
-Checks the status of the **Runninglock** object.
+> This API is deprecated since API version 9. You are advised to use [RunningLock.isHolding](#isholding9) instead.
+
+Checks the hold status of the **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
-**Return Value**
-| Type | Description |
-| ------- | ------------------------------------- |
-| boolean | Returns **true** if the **Runninglock** object is held; returns **false** if the **Runninglock** object is released.|
+**Return value**
+| Type | Description |
+| ------- | ------------------------------------------------------------ |
+| boolean | The value **true** indicates that the **Runninglock** object is held; and the value **false** indicates that the **Runninglock** object is released.|
**Example**
-```
-runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
-.then(runningLock => {
- var used = runningLock.isUsed()
- console.info('runningLock used status: ' + used)
+```js
+runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
+.then(lock => {
+ var isUsed = lock.isUsed();
+ console.info('check running lock used status: ' + isUsed);
})
-.catch(error => {
- console.log('runningLock isUsed test error: ' + error)
+.catch(err => {
+ console.error('check running lock used status failed, err: ' + err);
});
```
+
+## RunningLockType
+
+Enumerates the types of **RunningLock** objects.
+
+**System capability:** SystemCapability.PowerManager.PowerManager.Core
+
+| Name | Value | Description |
+| ------------------------ | ---- | -------------------------------------- |
+| BACKGROUND | 1 | A lock that prevents the system from hibernating when the screen is off. |
+| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen.|
diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md
index 7b577c8ee81c733cdb1aa1f2ccfcced87829f304..31959da80f23b90f54ea10883417eec202152d1a 100644
--- a/en/application-dev/reference/apis/js-apis-system-battery.md
+++ b/en/application-dev/reference/apis/js-apis-system-battery.md
@@ -1,9 +1,10 @@
-# Battery Level
+# Battery Info
->  **NOTE**
-> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.batteryInfo`](js-apis-battery-info.md) instead.
->
-> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+This module allows you to query the charging status and remaining power of a device.
+
+> **NOTE**
+> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.batteryInfo`](js-apis-battery-info.md) instead.
+> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -16,40 +17,46 @@ import battery from '@system.battery';
## battery.getStatus
-getStatus(Object): void
+getStatus(options?: GetStatusOptions): void;
Obtains the current charging state and battery level.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
-**Parameter**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| success | Function | No | Called when the check result is obtained |
-| fail | Function | No | Called when the check result fails to be obtained |
-| complete | Function | No | Called when the execution is complete |
-
-The following value will be returned when the check result is obtained.
-
-| Name | Type | Description |
-| -------- | -------- | -------- |
-| charging | boolean | Whether the battery is being charged |
-| level | number | Current battery level, which ranges from 0.00 to 1.00. |
+| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.|
**Example**
```js
-export default {
- getStatus() {
- battery.getStatus({
- success: function(data) {
- console.log('success get battery level:' + data.level);
- },
- fail: function(data, code) {
- console.log('fail to get battery level code:' + code + ', data: ' + data);
- },
- });
- },
-}
-```
\ No newline at end of file
+battery.getStatus({
+ success: function(data) {
+ console.log('success get battery level:' + data.level);
+ },
+ fail: function(data, code) {
+ console.error('fail to get battery level code:' + code + ', data: ' + data);
+ }
+});
+```
+
+## GetStatusOptions
+
+Object that contains the API calling result.
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
+| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
+| complete | () => void | No | Called when API call is complete. |
+
+## BatteryResponse
+
+Defines a response that returns the charging status and remaining power of the device.
+
+| Name| Type| Description|
+| -------- | -------- | -------- |
+| charging | boolean | Whether the battery is being charged.|
+| level | number | Current battery level, which ranges from **0.00** to **1.00**.|
diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md
index 71e9b7072d03d8c25297cfd2c8f3c97c295097eb..2773c74397046c44784b65cc458be75eef8c21ea 100644
--- a/en/application-dev/reference/apis/js-apis-system-brightness.md
+++ b/en/application-dev/reference/apis/js-apis-system-brightness.md
@@ -1,8 +1,9 @@
# Screen Brightness
->  **NOTE**
+This module provides APIs for querying and adjusting the screen brightness and mode.
+
+> **NOTE**
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.brightness`](js-apis-brightness.md) instead.
->
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -16,7 +17,7 @@ import brightness from '@system.brightness';
## brightness.getValue
-getValue(Object): void
+getValue(options?: GetBrightnessOptions): void
Obtains the current screen brightness.
@@ -24,39 +25,27 @@ Obtains the current screen brightness.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| success | Function | No | Called when the execution is successful. |
-| fail | Function | No | Called when the operation fails. |
-| complete | Function | No | Called when the execution is complete |
-
-The following values will be returned when the operation is successful.
-
-| Name | Type | Description |
-| -------- | -------- | -------- |
-| value | number | Screen brightness, which ranges from 1 to 255. |
+| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.|
**Example**
-```js
-export default {
- getValue() {
- brightness.getValue({
- success: function(data){
- console.log('success get brightness value:' + data.value);
- },
- fail: function(data, code) {
- console.log('get brightness fail, code: ' + code + ', data: ' + data);
+ ```js
+ brightness.getValue({
+ success: function(data) {
+ console.log('success get brightness value:' + data.value);
},
- });
- },
-}
-```
+ fail: function(data, code) {
+ console.error('get brightness fail, code: ' + code + ', data: ' + data);
+ }
+ });
+ ```
## brightness.setValue
-setValue(Object): void
+etValue(options?: SetBrightnessOptions): void
Sets the screen brightness.
@@ -64,35 +53,28 @@ Sets the screen brightness.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | number | Yes | Screen brightness. The value is an integer ranging from 1 to 255.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used. |
-| success | Function | No | Called when the execution is successful. |
-| fail | Function | No | Called when the operation fails. |
-| complete | Function | No | Called when the execution is complete. |
+| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.|
**Example**
-```js
-export default {
- setValue() {
- brightness.setValue({
- value: 100,
- success: function(){
- console.log('handling set brightness success.');
- },
- fail: function(data, code){
- console.log('handling set brightness value fail, code:' + code + ', data: ' + data);
- },
- });
- },
-}
-```
+ ```js
+ brightness.setValue({
+ value: 100,
+ success: function() {
+ console.log('handling set brightness success.');
+ },
+ fail: function(data, code) {
+ console.error('handling set brightness value fail, code:' + code + ', data: ' + data);
+ }
+ });
+ ```
## brightness.getMode
-getMode(Object): void
+getMode(options?: GetBrightnessModeOptions: void
Obtains the screen brightness adjustment mode.
@@ -100,75 +82,57 @@ Obtains the screen brightness adjustment mode.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| success | Function | No | Called when the execution is successful. |
-| fail | Function | No | Called when the operation fails. |
-| complete | Function | No | Called when the execution is complete |
-
-The following values will be returned when the operation is successful.
-
-| Name | Type | Description |
-| -------- | -------- | -------- |
-| mode | number | The value can be **0** or **1**.
- **0**: The screen brightness is manually adjusted.
- **1**: The screen brightness is automatically adjusted. |
+| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.|
**Example**
-```js
-export default {
- getMode() {
- brightness.getMode({
- success: function(data){
- console.log('success get mode:' + data.mode);
- },
- fail: function(data, code){
- console.log('handling get mode fail, code:' + code + ', data: ' + data);
+ ```js
+ brightness.getMode({
+ success: function(data) {
+ console.log('success get mode:' + data.mode);
},
- });
- },
-}
-```
+ fail: function(data, code){
+ console.error('handling get mode fail, code:' + code + ', data: ' + data);
+ }
+ });
+ ```
## brightness.setMode
-setMode(Object): void
+setMode(options?: SetBrightnessModeOptions): void
Sets the screen brightness adjustment mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**Parameters**
-
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| mode | number | Yes | The value can be **0** or **1**.
- **0**: The screen brightness is manually adjusted.
- **1**: The screen brightness is automatically adjusted. |
-| success | Function | No | Called when the execution is successful. |
-| fail | Function | No | Called when the operation fails. |
-| complete | Function | No | Called when the execution is complete. |
+| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.|
**Example**
-```js
-export default {
- setMode() {
- brightness.setMode({
- mode: 1,
- success: function(){
- console.log('handling set mode success.');
- },
- fail: function(data, code){
- console.log('handling set mode fail, code:' + code + ', data: ' + data);
- },
- });
- },
-}
-```
+ ```js
+ brightness.setMode({
+ mode: 1,
+ success: function() {
+ console.log('handling set mode success.');
+ },
+ fail: function(data, code) {
+ console.error('handling set mode fail, code:' + code + ', data: ' + data);
+ }
+ });
+ ```
## brightness.setKeepScreenOn
-setKeepScreenOn(Object): void
+setKeepScreenOn(options?: SetKeepScreenOnOptions): void
+
+>This API is no longer maintained since API version 7. It is recommended that you use [window.setKeepScreenOn](js-apis-window.md#setkeepscreenon) instead.
Sets whether to always keep the screen on. Call this API in **onShow()**.
@@ -176,27 +140,88 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| keepScreenOn | boolean | Yes | Whether to always keep the screen on |
-| success | Function | No | Called when the execution is successful. |
-| fail | Function | No | Called when the operation fails. |
-| complete | Function | No | Called when the execution is complete. |
+| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.|
**Example**
-```js
-export default {
- setKeepScreenOn() {
- brightness.setKeepScreenOn({
- keepScreenOn: true,
- success: function () {
- console.log('handling set keep screen on success.')
- },
- fail: function (data, code) {
- console.log('handling set keep screen on fail, code:' + code + ', data: ' + data);
- },
- });
- },
-}
-```
\ No newline at end of file
+ ```js
+ brightness.setKeepScreenOn({
+ keepScreenOn: true,
+ success: function () {
+ console.log('handling set keep screen on success.');
+ },
+ fail: function (data, code) {
+ console.error('handling set keep screen on fail, code:' + code + ', data: ' + data);
+ }
+ });
+ ```
+## GetBrightnessOptions
+
+Defines the options for obtaining the screen brightness.
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
+| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.|
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
+| complete | () => void | No | Called when API call is complete. |
+
+## SetBrightnessOptions
+
+Defines the options for setting the screen brightness.
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
+| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.|
+| success | () => void | No | Called when API call is successful. |
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
+| complete | () => void | No | Called when API call is complete. |
+
+## BrightnessResponse
+
+Defines a response that returns the screen brightness.
+
+| Parameter| Type | Description|
+| -------- | -------- | -------- |
+| value | number | Screen brightness. The value ranges from 1 to 255.|
+
+## GetBrightnessModeOptions
+
+Defines the options for obtaining the screen brightness mode.
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.|
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
+| complete | () => void | No | Called when API call is complete. |
+
+## SetBrightnessModeOptions
+
+Defines the options for setting the screen brightness mode.
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
+| mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
+| success | () => void | No | Called when API call is successful. |
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
+| complete | () => void | No | Called when API call is complete. |
+
+## BrightnessModeResponse
+
+Defines a response that returns the screen brightness mode.
+
+| Name| Type | Description|
+| -------- | -------- | -------- |
+| mode | number | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
+
+## SetKeepScreenOnOptions
+
+Defines the options for setting the screen to be steady on.
+
+| Name | Type | Mandatory| Description |
+| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
+| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. |
+| success | () => void | No | Called when API call is successful. |
+| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
+| complete | () => void | No | Called when API call is complete. |
diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md
index b7b7e08a0a6a5a82a8813aad1f9d2010ff899a50..e0d809d06ab24702e5eaf67eb6b1b841a7944ffc 100644
--- a/en/application-dev/reference/apis/js-apis-thermal.md
+++ b/en/application-dev/reference/apis/js-apis-thermal.md
@@ -1,11 +1,9 @@
# Thermal Manager
-> **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.
-
This module provides thermal level-related callback and query APIs to obtain the information required for thermal control.
+> **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
@@ -13,78 +11,168 @@ This module provides thermal level-related callback and query APIs to obtain the
import thermal from '@ohos.thermal';
```
+## thermal.registerThermalLevelCallback9+
-## ThermalLevel
+registerThermalLevelCallback(callback: Callback<ThermalLevel>): void
-Represents the thermal level.
+Subscribes to thermal level changes.
**System capability:** SystemCapability.PowerManager.ThermalManager
-| 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.|
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------- | ---- | ------------------------------ |
+| callback | Callback<ThermalLevel> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-thermal.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4800101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ thermal.registerThermalLevelCallback(level => {
+ console.info('thermal level is: ' + level);
+ });
+ console.info('register thermal level callback success.');
+} catch(err) {
+ console.error('register thermal level callback failed, err: ' + err);
+}
+```
+
+## thermal.unregisterThermalLevelCallback9+
+
+unregisterThermalLevelCallback(callback?: Callback\): void
+
+Unsubscribes from thermal level changes.
+
+**System capability:** SystemCapability.PowerManager.ThermalManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------------------------------------------- |
+| callback | Callback<void> | No | Callback used to return the result. No value is returned. If this parameter is not set, this API unsubscribes from all callbacks.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-thermal.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4800101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ thermal.unregisterThermalLevelCallback(() => {
+ console.info('unsubscribe thermal level success.');
+ });
+ console.info('unregister thermal level callback success.');
+} catch(err) {
+ console.error('unregister thermal level callback failed, err: ' + err);
+}
+```
+
+## thermal.getLevel9+
+
+getLevel(): ThermalLevel
+
+Obtains the current thermal level.
+
+**System capability:** SystemCapability.PowerManager.ThermalManager
+**Return value**
-## thermal.subscribeThermalLevel
+| Type | Description |
+| ------------ | ------------ |
+| ThermalLevel | Thermal level obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-thermal.md).
+
+| Code | Error Message |
+|---------|---------|
+| 4800101 | Operation failed. Cannot connect to service.|
+
+**Example**
+
+```js
+try {
+ var level = thermal.getLevel();
+ console.info('thermal level is: ' + level);
+} catch(err) {
+ console.error('get thermal level failed, err: ' + err);
+}
+```
+
+## thermal.subscribeThermalLevel(deprecated)
subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void
+> This API is deprecated since API version 9. You are advised to use [thermal.registerThermalLevelCallback](#thermalregisterthermallevelcallback9) instead.
+
Subscribes to thermal level changes.
**System capability:** SystemCapability.PowerManager.ThermalManager
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------------------- | ---- | ---------------------------------------- |
-| callback | AsyncCallback<ThermalLevel> | Yes | Callback used to obtain the return value.
The return value contains only one parameter, that is, thermal level. If an alarm is generated, you can use `// @ts-ignore` to suppress the alarm.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<ThermalLevel> | Yes | Callback used to return the result. The return value contains only one parameter, that is, thermal level. If an alarm is generated, you can use `// @ts-ignore` to suppress the alarm.|
**Example**
```js
-var lev = 0;
-thermal.subscribeThermalLevel((lev) => {
- console.info("Thermal level is: " + lev);
-})
+thermal.subscribeThermalLevel((level) => {
+ console.info('thermal level is: ' + level);
+});
```
-## thermal.unsubscribeThermalLevel
+## thermal.unsubscribeThermalLevel(deprecated)
unsubscribeThermalLevel(callback?: AsyncCallback\): void
+> This API is deprecated since API version 9. You are advised to use [thermal.unregisterThermalLevelCallback](#thermalunregisterthermallevelcallback9) instead.
+
Unsubscribes from thermal level changes.
**System capability:** SystemCapability.PowerManager.ThermalManager
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------------------------- | ---- | --------------------- |
-| callback | AsyncCallback<void> | No | Callback without a return value.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------------------------------------------- |
+| callback | AsyncCallback<void> | No | Callback used to return the result. No value is returned. If this parameter is not set, this API unsubscribes from all callbacks.|
**Example**
```js
thermal.unsubscribeThermalLevel(() => {
- console.info("Unsubscribe completed.");
+ console.info('unsubscribe thermal level success.');
});
```
-## thermal.getThermalLevel
+## thermal.getThermalLevel(deprecated)
getThermalLevel(): ThermalLevel
+> This API is deprecated since API version 9. You are advised to use [thermal.getLevel](#thermalgetlevel9) instead.
+
Obtains the current thermal level.
**System capability:** SystemCapability.PowerManager.ThermalManager
-**Return value**:
+**Return value**
| Type | Description |
| ------------ | ------ |
@@ -93,6 +181,22 @@ Obtains the current thermal level.
**Example**
```js
-var lev = thermal.getThermalLevel();
-console.info("Thermal level is: " + lev);
+var level = thermal.getThermalLevel();
+console.info('thermal level is: ' + level);
```
+
+## ThermalLevel
+
+Represents the thermal level.
+
+**System capability:** SystemCapability.PowerManager.ThermalManager
+
+| Name | 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.|
diff --git a/en/application-dev/reference/errorcodes/errorcode-batteryStatistics.md b/en/application-dev/reference/errorcodes/errorcode-batteryStatistics.md
new file mode 100644
index 0000000000000000000000000000000000000000..6618e266707d3e187e0b79fcef9c67ac9ae5d142
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-batteryStatistics.md
@@ -0,0 +1,29 @@
+# Power Consumption Statistics Error Codes
+
+## 4600101 Service Connection Failure
+
+**Error Message**
+
+Operation failed. Cannot connect to service.
+
+**Description**
+
+This error code is reported for a service connection failure.
+
+**Possible Causes**
+
+1. The system service stops running.
+
+2. The internal communication of system services is abnormal.
+
+**Solution**
+
+Check whether the system services are running properly.
+
+1. Run the following command on the console to view the current system service list:
+
+ ```bash
+ > hdc shell hidumper -ls
+ ```
+
+2. Check whether **BatteryStatisticsService** is included in the system service list.
diff --git a/en/application-dev/reference/errorcodes/errorcode-brightness.md b/en/application-dev/reference/errorcodes/errorcode-brightness.md
new file mode 100644
index 0000000000000000000000000000000000000000..98dbced9c54a41dc6c55eb35ddf018c5a089d4be
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-brightness.md
@@ -0,0 +1,29 @@
+# Brightness Error Codes
+
+## 4700101 Service Connection Failure
+
+**Error Message**
+
+Operation failed. Cannot connect to service.
+
+**Description**
+
+This error code is reported for a service connection failure.
+
+**Possible Causes**
+
+1. The system service stops running.
+
+2. The internal communication of system services is abnormal.
+
+**Solution**
+
+Check whether the system services are running properly.
+
+1. Run the following command on the console to view the current system service list:
+
+ ```bash
+ > hdc shell hidumper -ls
+ ```
+
+2. Check whether **DisplayPowerManagerService** is included in the system service list.
diff --git a/en/application-dev/reference/errorcodes/errorcode-power.md b/en/application-dev/reference/errorcodes/errorcode-power.md
new file mode 100644
index 0000000000000000000000000000000000000000..83bbb2cdea786fd43b780fb9c153a31faf924e17
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-power.md
@@ -0,0 +1,47 @@
+# Power Manager Error Codes
+
+## 4900101 Service Connection Failure
+
+**Error Message**
+
+Operation failed. Cannot connect to service.
+
+**Description**
+
+This error code is reported for a service connection failure.
+
+**Possible Causes**
+
+1. The system service stops running.
+
+2. The internal communication of system services is abnormal.
+
+**Solution**
+
+Check whether the system services are running properly.
+
+1. Run the following command on the console to view the current system service list:
+
+ ```bash
+ > hdc shell hidumper -ls
+ ```
+
+2. Check whether **PowerManagerService** is included in the system service list.
+
+## 4900102 System Shuting Down
+
+**Error Message**
+
+Operation failed. System is shutting down.
+
+**Description**
+
+This error code is reported when an operation failed during system shutting down.
+
+**Possible Causes**
+
+The system is shutting down.
+
+**Solution**
+
+Make sure that the operation is performed when the system is running properly.
diff --git a/en/application-dev/reference/errorcodes/errorcode-runninglock.md b/en/application-dev/reference/errorcodes/errorcode-runninglock.md
new file mode 100644
index 0000000000000000000000000000000000000000..5e55c69b6304f626ab2bc247e17547703c424056
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-runninglock.md
@@ -0,0 +1,29 @@
+# Running Lock Error Codes
+
+## 4900101 Service Connection Failure
+
+**Error Message**
+
+Operation failed. Cannot connect to service.
+
+**Description**
+
+This error code is reported for a service connection failure.
+
+**Possible Causes**
+
+1. The system service stops running.
+
+2. The internal communication of system services is abnormal.
+
+**Solution**
+
+Check whether the system services are running properly.
+
+1. Run the following command on the console to view the current system service list:
+
+ ```bash
+ > hdc shell hidumper -ls
+ ```
+
+2. Check whether **PowerManagerService** is included in the system service list.
diff --git a/en/application-dev/reference/errorcodes/errorcode-thermal.md b/en/application-dev/reference/errorcodes/errorcode-thermal.md
new file mode 100644
index 0000000000000000000000000000000000000000..d831a9ebe63ccff1a86ea8e77cb56a969c115f0b
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-thermal.md
@@ -0,0 +1,29 @@
+# Thermal Manager Error Codes
+
+## 4800101 Service Connection Failure
+
+**Error Message**
+
+Operation failed. Cannot connect to service.
+
+**Description**
+
+This error code is reported for a service connection failure.
+
+**Possible Causes**
+
+1. The system service stops running.
+
+2. The internal communication of system services is abnormal.
+
+**Solution**
+
+Check whether the system services are running properly.
+
+1. Run the following command on the console to view the current system service list:
+
+ ```bash
+ > hdc shell hidumper -ls
+ ```
+
+2. Check whether **ThermalService** is included in the system service list.