harmony 鸿蒙Power Wakeup Action Source Customization
Power Wakeup Action Source Customization
Overview
Introduction
OpenHarmony provides the function of waking up the system in sleep mode to take expected actions. For example, when the battery level is low, OpenHarmony can wake up the system to shut down the device. When the system is in the sleep state, it can be woken up based on the configuration policy to perform the scheduled action. However, supported application scenarios may vary according to products. For example, wakeup at low battery level may not be supported by certain products. To address this issue, OpenHarmony provides the function that allows you to customize power wakeup action sources depending on your product specifications.
Constraints
Required adaptation:
- Triggering a power button event when the wakeup condition is met (for example, the battery level is lower than the specified threshold).
- Saving the wakeup reason (for example, wakeup due to low battery level) to the kernel node.
Configuration rule:
The configuration path for power wakeup action source 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 post-wakeup system action customization.
Create the
power_managerfolder in the product directory /vendor/hihope/rk3568.Create a target folder by referring to the default folder of power wakeup action source configuration, and install it in
/vendor/hihope/rk3568/power_manager. The content is as follows:profile ├── BUILD.gn ├── power_wakeup_action.jsonWrite the custom
power_wakeup_action.jsonfile, which contains the custom wakeup reasons and actions as follows:{ "53": { "scene": "LowCapacity", "action": 2, "description": "(such as)53 is a uniquely wakeup reason by reading node through HDI interface(GetWakeupReason)" } }Table 1 Description of wakeup sources
|Wakeup Source|Description| |——–|——–| |53|Wakeup due to low battery level.|
The wakeup source can be obtained by reading node data or by other ways.
**Table 2** Description of wakeup scenarios
|Wakeup Scenario|Description| |——–|——–| |LowCapacity|Low battery level.|
**Table 3** Description of actions
|action|Value|Description| |——–|——–|——–| |ACTION_NONE|0|No action| |ACTION_HIBERNATE|1|Hibernation| |ACTION_SHUTDOWN|2|Shutdown|
Write the
BUILD.gnfile by referring to the BUILD.gn file in the default folder of power wakeup action source configuration to pack thepower_wakeup_action.jsonfile to the/vendor/etc/power_wakeup_actiondirectory. The configuration is as follows:import("//build/ohos.gni") # Reference build/ohos.gni. ohos_prebuilt_etc("wakeup_action_config") { source = "power_wakeup_action.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_action_config" // Add the configuration for building of wakeup_action_config. ] } }, "subsystem": "product_hihope" }In the preceding code,
//vendor/hihope/rk3568/power_manager/is the folder path,profileis the folder name, andwakeup_action_configis the build target.Build the customized version by referring to Quick Start.
./build.sh --product-name rk3568 --ccacheBurn the customized version to the DAYU200 development board.
Debugging and Verification
Customize power wakeup action sources in the new configuration file.
{ "53": { "scene": "LowCapacity", "action": 2, "description": "(such as)53 is a uniquely wakeup reason by reading node through HDI interface(GetWakeupReason)" } }In the powermgr.gni file, set power_manager_feature_wakeup_action to true to enable the feature.
power_manager_feature_wakeup_action = trueAdd the following configuration to the battery_config.json file:
"charge_scene": { "low_battery_thers": { "set": { "path": "xxx" } } }In the preceding configuration, path indicates the path of the node that stores the low battery threshold.
In the batterymgr.gni file, set battery_manager_feature_set_low_capacity_threshold to true to enable the feature.
battery_manager_feature_set_low_capacity_threshold = trueAdd the following configuration to the power_config.json file:
{ "scene" :{ "wakeuo_cause": { "get": { "path": "yyy" } } } }In the preceding configuration, get indicates the path of the node that stores the low battery wakeup reason.
In the power.gni file, set drivers_peripheral_power_wakeup_cause_path to true to enable the feature.
drivers_peripheral_power_wakeup_cause_path = trueChange the node permission to system in the pre-init field of the hdf_peripheral.cfg file.
"chown system system xxx", "chown system system yyy",Decrease the battery level to fall below the specified threshold when the system is in the sleep state.
The device is shut down.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AI Framework Development Guide
harmony 鸿蒙Neural Network Runtime Device Access
harmony 鸿蒙Application Privilege Configuration
harmony 鸿蒙Setting Up a Development Environment
harmony 鸿蒙Development Guidelines
harmony 鸿蒙Application Framework Overview
harmony 鸿蒙ArkCompiler Development
harmony 鸿蒙Window Title Bar Customization Development (ArkTS)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 openharmony
-
9、 golang