By default, OpenHarmony supports setting of charging current and voltage limits. When a device is being charged, the battery temperature may become excessively high due to the impact of ambient environment. In such a case, the charging current or voltage needs to be limited to ensure safety use of the device. However, the impact of charging current or voltage on device safety varies according to product specifications. To address this issue, OpenHarmony provides the function of customizing charging current and voltage limits.
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.
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.
The following uses DAYU200 as an example to illustrate customization of charging current and voltage limits.
Create the battery
folder in the product directory /vendor/hihope/rk3568.
Create a target folder by referring to the default folder of charging current and voltage limit configuration, and install it in //vendor/hihope/rk3568/battery
. The content is as follows:
profile
├── BUILD.gn
├── battery_config.json
Write the custom battery_config.json
file by referring to the battery_config.json
file in the default folder of charging current and voltage limit configuration. For example:
{
"charger": {
"current_limit":{
"path": "/data/service/el0/battery/current_limit"
},
"voltage_limit":{
"path": "/data/service/el0/battery/voltage_limit"
}
}
}
Write the BUILD.gn
file by referring to the BUILD.gn
in the default folder of charging current and voltage limit configuration to pack the battery_config.json
file to the //vendor/etc/battery
directory. 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_list
in ohos.build in the /vendor/hihope/rk3568
directory. 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, profile
is the folder name, and battery_config
is 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.
Build the battery-specific hats test cases. For details about the build commands and framework setup, see XTS Subsystem.
Run the test cases, and check the test report.
During development, you can refer to the default charging current and voltage configuration, as shown below:
{
"charger": {
"current_limit":{
"path": "/data/service/el0/battery/current_limit"
},
"voltage_limit":{
"path": "/data/service/el0/battery/voltage_limit"
}
}
}
Packing path: /system/etc/battery
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。