• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Wakeup Source Customization
2
3## Overview
4
5### Introduction
6
7OpenHarmony supports multiple wakeup sources, such as the power button, keyboard, and mouse, and provides custom modes for turning on and off these wakeup sources. After a device enters the sleep state, you can turn on the screen and wake up the device by touching the power button, keyboard, mouse, or screen. However, different products may support different peripherals, for example, stylus or folio keyboard. To address this issue, OpenHarmony provides the wakeup source customization function, allowing you to customize wakeup sources depending on your hardware specifications.
8
9### Constraints
10
11The configuration paths for battery level customization are subject to the configuration policy.
12The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy.
13
14## How to Develop
15
16### Setting Up the Environment
17
18**Hardware requirements:**
19
20Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite.
21
22**Environment requirements:**
23
24For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md).
25
26### Getting Started with Development
27
28The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate wakeup source customization.
29
301. Create the `power_manager` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
31
322. Create a target folder by referring to the [default folder of wakeup source configuration](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile), and install it in `/vendor/hihope/rk3568/power_manager`. The content is as follows:
33
34    ```text
35    profile
36    ├── BUILD.gn
37    ├── power_wakeup.json
38    ```
39
403. Write the custom `power_wakeup.json` file that contains the custom wakeup sources. The following is an example of wakeup source configuration:
41
42    ```json
43    {
44        "powerkey": {
45            "enable": true
46        },
47        "keyborad": {
48            "enable": true
49        },
50        "mouse": {
51            "enable": true
52        },
53        "touchscreen": {
54            "enable": true,
55            "click": 2
56        },
57        "touchpad": {
58            "enable": true
59        },
60        "pen": {
61            "enable": true
62        },
63        "lid": {
64            "enable": true
65        },
66        "switch": {
67            "enable": true
68        },
69        "tp_touch": {
70            "enable": true
71        }
72    }
73    ```
74
75    **Table 1** Description of wakeup sources
76
77    | Wakeup Source| Description|
78    | -------- | -------- |
79    | powerkey | Wakeup by power button|
80    | keyborad | Wakeup by keyboard|
81    | mouse | Wakeup by mouse|
82    | touchscreen | Wakeup by touchscreen|
83    | touchpad | Wakeup by touchpad|
84    | pen | Wakeup by stylus|
85    | lid | Wakeup by lid|
86    | switch | Wakeup by switch|
87    | tp_touch | Wakeup by touch|
88
89    **Table 2** Description of the wakeup source configuration
90
91    | Item| Type| Description|
92    | -------- | -------- | -------- |
93    | enable | bool | Whether to enable wakeup listening|
94    | click | int | Number of clicks|
95
96
974. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of wakeup source configuration to pack the `power_wakeup.json` file to the `/vendor/etc/power_config` directory. The configuration is as follows:
98
99    ```shell
100    import("//build/ohos.gni")               # Reference build/ohos.gni.
101
102    ohos_prebuilt_etc("wakeup_config") {
103        source = "power_wakeup.json"
104        relative_install_dir = "power_config"
105        install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory.
106        part_name = "product_rk3568"          # Set part_name to product_rk3568 for subsequent build.
107    }
108    ```
109
1105. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example:
111
112    ```json
113    {
114        "parts": {
115            "product_rk3568": {
116                "module_list": [
117                    "//vendor/hihope/rk3568/default_app_config:default_app_config",
118                    "//vendor/hihope/rk3568/image_conf:custom_image_conf",
119                    "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
120                    "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
121                    "//vendor/hihope/rk3568/etc:product_etc_conf",
122                    "//vendor/hihope/rk3568/power_manager/profile:wakeup_config" // Add the configuration for building of wakeup_config.
123                ]
124            }
125        },
126        "subsystem": "product_hihope"
127    }
128    ```
129    In the preceding code, `//vendor/hihope/rk3568/power_manager/` is the folder path, `profile` is the folder name, and `wakeup_config` is the build target.
130
1316. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
132
133    ```shell
134    ./build.sh --product-name rk3568 --ccache
135    ```
136
1377. Burn the customized version to the DAYU200 development board.
138
139### Debugging and Verification
140
141> **NOTE**
142>
143> Currently, the Double-tap to wake feature is not supported. That is, **enable** in **touchscreen** can only be set to **false**. This feature will be provided in later versions.
144
1451. Customize wakeup sources in the `power_wakeup.json` file.
146    ```json
147    {
148        "powerkey": {
149            "enable": true
150        },
151        "keyborad": {
152            "enable": true
153        },
154        "mouse": {
155            "enable": true
156        },
157        "touchscreen": {
158            "enable": false,
159            "click": 2
160        },
161        "touchpad": {
162            "enable": false
163        },
164        "pen": {
165            "enable": false
166        },
167        "lid": {
168            "enable": false
169        },
170        "switch": {
171            "enable": false
172        },
173        "tp_touch": {
174            "enable": false
175        }
176    }
177    ```
178
1792. After the device is powered on, press the power button to switch the device to the sleep mode. Then, press the power button again.
180
181    The device screen is turned on and the device is woken up.
182
1833. Press the power button to switch the device to the sleep mode, and then press the keyboard.
184
185    The device screen is turned on and the device is woken up.
186
1874. Press the power button to switch the device to the sleep mode, and then move the mouse.
188
189    The device screen is turned on and the device is woken up.
190