How to get CPU temperature in Android

廉价感情. 提交于 2019-11-27 21:44:21

问题


Sensor Type TYPE_TEMPERATURE has been deprecated [since Android 2.3] probably which was giving info about CPU temperature. Now we have Sensor Type TYPE_AMBIENT_TEMPERATURE which will provide us room temperature (none of my use, & btw not all devices&/Android versions support it)

I checked few apps which measures CPU temperature. Probably they're reading system files. I tried locating, in some devices I'm able to locate it inside following path:

sys/devices/virtual/thermal/thermal_zone0/temp

The structure bit varies from vendor to vendor & also the unit of measurement. fine! But in many devices I'm simply unable to locate any such files & in same devices those apps work! I wonder, how!

How can we measure CPU temperature in Android?


回答1:


I've used the following path:

sys/class/hwmon/hwmonX/temp1_input

that works on the most phones




回答2:


Deprecated does not equal removed! If you find that the device still offers the deprecated sensor type, then go ahead and continue to use it.

Part of the reason for deprecating the old sensor name was that on seeing a temperature sensor, the public expectation was that the temperature would be that of the ambient air. However in many cases the sensor was part of/so close to the CPU that it ended up being mostly a reflection of the CPU temperature.

By adding a new (optional) sensor type that is explicitly the air temperature, this expectation can be better managed:

  • if you want the air temperature, use the new sensor if available
  • if you don't care what you are measuring (but in most practical cases will end up with something heavily influenced by the CPU temperature), use the deprecated sensor if available


来源:https://stackoverflow.com/questions/24797869/how-to-get-cpu-temperature-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!