如何以编程方式在android上获取所有热量信息(CPU [所有内核],GPU,设备等)? [英] How to get all the thermal information on android programmatically (CPU [all Cores], GPU, Device, etc.)?

查看:118
本文介绍了如何以编程方式在android上获取所有热量信息(CPU [所有内核],GPU,设备等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式在android应用程序中提取热信息,但是没有足够的文档来做到这一点.

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

vbal_low - 37.9 C

gold-virt-max-step-28.2 C

gold-virt-max-step - 28.2 C

cpu3-silver-lowf-27.8 C

cpu3-silver-lowf - 27.8 C

msm-therm-adc-26 C

msm-therm-adc - 26 C

mdm-dsp-usr-30.1 C

mdm-dsp - usr - 30.1 C

gpu0-lowf-27.5 C

gpu0-lowf - 27.5 C

wlan-lowf-28.1 C

wlan-lowf - 28.1 C

还有其他大约50个温度值,该怎么做?

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

推荐答案

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;
    }

这篇关于如何以编程方式在android上获取所有热量信息(CPU [所有内核],GPU,设备等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆