我正在尝试以编程方式提取 Android 应用程序中的热信息,但没有足够的文档来执行此操作。
我想要提取的东西是这样的:
vbal_low - 37.9 C
gold-virt-max-step - 28.2 C
cpu3-银-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
还有像其他50个左右的温度值,怎么办?
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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)