• Android 如何获取CPU的温度


    最近的项目有需求要获取CPU的温度,在网上找了一些资料,基本算是解决了问题:

    进入adb shell执行下面的命令:

    shell@android:/ $ cat /etc/thermald.conf 

    这个不同设备得到的结果可能是不已样的,有这样的:

    sampling         5000
    
    [tsens_tz_sensor0]
    sampling         5000
    thresholds       10
    thresholds_clr   5
    actions          none
    action_info      0
    
    [tsens_tz_sensor1]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor2]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor3]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor4]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor5]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor6]
    sampling         5000
    thresholds       60
    thresholds_clr   57
    actions          none
    action_info      0
    
    [tsens_tz_sensor7]
    sampling         1500
    thresholds       95     120
    thresholds_clr   87     115
    actions          cpu    cpu+shutdown
    action_info      384000 384000+5000
    
    [tsens_tz_sensor8]
    sampling         1500
    thresholds       95     120
    thresholds_clr   87     115
    actions          cpu    cpu+shutdown
    action_info      384000 384000+5000
    
    [tsens_tz_sensor9]
    sampling         1500
    thresholds       95     120
    thresholds_clr   87     115
    actions          cpu    cpu+shutdown
    action_info      384000 384000+5000
    
    [tsens_tz_sensor10]
    sampling         1500
    thresholds       95     120
    thresholds_clr   87     115
    actions          cpu    cpu+shutdown
    action_info      384000 384000+5000
    
    [batt_therm]
    sampling         1500
    thresholds       410             420             430             440             450
    thresholds_clr   400             410             420             430             440
    actions          cpu+lcd+battery cpu+lcd+battery cpu+lcd+battery cpu+lcd+battery cpu+lcd+battery
    action_info      1350000+192+0   1134000+181+1   1026000+181+1   918000+171+2    810000+171+3

    这样的:

    sampling         5000
    
    [tsens_tz_sensor0]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor1]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor2]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor3]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor4]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor5]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor6]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor7]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor8]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor9]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000
    
    [tsens_tz_sensor10]
    sampling         1000
    thresholds       60      90      95      100     105     110     115     120
    thresholds_clr   57      85      90      95      100     105     110     115
    actions          cpu     cpu     cpu     cpu     cpu     cpu     cpu     shutdown
    action_info      1512000 1188000 918000  756000  648000  540000  486000  5000

    还有压根就不能执行的情况。

    个人理解,这个就是对应不同设备的温度传感器。

    然后,我们可以看到,有的传感器是针对CPU的。那么到下面的目录:

    shell@android:/sys/class/thermal $

    你可以找到这些传感器,然后进入对应的传感器,用cat指令可以知道温度了。

    shell@android:/sys/class/thermal/thermal_zone7 $ cat temp

    ## cat type 的话应该可以获取传感器的类型信息。

    虽然解决了问题,但是不是很理解。比如,这个是linux系统的通用设置吗? 其他传感器都对应了什么? 等等。

  • 相关阅读:
    【python学以致用】给PDF添加书签目录,Python解析书签JSON python王者归来 带书签版
    Difference between os.path.exists and os.path.isfile?
    Python的os.listdir配合os.path.isdir不返回目录
    selenium + geckodriver报 Message: Unable to find a matching set of capabilities
    TypeError: string argument without an encoding
    使用gevent时遇到的一些问题记录
    【JavaSE】基本类型包装类(以Integer代表)
    【JavaSE】其他常用类:Math、Random、Calendar、System
    【JavaSE】黑马程序员 刘意 基础部分笔记
    【JavaSE】集合容器的总结(全)
  • 原文地址:https://www.cnblogs.com/beautiful-scenery/p/3613874.html
Copyright © 2020-2023  润新知