harmony 鸿蒙Charging Type Customization
Charging Type Customization
Overview
Introduction
By default, OpenHarmony supports multiple charging types. You can charge devices through different types of charging, for example, wired fast charging and wireless fast charging. OpenHarmony can display appropriate animations or take required service processing based on the charging type. However, the supported charging types vary according to products. To address this issue, OpenHarmony provides the charging type customization function.
Constraints
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 charging type customization.
Create the
batteryfolder in the product directory /vendor/hihope/rk3568.Create a target folder by referring to the default folder of charging type configuration, and install it in
//vendor/hihope/rk3568/battery. The content is as follows:profile ├── BUILD.gn ├── battery_config.jsonWrite the custom
battery_config.jsonfile by referring to the battery_config.json file in the default folder of charging type configuration. For example:{ "charger": { "type": { "path": "/data/service/el0/battery/charger_type" } } }Write the
BUILD.gnfile by referring to the BUILD.gn file in the default folder of charging type configuration to pack thebattery_config.jsonfile to the//vendor/etc/batterydirectory. The configuration is as follows:import("//build/ohos.gni") # Reference build/ohos.gni. ohos_prebuilt_etc("battery_config") { source = "battery_config.json" relative_install_dir = "battery" 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/battery/profile:battery_config" # Add the configuration for building of battery_config. ] } }, "subsystem": "product_hihope" }In the preceding code,
//vendor/hihope/rk3568/battery/is the folder path,profileis the folder name, andbattery_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
After startup, run the following command to launch the shell command line:
hdc shellGo to the custom battery level configuration directory. The path of DAYU200 is used as an example.
cd /data/service/el0/battery/Modify the charging status, simulate reporting of the battery power change, and check whether the returned battery level is correct. The following uses the default charging type as an example.
- Modify the charging type.
echo 1 > charger_type - Report the charging status change to trigger mapping between the charging type and animation.
hidumper -s 3302 -a -r - Check the output for the charging type.
hidumper -s 3302 -a -i-------------------------------[ability]---------------------------- ------------------------------BatteryService------------------------ capacity: 11 batteryLevel: 4 chargingStatus: 1 healthState: 1 pluggedType: 2 voltage: 4123456 present: 0 technology: Li-ion nowCurrent: 1000 currentAverage: 1000 totalEnergy: 4000000 remainingEnergy: 4000000 remainingChargeTime: 0 temperature: 222 chargeType: 1
- Modify the charging type.
Reference
During development, you can refer to the default charging type configuration, as shown below:
```shell
{
"charger": {
"type": {
"path": "/data/service/el0/battery/charger_type"
}
}
}
```
Packing path: /system/etc/battery
你可能感兴趣的鸿蒙文章
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
-
8、 openharmony
-
9、 golang