当前位置: 首页 > news >正文

openharmony之充电空闲状态定制开发

概述

简介

OpenHarmony系统默认集成充电空闲状态检测功能。该功能通过综合评估设备热等级、电池电量、充电状态及充电电流等参数,判断设备是否满足空闲状态条件,从而触发后台任务执行。由于不同设备的硬件特性存在差异,各产品需根据实际设计需求进行定制化配置。

本指导文档以DAYU200开发套件为例,详细说明定制开发流程,开发者可根据具体产品需求调整实现方案。
关于电源管理模块学习欢迎订阅专栏文章《openharmony之电源管理模块需求定制总结》

约束与限制

  • 配置文件存储路径需遵循产品配置策略,示例中采用/vendor路径,实际开发中应根据项目规范调整
  • 热等级阈值需结合设备散热能力设定,建议通过温控测试确定合理范围
  • 电池参数配置应符合电池安全规范,避免设置超出硬件规格的电流阈值

开发流程

开发环境要求

  • 硬件平台:DAYU200/Hi3516DV300等标准系统开发板
  • 开发环境:基于Linux的编译环境

定制开发步骤

1. 创建配置目录

在产品专属目录下创建温控配置目录:

mkdir -p /vendor/hihope/rk3568/thermal
2. 配置文件准备

从默认配置目录获取模板文件:

cp -r /services/native/profile/thermal_service_config.xml /vendor/hihope/rk3568/thermal/
3. 配置参数说明

XML配置文件包含以下关键参数:

参数项数据类型取值范围配置说明
thermallevelint0-7设备热等级阈值,当当前热等级≤该值时进入空闲状态
socint0-100电池电量阈值,当电量≥该值时进入空闲状态
chargingint0/1充电状态标识,1表示正在充电
currentint≥0(单位:mA)充电电流阈值,当实际电流≥该值时进入空闲状态

打包路径:/vendor/etc/thermal_config/hdf
示例配置:

<idle name="charging"><thermallevel>1</thermallevel>  <!-- 热等级≤1 --><soc>90</soc>                   <!-- 电量≥90% --><charging>1</charging>          <!-- 正在充电 --><current>1000</current>         <!-- 电流≥1000mA -->
</idle>
4. 构建配置文件

创建BUILD.gn构建配置:

import("//build/ohos.gni")ohos_prebuilt_etc("thermal_service_config") {source = "thermal_service_config.xml"relative_install_dir = "thermal_config"install_images = [ chipset_base_dir ]part_name = "product_rk3568"
}
5. 集成编译配置

ohos.build中添加编译模块:

{"parts": {"product_rk3568": {"module_list": [..."//vendor/hihope/rk3568/thermal/profile:thermal_service_config"]}},"subsystem": "product_hihope"
}
6. 编译与烧录

执行编译命令:

./build.sh --product-name rk3568 --ccache

将生成的固件烧录至开发板完成部署。

调测验证

状态检测方法

  1. 通过HDC工具进入设备shell:
    hdc shell
    
  2. 执行状态查询命令:
    hidumper -s 3303 -a -i
    

预期输出示例

-------------------------------[ability]-------------------------------
----------------------------------ThermalService---------------------------------
thermallevel: 1
soc: 90
charging: 1
current: 1000

参考资源

  • 默认配置文件路径:/services/native/profile/thermal_service_config.xml
  • 系统配置文档:/resources/base/etc/thermal_config/thermal_service_config.xml
  • 温控服务源码:/services/native/thermal/thermal_service.cpp

注意:实际开发中应结合设备硬件规格进行参数优化,建议通过温升测试验证配置有效性。电流阈值设置应留有安全余量,避免触发过流保护。

附录:完整配置文件示例

<?xml version="1.0" encoding="UTF-8"?>
<!--Copyright (c) 2022-2023 Huawei Device Co., Ltd.Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.--><thermal version="0.01" product="lya"><base><item tag="history_temp_count" value="10"/><item tag="temperature_query_enum" value="soc,battery,shell,cpu,charger,ambient,ap,pa"/><item tag="sim_tz" value="1"/></base><level><sensor_cluster name="screenoff_charge" sensor="battery"><state screen="0" charge="1"/><item level="1" threshold="40000" threshold_clr="38000"/><item level="2" threshold="43000" threshold_clr="41000"/></sensor_cluster><sensor_cluster name="base_safe" sensor="battery,charger,cpu,soc"><item level="1" threshold="40000,38000,30000,40000" threshold_clr="38000,36000,28000,38000"/><item level="2" threshold="43000,41000,32000,42000" threshold_clr="41000,39000,30000,40000"/><item level="3" threshold="46000,44000,34000,44000" threshold_clr="44000,42000,32000,42000"/><item level="4" threshold="48000,46000,36000,46000" threshold_clr="46000,44000,34000,44000"/></sensor_cluster><sensor_cluster name="warm_5G" sensor="pa" aux_sensor="ambient"><item level="1" threshold="40000" threshold_clr="38000" aux_trigger_range="5000_35000"/><item level="2" threshold="43000" threshold_clr="41000" aux_trigger_range="5000_35000"/><item level="3" threshold="45000" threshold_clr="44000" aux_trigger_range="5000_35000"/></sensor_cluster><sensor_cluster name="warm_safe" sensor="ap,soc" aux_sensor="ambient,shell"><item level="1" threshold="75000,30000" threshold_clr="71000,28000" aux_trigger_range="0_900000,0_40000"/></sensor_cluster><sensor_cluster name="high_safe" sensor="shell"><item level="1" threshold="40000" threshold_clr="38000" temp_rise_rate="1.5"/><item level="2" threshold="43000" threshold_clr="41000" temp_rise_rate="1.5"/><item level="3" threshold="46000" threshold_clr="44000" temp_rise_rate="1.5"/><item level="4" threshold="48000" threshold_clr="47000" temp_rise_rate="1.5"/></sensor_cluster><sensor_cluster name="cold_safe" sensor="battery,soc" desc="1"><item level="1" threshold="-9000,-8000" threshold_clr="-6000,-5000"/><item level="2" threshold="-14000,-13000" threshold_clr="-11000,-10000"/><item level="3" threshold="-19000,-18000" threshold_clr="-16000,-15000"/><item level="4" threshold="-21000,-20000" threshold_clr="-20000,-19000"/></sensor_cluster></level><state><item name="scene" param="cam,call,game,test"/><item name="screen"/><item name="charge"/></state><action><item name="airplane"/><item name="cpu_big"/><item name="cpu_med"/><item name="cpu_lit"/><item name="gpu"/><item name="boost" event="1"/><item name="isolate" event="1"/><item name="lcd"/><item name="volume" uid="2001,2002"/><item name="current_sc" protocol="current" param="sc" event="1"/><item name="current_buck" protocol="current" param="buck" event="1"/><item name="voltage_sc" protocol="voltage" param="sc" event="1"/><item name="voltage_buck" protocol="voltage" param="buck" event="1"/><item name="process_ctrl" param="32,64,128,256" event=""/><item name="shut_down" event="0"/><item name="thermallevel" event="1"/><item name="popup"/><item name="test"/></action><policy><config name="base_safe" level="1"><airplane>0</airplane><lcd>1.00</lcd><lcd scene="cam">0.99</lcd><lcd scene="call">0.98</lcd><lcd scene="game">0.97</lcd><lcd scene="test">0.91</lcd><cpu_big>1992000</cpu_big><cpu_med>1991500</cpu_med><cpu_lit>1991200</cpu_lit><test>99999</test><process_ctrl>3</process_ctrl><cpu_big scene="cam" charge="1">1991800</cpu_big><cpu_big scene="cam" charge="0">1991600</cpu_big><gpu screen="0">524288</gpu><gpu screen="1">512000</gpu><thermallevel>1</thermallevel><current_sc>1800</current_sc><current_sc scene="cam">1200</current_sc><current_buck>1200</current_buck><voltage_sc>4000</voltage_sc><voltage_buck>3000</voltage_buck><volume>1.0</volume><boost>1</boost><isolate>0</isolate></config><config name="base_safe" level="2"><airplane>1</airplane><lcd>0.90</lcd><lcd scene="cam">0.89</lcd><lcd scene="call">0.88</lcd><lcd scene="game">0.87</lcd><cpu_big>1991000</cpu_big><cpu_med>1990500</cpu_med><cpu_lit>1990200</cpu_lit><process_ctrl>2</process_ctrl><cpu_big scene="cam" charge="1">1990800</cpu_big><cpu_big scene="cam" charge="0">1990600</cpu_big><gpu screen="0">499712</gpu><gpu screen="1">487424</gpu><thermallevel>2</thermallevel><current_sc>1500</current_sc><current_sc scene="cam">1000</current_sc><current_buck>1000</current_buck><voltage_sc>3000</voltage_sc><voltage_buck>2000</voltage_buck><volume>0.8</volume><boost>1</boost><isolate>1</isolate></config><config name="base_safe" level="3"><lcd>0.80</lcd><lcd scene="cam">0.79</lcd><lcd scene="call">0.78</lcd><lcd scene="game">0.77</lcd><cpu_big>1990000</cpu_big><cpu_med>1989500</cpu_med><cpu_lit>1989200</cpu_lit><process_ctrl>1</process_ctrl><cpu_big scene="cam" charge="1">1989800</cpu_big><cpu_big scene="cam" charge="0">1989600</cpu_big><gpu screen="0">475136</gpu><gpu screen="1">462848</gpu><thermallevel>3</thermallevel><current_sc>1300</current_sc><current_sc scene="cam">800</current_sc><current_buck>800</current_buck><voltage_sc>2000</voltage_sc><voltage_buck>1000</voltage_buck><volume>0.7</volume><shut_down>1</shut_down><boost>0</boost><isolate>2</isolate></config><config name="warm_5G" level="1"><lcd>0.70</lcd><thermallevel>4</thermallevel><process_ctrl>2</process_ctrl></config><config name="warm_5G" level="2"><lcd>0.60</lcd><process_ctrl>3</process_ctrl><thermallevel>5</thermallevel></config><config name="warm_5G" level="3"><thermallevel>7</thermallevel></config><config name="warm_safe" level="1"><process_ctrl screen="1">3</process_ctrl><shut_down screen="1">1</shut_down><thermallevel>6</thermallevel></config><config name="cold_safe" level="1"><current_sc>1850</current_sc><thermallevel>0</thermallevel></config><config name="cold_safe" level="2"><current_sc>1550</current_sc><thermallevel>0</thermallevel></config><config name="cold_safe" level="3"><current_sc>1150</current_sc><thermallevel>0</thermallevel></config></policy><fan><sensor_cluster name="fan_fault_detect" sensor="soc,gpu,fan"><item fault="1" threshold="50000,50000,500"/><item fault="2" threshold="30000,30000,1500"/></sensor_cluster></fan><idle name="charging"><thermallevel>1</thermallevel>  <!-- thermal level is equal or less than 1 --><soc>80</soc> <!-- battery soc is equal or more than 80% --><charging>1</charging> <!-- battery is charging --><current>1000</current> <!-- battery charging current is equal or more than 1000mA --></idle>
</thermal>
http://www.dtcms.com/a/392366.html

相关文章:

  • 【开题答辩全过程】以 python的线上订餐系统为例,包含答辩的问题和答案
  • (附源码)基于Spring Boot的校园心理健康服务平台的设计与实现
  • 微信小程序开发教程(十八)
  • 寰宇光锥舟架构图
  • Spring Bean生命周期全面解析
  • [vibe code追踪] 侧边栏UI管理器 | showSidebarContent
  • 嵌入式ARM架构学习9——IIC
  • 多线程——线程安全的练习加感悟
  • 使用 TwelveLabs 的 Marengo 视频嵌入模型与 Amazon Bedrock 和 Elasticsearch
  • Windows 11 下 Notepad++ 等应用无法启动问题排查修复
  • 面向口齿不清者的语音识别新突破:用大模型拯救“听不懂”的声音
  • 服装企业优化信息化管理系统的最佳软件选择
  • 多阶段构建镜像
  • 推荐一个开源服务器一键自动重装系统脚本:reinstall
  • 【C++进阶】C++11 的新特性 | lambda | 包装器
  • 2.【QT 5.12.12 安装 Windows 版本】
  • Rust_2025:阶段1:day6.3 macro
  • 【Qt开发】输入类控件(一)-> QLineEdit
  • python10——组合数据类型(集合)
  • 分布式专题——14 RabbitMQ之集群实战
  • WEEX唯客的多维度安全守护
  • 深度学习环境配置
  • 生鲜速递:HTTP 的缓存控制
  • ​​Snipaste 2.10.1.dmg截图安装教程|Mac电脑拖拽安装详细步骤​
  • 10.1.1 使用python完成第一个遗传算法
  • C语言内存精讲系列(二十九):C 语言堆区内存进阶与动态内存实战
  • 6G量子通信融合:破解未来网络的安全与效能密码
  • C#练习题——泛型实现单例模式和增删改查
  • 网关登录校验
  • Kubernetes Fluent Bit Pod Pending 问题解决方案