How to get all the thermal information on android programmatically (CPU [all Cores], GPU, Device, etc.)?

强颜欢笑 提交于 2021-01-28 06:20:23

问题


I am trying to extract thermal information in an android application programmatically but there is not enough documentation to do so.

The things which I want to extract are like this:

vbal_low - 37.9 C

gold-virt-max-step - 28.2 C

cpu3-silver-lowf - 27.8 C

msm-therm-adc - 26 C

mdm-dsp - usr - 30.1 C

gpu0-lowf - 27.5 C

wlan-lowf - 28.1 C

and there are like other 50 or so temperature values, how to do so?


回答1:


public float thermalTemp(int i) {
        Process process;
        try {
            process = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone"+i+"/temp");
            process.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = reader.readLine();
            if(line!=null) {
                float temp = Float.parseFloat(line);
                return temp / 1000.0f;
            }else{
                return 51.0f;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return 0.0f;
        }
    }
    public String thermalType(int i) {
        Process process;
        String line = null;
        try {
            process = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone" + i + "/type");
            process.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            line = reader.readLine();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return line;
    }


来源:https://stackoverflow.com/questions/65643038/how-to-get-all-the-thermal-information-on-android-programmatically-cpu-all-cor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!