Wakeup Source Customization
Overview
Introduction
OpenHarmony 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.
Constraints
The configuration paths for battery level customization are subject to the configuration policy.
The configuration path for battery level customization is subject to the configuration 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.
How to Develop
Setting Up the Environment
Hardware requirements:
Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite.
Environment requirements:
For details about the requirements on the Linux environment, see Quick Start.
Getting Started with Development
The following uses DAYU200 as an example to illustrate wakeup source customization.
-
Create the
power_managerfolder in the product directory /vendor/hihope/rk3568. -
Create a target folder by referring to the default folder of wakeup source configuration, and install it in
/vendor/hihope/rk3568/power_manager. The content is as follows:profile ├── BUILD.gn ├── power_wakeup.json -
Write the custom
power_wakeup.jsonfile that contains the custom wakeup sources. The following is an example of wakeup source configuration:{ "powerkey": { "enable": true }, "keyborad": { "enable": true }, "mouse": { "enable": true }, "touchscreen": { "enable": true, "click": 2 }, "touchpad": { "enable": true }, "pen": { "enable": true }, "lid": { "enable": true }, "switch": { "enable": true }, "tp_touch": { "enable": true } }Table 1 Description of wakeup sources
Wakeup Source Description powerkey Wakeup by power button keyborad Wakeup by keyboard mouse Wakeup by mouse touchscreen Wakeup by touchscreen touchpad Wakeup by touchpad pen Wakeup by stylus lid Wakeup by lid switch Wakeup by switch tp_touch Wakeup by touch Table 2 Description of the wakeup source configuration
Item Type Description enable bool Whether to enable wakeup listening click int Number of clicks -
Write the
BUILD.gnfile by referring to the BUILD.gn file in the default folder of wakeup source configuration to pack thepower_wakeup.jsonfile to the/vendor/etc/power_configdirectory. The configuration is as follows:import("//build/ohos.gni") # Reference build/ohos.gni. ohos_prebuilt_etc("wakeup_config") { source = "power_wakeup.json" relative_install_dir = "power_config" install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. } -
Add the build target to
module_listin ohos.build in the/vendor/hihope/rk3568directory. For example:{ "parts": { "product_rk3568": { "module_list": [ "//vendor/hihope/rk3568/default_app_config:default_app_config", "//vendor/hihope/rk3568/image_conf:custom_image_conf", "//vendor/hihope/rk3568/preinstall-config:preinstall-config", "//vendor/hihope/rk3568/resourceschedule:resourceschedule", "//vendor/hihope/rk3568/etc:product_etc_conf", "//vendor/hihope/rk3568/power_manager/profile:wakeup_config" // Add the configuration for building of wakeup_config. ] } }, "subsystem": "product_hihope" }In the preceding code,
//vendor/hihope/rk3568/power_manager/is the folder path,profileis the folder name, andwakeup_configis the build target. -
Build the customized version by referring to Quick Start.
./build.sh --product-name rk3568 --ccache -
Burn the customized version to the DAYU200 development board.
Debugging and Verification
NOTE
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.
-
Customize wakeup sources in the
power_wakeup.jsonfile.{ "powerkey": { "enable": true }, "keyborad": { "enable": true }, "mouse": { "enable": true }, "touchscreen": { "enable": false, "click": 2 }, "touchpad": { "enable": false }, "pen": { "enable": false }, "lid": { "enable": false }, "switch": { "enable": false }, "tp_touch": { "enable": false } } -
After the device is powered on, press the power button to switch the device to the sleep mode. Then, press the power button again.
The device screen is turned on and the device is woken up.
-
Press the power button to switch the device to the sleep mode, and then press the keyboard.
The device screen is turned on and the device is woken up.
-
Press the power button to switch the device to the sleep mode, and then move the mouse.
The device screen is turned on and the device is woken up.