1# Charging Type Customization 2 3## Overview 4 5### Introduction 6 7By 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. 8 9### Constraints 10 11The 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. 12 13## How to Develop 14 15### Setting Up the Environment 16 17**Hardware requirements:** 18 19Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. 20 21**Environment requirements:** 22 23For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). 24 25### Getting Started with Development 26 27The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate charging type customization. 28 291. Create the `battery` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). 30 312. Create a target folder by referring to the [default folder of charging type configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: 32 33 ```text 34 profile 35 ├── BUILD.gn 36 ├── battery_config.json 37 ``` 38 393. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of charging type configuration. For example: 40 41 ```shell 42 { 43 "charger": { 44 "type": { 45 "path": "/data/service/el0/battery/charger_type" 46 } 47 } 48 } 49 ``` 50 514. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of charging type configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: 52 53 ```shell 54 import("//build/ohos.gni") # Reference build/ohos.gni. 55 56 ohos_prebuilt_etc("battery_config") { 57 source = "battery_config.json" 58 relative_install_dir = "battery" 59 install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. 60 part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. 61 } 62 ``` 63 645. 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: 65 66 ```json 67 { 68 "parts": { 69 "product_rk3568": { 70 "module_list": [ 71 "//vendor/hihope/rk3568/default_app_config:default_app_config", 72 "//vendor/hihope/rk3568/image_conf:custom_image_conf", 73 "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 74 "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 75 "//vendor/hihope/rk3568/etc:product_etc_conf", 76 "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. 77 ] 78 } 79 }, 80 "subsystem": "product_hihope" 81 } 82 ``` 83 In the preceding code, `//vendor/hihope/rk3568/battery/` is the folder path, `profile` is the folder name, and `battery_config` is the build target. 84 856. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 86 87 ```shell 88 ./build.sh --product-name rk3568 --ccache 89 ``` 90 917. Burn the customized version to the DAYU200 development board. 92 93### Debugging and Verification 94 95 961. After startup, run the following command to launch the shell command line: 97 ``` 98 hdc shell 99 ``` 100 1012. Go to the custom battery level configuration directory. The path of DAYU200 is used as an example. 102 ``` 103 cd /data/service/el0/battery/ 104 ``` 105 1063. Modify the charging status, simulate reporting of the charging status, and check whether the displayed animation is correct. The following uses the default charging type and animation mapping as an example. 107 1. Modify the charging type. 108 ``` 109 echo 1 > charger_type 110 ``` 111 2. Report the charging status change to trigger mapping between the charging type and animation. 112 ``` 113 hidumper -s 3302 -a -r 114 ``` 115 3. Check the output for the charging type. 116 ``` 117 hidumper -s 3302 -a -i 118 ``` 119 ``` 120 -------------------------------[ability]---------------------------- 121 ------------------------------BatteryService------------------------ 122 capacity: 11 123 batteryLevel: 4 124 chargingStatus: 1 125 healthState: 1 126 pluggedType: 2 127 voltage: 4123456 128 present: 0 129 technology: Li-ion 130 nowCurrent: 1000 131 currentAverage: 1000 132 totalEnergy: 4000000 133 remainingEnergy: 4000000 134 remainingChargeTime: 0 135 temperature: 222 136 chargeType: 1 137 ``` 138  139 140 141## Reference 142During development, you can refer to the [default charging type configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below: 143 144 ```shell 145 { 146 "charger": { 147 "type": { 148 "path": "/data/service/el0/battery/charger_type" 149 } 150 } 151 } 152 ``` 153 154Packing path: `/system/etc/battery` 155