@@ -93,7 +89,6 @@ The **condition** parameter must be in the specified JSON string format. For exa
...
@@ -93,7 +89,6 @@ The **condition** parameter must be in the specified JSON string format. For exa
- The **version** field is mandatory, indicating the supported version of the input condition. Currently, only **V1** is supported.
- The **version** field is mandatory, indicating the supported version of the input condition. Currently, only **V1** is supported.
- The **condition** field is mandatory, indicating the input condition.
- The **condition** field is mandatory, indicating the input condition.
- The **and** field is optional, indicating the AND relationship between conditions.
- The **and** field is optional, indicating the AND relationship between conditions.
- The **or** field is optional, indicating the OR relationship between conditions.
- The **param** field is mandatory, indicating the parameter name for condition matching. The value must be a string.
- The **param** field is mandatory, indicating the parameter name for condition matching. The value must be a string.
- The **op** field is mandatory, indicating the parameter comparison operator for condition matching. The value must be a string. Supported comparison operators include the following: =, >, <,>=, and <=.
- The **op** field is mandatory, indicating the parameter comparison operator for condition matching. The value must be a string. Supported comparison operators include the following: =, >, <,>=, and <=.
- The **value** field is mandatory, indicating the parameter value for condition matching. The value must be a string or an integer.
- The **value** field is mandatory, indicating the parameter value for condition matching. The value must be a string or an integer.
By default, after a device screen is turned off, OpenHarmony starts the running lock loop detection thread and then enters the hibernation state. For different devices, the mode of turning off the screen is different, which can be closing the lid, setting a timeout, or pressing the power button. Besides, the default hibernation behavior is also different, which can be performing no action, powering off the screen, or entering the hibernation state. To address this issue, OpenHarmony provides the default hibernation behavior customization function, allowing you to customize the default hibernation behavior depending on your hardware specifications.
### Constraints
The configuration paths for battery level customization are subject to the configuration policy.
The 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.
## 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](../quick-start/quickstart-overview.md).
### Getting Started with Development
The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate default hibernation behavior customization.
1. Create the `power_manager` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
2. Create a target folder by referring to the [default folder of hibernation behavior configuration](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile), and install it in `/vendor/hihope/rk3568/power_manager`. The content is as follows:
```text
profile
├── BUILD.gn
├── power_suspend.json
```
3. Write the custom `power_suspend.json` file that contains the custom default hibernation behavior. The following is an example of hibernation behavior configuration:
```json
{
"powerkey": {
"action": 1,
"delayMs": 0
},
"timeout": {
"action": 1,
"delayMs": 0
},
"lid": {
"action": 1,
"delayMs": 0
},
"switch": {
"action": 1,
"delayMs": 0
}
}
```
**Table 1** Description of hibernation sources
| Hibernation Source| Description|
| -------- | -------- |
| powerkey | Hibernation by power button|
| timeout | Hibernation by timeout|
| lid | Hibernation by lid|
| switch | Hibernation by switch|
**Table 2** Description of the hibernation source configuration
| Item| Description|
| -------- | -------- |
| action | Action to take after the screen is turned off. Set this parameter to an enumerated value. For details, see Table 3.|
| delayMs | Delay, in ms.|
**Table 3** Description of action
| action | Value| Description|
| -------- | -------- | -------- |
| ACTION_NONE | 0 | No action.|
| ACTION_AUTO_SUSPEND | 1 | Automatically entering the sleep mode.|
| ACTION_FORCE_SUSPEND | 2 | Forcibly entering the sleep mode.|
| ACTION_HIBERNATE | 3 | Entering the hibernation state.|
| ACTION_SHUTDOWN | 4 | Shutting down the system.|
4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of hibernation behavior configuration to pack the `power_suspend.json` file to the `/vendor/etc/power_config` directory. The configuration is as follows:
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.
}
```
5. 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:
"//vendor/hihope/rk3568/power_manager/profile:wakeup_config" // Add the configuration for building of suspend_config.
]
}
},
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/power_manager/` is the folder path, `profile` is the folder name, and `suspend_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
```shell
./build.sh --product-name rk3568 --ccache
```
7. Burn the customized version to the DAYU200 development board.
### Debugging and Verification
1. Customize hibernation sources in the `power_suspend.json` file.
```json
{
"powerkey":{
"action":4,
"delayMs":0
},
"timeout":{
"action":1,
"delayMs":0
},
"lid":{
"action":1,
"delayMs":0
},
"switch":{
"action":1,
"delayMs":0
}
}
```
2. Power on the device, and then press the power button.
The device is powered off.
3. Power on the device again, and then wait for a while.
By default, OpenHarmony provides the power consumption statistics feature. However, the power consumption benchmarks vary according to hardware specifications of different products. To address this issue, OpenHarmony provides the power consumption statistics customization function, allowing you to customize power consumption benchmarks depending on your hardware specifications.
By default, OpenHarmony provides the power consumption statistics feature. However, the power consumption benchmarks vary according to hardware specifications of different products. To address this issue, OpenHarmony provides the power consumption statistics customization function, allowing you to customize power consumption benchmarks depending on your hardware specifications.
OpenHarmony supports multiple wakeup sources, such as the power button, keyboard, and mouse, and provides custom modes for turning on and off these wakeup sources. After a device enters the sleep state, you can turn on the screen and wake up the device by pressing the power button, keyboard, or mouse. However, different products may support different peripherals, for example, stylus or folio keyboard. To address this issue, OpenHarmony provides the wakeup source customization function, allowing you to customize wakeup sources depending on your hardware specifications.
### Constraints
The configuration paths for battery level customization are subject to the configuration policy.
The 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.
## 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](../quick-start/quickstart-overview.md).
### Getting Started with Development
The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate wakeup source customization.
1. Create the `power_manager` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
2. Create a target folder by referring to the [default folder of wakeup source configuration](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile), and install it in `/vendor/hihope/rk3568/power_manager`. The content is as follows:
```text
profile
├── BUILD.gn
├── power_wakeup.json
```
3. Write the custom `power_wakeup.json` file that contains the custom wakeup sources. The following is an example of wakeup source configuration:
```json
{
"powerkey": {
"enable": true
},
"keyborad": {
"enable": true
},
"mouse": {
"enable": true
},
"touchscreen": {
"enable": true,
"click": 2
},
"touchpad": {
"enable": true
},
"pen": {
"enable": true
},
"lid": {
"enable": true
},
"switch": {
"enable": true
}
}
```
**Table 1** Description of wakeup sources
| Wakeup Source| Description|
| -------- | -------- |
| powerkey | Wakeup by power button|
| keyborad | Wakeup by keyboard|
| mouse | Wakeup by mouse|
| touchscreen | Wakeup by touchscreen|
| touchpad | Wakeup by touchpad|
| pen | Wakeup by stylus|
| lid | Wakeup by lid|
| switch | Wakeup by switch|
**Table 2** Description of the wakeup source configuration
| Item| Type| Description|
| -------- | -------- | -------- |
| enable | bool | Whether to enable wakeup listening|
| click | int | Number of clicks|
4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of wakeup source configuration to pack the `power_wakeup.json` file to the `/vendor/etc/power_config` directory. The configuration is as follows:
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.
}
```
5. 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:
"//vendor/hihope/rk3568/power_manager/profile:wakeup_config" // Add the configuration for building of wakeup_config.
]
}
},
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/power_manager/` is the folder path, `profile` is the folder name, and `wakeup_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
```shell
./build.sh --product-name rk3568 --ccache
```
7. Burn the customized version to the DAYU200 development board.
### Debugging and Verification
1. Customize wakeup sources in the `power_wakeup.json` file.
```json
{
"powerkey":{
"enable":true
},
"keyborad":{
"enable":true
},
"mouse":{
"enable":true
},
"touchscreen":{
"enable":false,
"click":2
},
"touchpad":{
"enable":false
},
"pen":{
"enable":false
},
"lid":{
"enable":false
},
"switch":{
"enable":false
}
}
```
2. After the device is powered on, press the power button to switch the device to the sleep mode. Then, press the power button again.
The device screen is turned on and the device is woken up.
3. Press the power button to switch the device to the sleep mode, and then press the keyboard.
The device screen is turned on and the device is woken up.
4. Press the power button to switch the device to the sleep mode, and then move the mouse.
The device screen is turned on and the device is woken up.