所以apparantly的信息存儲在/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
。如果你閱讀文件,你會得到這種州長。您也可以通過拉動文件/proc/cpuinfo
來獲得更多cpu信息,但是如果您這樣做,則不包括州長。
private String getGovernor() {
StringBuffer sb = new StringBuffer();
//String file = "/proc/cpuinfo"; // Gets most cpu info (but not the governor)
String file = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"; // Gets governor
if (new File(file).exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(new File(file)));
String aLine;
while ((aLine = br.readLine()) != null)
sb.append(aLine + "\n");
if (br != null)
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}