roger-yu

基本概念

参阅下面两篇文章,就可以大概了解一些概念的内容了

https://source.android.com/devices/architecture/hidl/thermal-mitigation

https://blog.csdn.net/feelabclihu/article/details/107873407

 

功能实现

这里我们不做讲解,直接给参考例子,基本拿来可以用

》Thermal HAL 2.0的实现

https://github.com/LineageOS/android_hardware_google_pixel/tree/lineage-18.1/thermal

》sepolicy相关设置

https://github.com/LineageOS/android_hardware_google_pixel-sepolicy/tree/lineage-19.0/thermal

》thermal_info_config配置文件,根据自身系统配置

https://github.com/LineageOS/android_device_google_taimen/blob/lineage-17.1/thermal_info_config.json

 

测试

技巧一:

执行 adb shell dumpsys thermalservice 可以查看温度的信息,例如:

 

技巧二:

Linux kernel中有模拟温度的方式,编内核时打开选项开关CONFIG_THERMAL_EMULATION=y,这样就会看到如下这个值:

/sys/class/thermal/thermal_zone0/emul_temp

之后测试可以:

echo  100000 > /sys/class/thermal/thermal_zone0/emul_temp

然后使用dumpsys thermalservice 查看这个模拟的温度值

 

VTS/CTS测试

几个相关的测试项

run vts -m VtsHalThermalV2_0TargetTest

run vts -m VtsHalThermalV1_0TargetTest

run vts -m VtsHalThermalV1_1TargetTest

run cts -m CtsOsTestCases -t android.os.cts.PowerManager_ThermalTest

 

补充

/frameworks/base/services/core/java/com/android/server/power/ThermalManagerService.java

Android framework中有去注册监听器,检测Thermal HAL 的回调事件,高温时可能出发shutdown

private void shutdownIfNeeded(Temperature temperature) {
        if (temperature.getStatus() != Temperature.THROTTLING_SHUTDOWN) {
            return;
        }

        final PowerManager powerManager = getContext().getSystemService(PowerManager.class);
        switch (temperature.getType()) {
            case Temperature.TYPE_CPU:
                // Fall through
            case Temperature.TYPE_GPU:
                // Fall through
            case Temperature.TYPE_NPU:
                // Fall through
            case Temperature.TYPE_SKIN:
                powerManager.shutdown(false, PowerManager.SHUTDOWN_THERMAL_STATE, false);
                break;
            case Temperature.TYPE_BATTERY:
                powerManager.shutdown(false, PowerManager.SHUTDOWN_BATTERY_THERMAL_STATE, false);
                break;
        }
    }

 

关于温度的几个等级可以参考 https://source.android.com/devices/architecture/hidl/thermal-mitigation

触发这些事件的温度就是我们在thermal_info_config.json配置的, 如果不需要触发回调事件可以设置 "Monitor":false

    "Sensors":[
        {
            "Name":"cpu-thermal",
            "Type":"CPU",
            "HotThreshold":[
                "NAN",
                "NAN",
                "NAN",
                95.0,
                "NAN",
                "NAN",
                125.0
            ],
            "VrThreshold":"NAN",
            "Multiplier":0.001,
            "Monitor":false
        }
    ]

 

相关文章:

猜你喜欢