How to read cpu frequency on android device [closed]
Solution 1:
To have frequency on Android, just read these special files in /sys directory:
#cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
#cat "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"
#cat "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
You will have current, min and max Frequency allowed.
Solution 2:
not MHz, but at least something. bogoMIPS value can be useful for you.
private String ReadCPUinfo()
{
ProcessBuilder cmd;
String result="";
try{
String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while(in.read(re) != -1){
System.out.println(new String(re));
result = result + new String(re);
}
in.close();
} catch(IOException ex){
ex.printStackTrace();
}
return result;
}
Solution 3:
If you are interested in how long your system spent in what state, check out the file
/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
I'm not sure, whether root access is necessary for that.