• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-885766

screenshot/device/12-May-2024-

.gitignoreD12-May-2024142 1111

README.mdD12-May-2024655 189

README_zh.mdD12-May-20241.8 KiB4021

build-profile.json5D12-May-20241 KiB4341

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024376 1918

README.md

1# Power Management
2
3### Introduction
4
5This sample shows how to power off a device, restart the system, and check the screen status.
6
7### Usage
8
91. To power off a device, tap the **Power off** button, and click **OK** in the displayed dialog. To quit, tap **Cancel** in the displayed dialog.
10
112. To restart the system, touch the **Restart** button, and click **OK** in the displayed dialog. To quit, tap **Cancel** in the displayed dialog.
12
133. To check whether the screen is on or off, tap the **Check screen status** button. The check result will be shown in the displayed dialog.
14
15### Constraints
16
17This sample can only be run on standard-system devices.
18

README_zh.md

1# 系统电源管理
2
3### 简介
4
5本示例通过[power](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-power.md)接口实现了关机、重启以及检测亮灭屏状态的功能。
6
7使用说明:
8
91.点击**关机**按钮,并在弹框中点击确定,系统将关机。点击取消,则关闭弹窗。
10
112.点击**重启**按钮,并在弹框中点击确定,系统将重启。点击取消,则关闭弹窗。
12
133.点击**检测亮灭屏状态**按钮,将会把检测的结果信息展示在显示窗口中。
14
15### 效果预览
16
17|主页|
18|--------------------------------|
19|![](screenshot/device/main.png)|
20
21### 相关权限
22
23电源管理权限:[ohos.permission.REBOOT](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)
24
25### 依赖
26
27不涉及。
28
29### 约束与限制
30
311.本示例仅支持在标准系统上运行。
32
332.本示例仅支持API9版本SDK,版本号:3.2.7.6。
34
353.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。
36
374.本示例需要使用@ohos.power系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md/)38
395.本示例所配置的权限ohos.permission.REBOOT为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/))40