Android 有意思的脚本(打印温度)

https://github.com/LineageOS/android_hardware_google_pixel/blob/lineage-18.1/thermal/device.mk

 

#!/system/bin/sh

timeout=$(expr $1 \* 1000)     

while true
do
    cpu0=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq)
    cpu1=$(cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq)
    cpu2=$(cat /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq)
    cpu3=$(cat /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq)
    temp=$(cat /sys/class/thermal/thermal_zone0/temp)
    time=$(date +%Y-%m-%d\ %H:%M:%S)

    printf "%19s cpu0=%7s cpu1=%7s cpu2=%7s cpu3=%7s temperature=%s\n" "$time" $cpu0 $cpu1 $cpu2 $cpu3 $temp

    usleep $timeout
done

 

log打印log

#!/vendor/bin/sh

if [ $# -eq 1 ]; then
  interval=$1
else
  exit 1
fi

while true
do
  logline="tz:"
  for f in /sys/class/thermal/thermal*
  do
    temp=`cat $f/temp`
    logline+="|$temp"
  done
  logline+=" cdev:"
  for f in /sys/class/thermal/cooling_device*
  do
    cur_state=`cat $f/cur_state`
    logline+="|$cur_state"
  done
  log -p w -t THERMAL_LOG $logline
  sleep $interval
done

 

posted on 2021-11-10 10:45  二的次方  阅读(202)  评论(1编辑  收藏  举报