未验证 提交 97230ecd 编写于 作者: O openharmony_ci 提交者: Gitee

!5483 翻译已完成5102&5112

Merge pull request !5483 from shawn_he/5102-b
# Power Manager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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**<br>
> 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,10 +12,6 @@ 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.shutdownDevice
......@@ -27,6 +23,8 @@ This is a system API and cannot be called by third-party applications.
**Required permission**: ohos.permission.REBOOT
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -47,7 +45,9 @@ rebootDevice(reason: string): void
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**
......@@ -69,6 +69,8 @@ isScreenOn(callback: AsyncCallback&lt;boolean&gt;): void
Checks the screen status of the current device.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -94,6 +96,8 @@ isScreenOn(): Promise&lt;boolean&gt;
Checks the screen status of the current device.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return value**
| Type | Description |
| ---------------------- | --------------------------------------- |
......@@ -110,3 +114,182 @@ power.isScreenOn()
console.log('error: ' + error);
})
```
## power.wakeupDevice<sup>9+</sup>
wakeupDevice(detail: string): void
Wakes up a device.
This is a system API and cannot be called by third-party applications.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- |
| detail | string | Yes | Reason for wakeup.|
**Example**
```js
power.wakeupDevice("application");
console.info('power_wakeup_device_test success')
```
## power.suspendDevice<sup>9+</sup>
suspendDevice(): void
Hibernates a device.
This is a system API and cannot be called by third-party applications.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Example**
```js
power.suspendDevice();
console.info('power_suspend_device_test success')
```
## power.getPowerMode<sup>9+</sup>
getPowerMode(callback: AsyncCallback&lt;DevicePowerMode&gt;): void
Obtains the power mode of this device.
**Required permission**: ohos.permission.POWER_OPTIMIZATION
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;DevicePowerMode&gt; | Yes | Callback used to obtain the return value.<br>Return value: [DevicePowerMode](#devicepowermode9)|
**Example**
```js
power.getPowerMode((error, mode) => {
if (typeof error === "undefined") {
console.info('power mode is ' + mode);
} else {
console.log('error: ' + error);
}
})
```
## power.getPowerMode<sup>9+</sup>
getPowerMode(): Promise&lt;DevicePowerMode&gt;
Obtains the power mode of this device.
**Required permission**: ohos.permission.POWER_OPTIMIZATION
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return value**
| Type | Description |
| ------------------------------ | ------------------------------------------------------------ |
| Promise&lt;DevicePowerMode&gt; | Promise used to obtain the return value. <br/>Return value: [DevicePowerMode](#devicepowermode9)|
**Example**
```js
power.getPowerMode()
.then(mode => {
console.info('power mode is ' + mode);
})
.catch(error => {
console.log('error: ' + error);
})
```
## power.setPowerMode<sup>9+</sup>
setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void
Sets the power mode of this device.
This is a system API and cannot be called by third-party applications.
**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&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, error => {
if (typeof error === "undefined") {
console.info('set power mode to MODE_PERFORMANCE');
} else {
console.log('error: ' + error);
}
})
```
## power.setPowerMode<sup>9+</sup>
setPowerMode(mode: DevicePowerMode): Promise&lt;void&gt;
Sets the power mode of this device.
This is a system API and cannot be called by third-party applications.
**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&lt;void&gt; | Promise used to return the result.|
**Example**
```js
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE)
.then(() => {
console.info('set power mode to MODE_PERFORMANCE');
})
.catch(error => {
console.log('error: ' + error);
})
```
## DevicePowerMode<sup>9+</sup>
Enumerates power modes.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
| Name | Default 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. |
......@@ -408,7 +408,7 @@ Checks whether the current device supports 5G \(NR\).
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
console.log("result is "+ result);
```
......
......@@ -521,7 +521,7 @@ Obtains the number of card slots.
**Example**
```js
console.log(sim.getMaxSimCount())
console.log("the result is "+sim.getMaxSimCount())
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册