2016-09-29 93 views
0

我正在製作一個應用程序,其行爲有所不同,具體取決於CPU調控器的設置(例如Performance,powersave等)。不過,我不確定如何在應用中獲得當前設置。有沒有人知道該命令將在Java類中訪問它?如何讓我的CPU調控器在Android應用程序中?

(要看到它在手機上,去Settings->Performance->Profile以及Settings->Performance->Processor->CPU Governor。)

回答

0

所以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(); 
} 
相關問題