Thermal Mitigation

本文介绍了Android 10中引入的热管理系统,包括Thermal HAL 2.0和Thermalservice,以及如何通过传感器监控和调整设备温度,确保用户体验在过热时得到保护。制造商需遵循指南报告温度和限制,开发者则利用API进行优化,应对不同级别的热状态通知.
部署运行你感兴趣的模型镜像

Thermal mitigation is needed when a device starts to overheat. As algorithm complexity, system core frequencies, and levels of integration continually increase, with packaging and form-factor sizes decreasing, thermal mitigation has become increasingly important.

Android 10 introduced a thermal system in the Android framework and a new version of the HAL that abstracts the interface to the thermal subsystem hardware devices. The hardware interface includes temperature sensors and thermistors for the skin, battery, GPU, CPU, and USB port. The device skin temperature is the most important one to track to keep the device surface temperature within specified thermal limits.

With the Android framework, device manufacturers and app developers can use thermal data to ensure a consistent UX if a device begins to overheat. For example, when a system undergoes thermal stress, jobscheduler jobs get throttled, and if necessary, a framework thermal shutdown is initiated. Apps that receive thermal-stress notifications through a registered callback (in the PowerManager class) can gracefully adjust their UX.

Thermal HAL

Android 9 and lower utilized a polling interface defined in Thermal HAL 1.0 to obtain temperature readings. The legacy Thermal HAL allowed the Android framework and other trusted clients (such as a device manufacturer's HAL) to read the current temperature and product-policy specific throttling and shutdown thresholds for each sensor through the same API.

Thermal HAL 2.0, introduced in Android 10, provides multiple clients with thermal sensor readings and associated severity levels to indicate thermal stress. Figure 1 shows two warning messages from the Android System UI, created based on IThermalEventListener for the USB_PORT and SKIN sensors, respectively, when they reach the EMERGENCY severity level.

Figure 1. Overheat warnings

The current temperatures are retrieved for the different  types of thermal sensors through  IThermal HAL. Each function call returns a status value of either SUCCESS or FAILURE. If SUCCESS is returned, the process continues. If FAILURE is returned, an error message (which must be human-readable) goes to status.debugMessage.

Besides being a polling interface that returns the current temperatures, the HIDL callback  IThermalChangedCallback can be used with the callback interface from thermal HAL clients, such as the framework’s thermal service. For example, RegisterIThermalChangedCallback and UnregisterIThermalChangedCallback register/unregister severity-changed events. If the thermal severity of a given sensor has changed, notifyThrottling sends a thermal throttling event callback to thermal-event listeners.

In addition to thermal sensor information, a list of the cooling devices that have undergone mitigation is exposed in getCurrentCoolingDevices. The list order is persistent, even if a cooling device has gone offline. Device manufacturers can use it to collect statsd metrics.

For more information, see the  Reference implementation. While you may add your own extensions, you must never disable the thermal mitigation function.

Thermal service

In Android 10, the thermal service in the framework provides constant monitoring using the various mitigation signals from Thermal HAL 2.0, and gives throttling severity feedback to its clients. These include internal components and Android apps. The service utilizes two binder callback interfaces, IThermalEventListener and IThermalStatusListener, exposed as callbacks. The former is for internal platform and device manufacturer use, and the latter is for Android apps.

Through the callback interfaces, a device’s current thermal status is retrievable as an integer value ranging from 0x00000000 (no throttling) to 0x00000006 (device shutdown). Only a trusted system service, such as an Android API or device manufacturer API, can access the detailed thermal sensor and thermal event information. Figure 2 provides a model of the thermal mitigation process flow in Android 10.

Figure 2. Thermal mitigation process flow in Android 10

Device manufacturer guidelines

Device manufacturers must implement the HIDL aspect of Thermal HAL 2.0 (as provided in IThermal.hal) to report device temperature sensor and throttling status. If you’re a developer, use this to enhance app UX under thermal stress.

Anything that throttles device performance, including battery power constraints, must be reported through the thermal HAL. To ensure this happens, put all sensors that may indicate a need for mitigation (based on status changes) into the thermal HAL, and report the severity of any mitigation actions taken. The temperature value returned from a sensor reading doesn’t have to be the actual temperature, so long as it accurately reflects the corresponding severity threshold. For example, you may pass different numerical values instead of your actual temperature threshold values, or you may build guardbanding into threshold specifications to provide hysteresis. However, the severity corresponding to that value must match what’s needed at that threshold. (For example, you may decide to return 72°C as your critical temperature threshold, when in reality the actual temperature is 65°C, and it corresponds to the critical severity you specified.) The severity level must always be accurate for best thermal framework functionality.

To read more about the threshold levels in the framework and how they correspond to mitigation actions, see the usage suggestions for each thermal status code.

Thermal API

Apps can add and remove listeners, and access thermal status information through the  PowerManager class. The IThermal interface provides all the functionality needed, including returning the thermal status values. The  IThermal binder interface is wrapped as the OnThermalStatusChangedListener interface, which apps can use when registering or removing thermal status listeners.

The Android thermal APIs have both callback and polling methods for apps to be notified of the thermal severity levels through status codes, which are defined in the PowerManager class. The methods are

The status codes translate to specific throttling levels, which can be used for gathering data, and for designing an optimal UX. For example, apps may receive a status of 0x0 (NONE), which may later change to 0x1 (LIGHT). Marking the 0x0 state as t0, then measuring the time lapsed from status NONE to status LIGHT (t1) enables device manufacturers to design and test mitigation strategies for specific use cases. You may want to use the thermal status codes in the ways suggested below.

Thermal status code Description and suggested use
NONE (0x0)No throttling.
Use this status to implement protective actions, such as detecting the start of the time period (t0 to t1) from NONE (0x0) to LIGHT (0x1).
LIGHT (0x1)Light throttling. UX isn't impacted.
Use gentle device mitigation for this stage. For example, skip boosting or using inefficient frequencies, but only on big cores.
MODERATE (0x2)Moderate throttling. UX isn't greatly impacted.
Thermal mitigation impacts foreground activities, so apps should reduce power immediately.
SEVERE (0x3)Severe throttling. UX is largely impacted.
In this stage, device thermal mitigation should limit the system capacity. This may cause side effects, such as display jank and audio jitter.
CRITICAL (0x4)Platform has done everything to reduce power.
The device thermal mitigation software has placed all components to run at their lowest capacity.
EMERGENCY (0x5)Key components in the platform are shutting down due to thermal conditions.
Device functionalities are limited. This is the last warning before device shutdown. At this stage some functions, such as the modem, cellular data are turned off completely.
SHUTDOWN (0x6)Shutdown immediately.
Due to the severity of this stage, apps may not be able to receive this notification.

API Testing

Device manufacturers must pass the VTS test for thermal HAL, and may use emul_temp from the kernel sysfs interface to simulate temperature changes.

您可能感兴趣的与本文相关的镜像

ComfyUI

ComfyUI

AI应用
ComfyUI

ComfyUI是一款易于上手的工作流设计工具,具有以下特点:基于工作流节点设计,可视化工作流搭建,快速切换工作流,对显存占用小,速度快,支持多种插件,如ADetailer、Controlnet和AnimateDIFF等

### Android Thermal 原生温控机制实现方法 #### 1. 理解 Thermal HAL 接口 为了使设备能够报告温度并执行热管理操作,设备制造商必须实现 `Thermal HAL`。对于 Android 10 至 13 版本,这涉及到实现 `Thermal HAL 2.0` 的 HIDL 接口 (`IThermal.hal`) [^2]。 #### 2. 温度监测与响应逻辑 当温度达到预设阈值时,系统会触发相应的动作。例如,在高通平台中,如果温度传感器检测到特定温度(记作 α),并且该温度达到了设定的临界值 β,则可能会触发系统的重置机制 [^1]: ```c++ if (currentTemperature >= criticalThreshold) { // Trigger system reset or other thermal mitigation actions } ``` #### 3. 自定义温控策略 某些情况下,默认的温控方案可能不够精细或不适合具体应用场景。比如针对 Wi-Fi 模块的温度变化较大这一情况,可以通过修改配置文件如 `WCNSS_qcom_cfg.ini` 来调整温控参数,甚至完全禁用默认的温控措施而采用自定义脚本来更好地适应实际需求 [^3]: ```ini ; Example of customizing WCNSS configuration in WCNSS_qcom_cfg.ini [WiFi_Temperature_Control] EnableCustomControl=1 MaxOperatingTemp=85 ; Set maximum operating temperature to 85°C MinCoolDownTemp=70 ; Define minimum cooldown temperature as 70°C ``` #### 4. 使用第三方应用增强控制 虽然不推荐绕过官方渠道来改变硬件行为,但确实存在一些应用程序可以帮助用户更灵活地管理和优化其设备上的温控设置。然而需要注意的是这类工具通常具有潜在风险,并且可能导致保修失效或其他不可预见的问题 [^4].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值