How do I get the temperature of my phone via ADB?



  • At work, I run lots of automated software testing on Android phones. They stay permanently plugged into a development machine, and are given jobs to run via ADB. I'd very much like to be able to monitor their temperatures, and doing so via ADB would be the easy way.



  • This is simple, on Android 10 or later, once you find out how.

    adb shell dumpsys thermalservice

    On my Samsung A52 5G with Android 12, this produces, with values apparently in Celsius.

    IsStatusOverride: false
    ThermalEventListeners:
            callbacks: 1
            killed: false
            broadcasts count: -1
    ThermalStatusListeners:
            callbacks: 4
            killed: false
            broadcasts count: -1
    Thermal Status: 0
    Cached temperatures:
            Temperature{mValue=0.0, mType=2, mName=SUBBAT, mStatus=0}
            Temperature{mValue=0.0, mType=2, mName=SUBBATRAW, mStatus=0}
            Temperature{mValue=25.6, mType=0, mName=AP, mStatus=0}
            Temperature{mValue=25.7, mType=5, mName=PA, mStatus=0}
            Temperature{mValue=23.8, mType=2, mName=BAT, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRB, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRF, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRP, mStatus=0}
            Temperature{mValue=0.0, mType=4, mName=USB, mStatus=0}
    HAL Ready: true
    HAL connection:
            ThermalHAL 2.0 connected: yes
    Current temperatures from HAL:
            Temperature{mValue=25.6, mType=0, mName=AP, mStatus=0}
            Temperature{mValue=23.8, mType=2, mName=BAT, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRB, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRF, mStatus=0}
            Temperature{mValue=24.7, mType=3, mName=LRP, mStatus=0}
            Temperature{mValue=25.7, mType=5, mName=PA, mStatus=0}
            Temperature{mValue=0.0, mType=2, mName=SUBBAT, mStatus=0}
            Temperature{mValue=0.0, mType=2, mName=SUBBATRAW, mStatus=0}
            Temperature{mValue=0.0, mType=4, mName=USB, mStatus=0}
    Current cooling devices from HAL:
    Temperature static thresholds from HAL:
    

    My very cheap Chinese Android 10 tablet says:

    IsStatusOverride: false
    ThermalEventListeners:
            callbacks: 1
            killed: false
            broadcasts count: -1
    ThermalStatusListeners:
            callbacks: 2
            killed: false
            broadcasts count: -1
    Thermal Status: 0
    Cached temperatures:
            Temperature{mValue=30.8, mType=3, mName=test temperature sensor, mStatus=0}
    HAL Ready: true
    HAL connection:
            ThermalHAL 2.0 connected: yes
    Current temperatures from HAL:
            Temperature{mValue=30.8, mType=3, mName=test temperature sensor, mStatus=0}
    Current cooling devices from HAL:
            CoolingDevice{mValue=100, mType=0, mName=test cooling device}
    

    That's probably the default configuration in Android 10.

    The underlying Android service for this is https://source.android.com/devices/architecture/hidl/thermal-mitigation . It says that HAL 2.0 appeared at Android 10, and previous versions only had HAL 1.0. The only pre-Android 10 device I've tried so far was a Black Shark 2 with Android 9, where dumpsys thermalservice didn't produce any output.

    I have only figured out parts of the mName values so far. It seems clear that the names vary between manufacturers, but the mType values seem to be consistent.

    • AP = Application Processor - maybe the SoC, or the CPU? mType 0.
    • BAT = BATTERY = Battery. mType 2, which makes it very plausible that SUBBAT and SUBBATRAW are battery-related, as the names suggest.
    • CPU = CPU. mType 0.
    • GPU = GPU. mType 1.
    • NPU = Neural Processing Unit? mType 9.
    • PA = Power Amplifier. mType 5.
    • SKIN = Device case, presumably. mType 3. That suggests that LRB, LRF and LRP on the Samsung are something to do with the case or buttons, and that the sole sensor on the cheap tablet is monitoring the case.
    • USB = Universal Serial Bus, presumably. mType 4.

    http://newandroidbook.com/ddb/RealMeGTNeo/dumpsys.html for some of those.

    The mStatus values are the power throttling status, from 0 (no throttling) to 6 (shut down due to heat).


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2