1

我正在使用 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 来提取当前频率。但是每当我运行这个命令时,我都会设置最大频率,而当我从 DDMS 中提取时,文件会显示不同的频率。你能建议可能是什么错误吗?

我的代码:

public String getCurrentCPU()
    {
        Process process;
        try{
        Runtime rt = Runtime.getRuntime();
        process=rt.exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq");
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(process.getInputStream()));
        int read;
        char[] buffer = new char[4096];
        StringBuffer output = new StringBuffer();
        while ((read = reader.read(buffer)) > 0) {
            output.append(buffer, 0, read);
        }        
        reader.close();
        process.destroy();
        //process.waitFor();
        return output.toString();
        }       catch (IOException e) {
            throw new RuntimeException(e);
        } 
    }
4

0 回答 0