public class PowerManager extends Object
The interfaces can be used to restart the system, use RunningLock,
and obtain the power status DevicePowerStatusInfo.
SystemCapability.PowerMgr#POWER_MANAGER| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
PowerManager.PowerState |
Indicates the power status of a device.
|
class |
PowerManager.RunningLock |
Provides a mechanism to prevent the system from hibernating so that the applications can run in the background or
when the screen is off.
|
static class |
PowerManager.RunningLockType |
Enumerates the
RunningLock types. |
| 构造器 | 说明 |
|---|---|
PowerManager() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
PowerManager.RunningLock |
createRunningLock(String name,
PowerManager.RunningLockType type) |
Creates a
RunningLock object. |
DevicePowerStatusInfo |
getCurrentPowerStatusInfo() |
已过时。
This change is effective since API version 7
|
boolean |
isRunningLockTypeSupported(PowerManager.RunningLockType type) |
Checks whether the specified
RunningLockType is supported. |
boolean |
isScreenOn() |
Checks whether the screen of a device is on or off.
|
void |
rebootDevice(String reason) |
Restarts the system.
|
public void rebootDevice(String reason)
This method requires the ohos.permission.REBOOT or ohos.permission.REBOOT_RECOVERY permission.
reason - Indicates the restart reason. For example, recovery indicates entering the recovery mode
after the restart. If the parameter is not specified, the system enters the normal mode after the restart.@Deprecated public DevicePowerStatusInfo getCurrentPowerStatusInfo()
DevicePowerStatusInfo interface.
The DevicePowerStatusInfo interface can be used to obtain power status information.
DevicePowerStatusInfo interface.public boolean isRunningLockTypeSupported(PowerManager.RunningLockType type)
RunningLockType is supported.type - Indicates the specified RunningLockType.true if the specified RunningLockType is supported;
returns false otherwise.public PowerManager.RunningLock createRunningLock(String name, PowerManager.RunningLockType type)
RunningLock object.
This method requires the ohos.permission.RUNNING_LOCK permission.
The RunningLock object can be used to perform a lock operation to prevent
the system from hibernating.
name - Indicates the RunningLock name. A recommended name consists of
the package or class name and a suffix.type - Indicates the RunningLockType.RunningLock object.public boolean isScreenOn()
true if the screen is on; returns false otherwise.