1e41f4b71Sopenharmony_ci# Thermal Scene Customization 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci### Introduction 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciBy default, OpenHarmony provides the thermal scene feature. During device usage, for example, gaming, photographing, or calling, the system will try to balance the performance, temperature, and power consumption. The thermal policy is usually scenario-specific. For example, the thermal policy in the gaming scenario does not decrease the screen brightness. However, the thermal scene definition varies according to product specifications. To address this issue, OpenHarmony provides the thermal scene customization function. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci### Constraints 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe 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. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## How to Develop 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci### Setting Up the Environment 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Hardware requirements:** 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciDevelopment board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Environment requirements:** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciFor details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci### Getting Started with Development 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciThe following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal scene customization. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Create a target folder by referring to the [default thermal scene configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci ```text 34e41f4b71Sopenharmony_ci profile 35e41f4b71Sopenharmony_ci ├── BUILD.gn 36e41f4b71Sopenharmony_ci ├── thermal_service_config.xml 37e41f4b71Sopenharmony_ci ``` 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal scene configuration folder. The following table describes the related configuration items. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci **Table 1** Configuration items for the thermal scene 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci | Configuration Item| Description| Parameter| Parameter Description| Parameter Type| Value Range| 44e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | -------- | -------- | 45e41f4b71Sopenharmony_ci | name="scene" | One or more thermal scenes specified by enum values.| param | Available thermal scenes: photographing, calling, and gaming.| enum | cam, call, and game| 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci **screen** and **charge** indicate the thermal status of the application; and specifically, whether the screen is turned on and whether the battery is being charged. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci ```shell 50e41f4b71Sopenharmony_ci <state> 51e41f4b71Sopenharmony_ci <item name="scene" param="cam,call,game"/> 52e41f4b71Sopenharmony_ci <item name="screen"/> 53e41f4b71Sopenharmony_ci <item name="charge"/> 54e41f4b71Sopenharmony_ci </state> 55e41f4b71Sopenharmony_ci ``` 56e41f4b71Sopenharmony_ci4. An external system can call the **UpdateThermalState** API of the thermal service to set the thermal status. 57e41f4b71Sopenharmony_ci```cpp 58e41f4b71Sopenharmony_cibool UpdateThermalState(const std::string& tag, const std::string& val, bool isImmed = false) 59e41f4b71Sopenharmony_ci``` 60e41f4b71Sopenharmony_ci| Parameter| Description| Type| 61e41f4b71Sopenharmony_ci|---|---|---| 62e41f4b71Sopenharmony_ci| tag | Scenario tag.| string | 63e41f4b71Sopenharmony_ci| val | Scenario status value.| string | 64e41f4b71Sopenharmony_ci| isImmed | Whether to update the thermal control action value immediately.| bool | 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci5. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal scene configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci ```shell 69e41f4b71Sopenharmony_ci import("//build/ohos.gni") # Reference build/ohos.gni. 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci ohos_prebuilt_etc("thermal_service_config") { 72e41f4b71Sopenharmony_ci source = "thermal_service_config.xml" 73e41f4b71Sopenharmony_ci relative_install_dir = "thermal_config" 74e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. 75e41f4b71Sopenharmony_ci part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 76e41f4b71Sopenharmony_ci } 77e41f4b71Sopenharmony_ci ``` 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci6. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build). For example: 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci ```json 82e41f4b71Sopenharmony_ci { 83e41f4b71Sopenharmony_ci "parts": { 84e41f4b71Sopenharmony_ci "product_rk3568": { 85e41f4b71Sopenharmony_ci "module_list": [ 86e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/default_app_config:default_app_config", 87e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/image_conf:custom_image_conf", 88e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 89e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 90e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/etc:product_etc_conf", 91e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. 92e41f4b71Sopenharmony_ci ] 93e41f4b71Sopenharmony_ci } 94e41f4b71Sopenharmony_ci }, 95e41f4b71Sopenharmony_ci "subsystem": "product_hihope" 96e41f4b71Sopenharmony_ci } 97e41f4b71Sopenharmony_ci ``` 98e41f4b71Sopenharmony_ci In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target. 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci7. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci ```shell 103e41f4b71Sopenharmony_ci ./build.sh --product-name rk3568 --ccache 104e41f4b71Sopenharmony_ci ``` 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci8. Burn the customized version to the DAYU200 development board. 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci### Debugging and Verification 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci1. After startup, run the following command to launch the shell command line: 111e41f4b71Sopenharmony_ci ```shell 112e41f4b71Sopenharmony_ci hdc shell 113e41f4b71Sopenharmony_ci ``` 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci2. Obtain the current thermal scene information. 116e41f4b71Sopenharmony_ci ```shell 117e41f4b71Sopenharmony_ci hidumper -s 3303 -a -s 118e41f4b71Sopenharmony_ci ``` 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci The following is the reference thermal scene result after customization: 121e41f4b71Sopenharmony_ci ```shell 122e41f4b71Sopenharmony_ci -------------------------------[ability]------------------------------- 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci ----------------------------------ThermalService--------------------------------- 126e41f4b71Sopenharmony_ci name: scene params: cam,call,game 127e41f4b71Sopenharmony_ci name: screen 128e41f4b71Sopenharmony_ci name: charge 129e41f4b71Sopenharmony_ci ``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci## Reference 132e41f4b71Sopenharmony_ciDuring development, you can refer to the [default thermal scene configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ciPacking path: `/vendor/etc/thermal_config/hdf` 135