Android获取处理器模型 [英] Android Get Processor Model
问题描述
我想获得类似于DU Booster的处理器模型。 CPU模型包含ARM处理器的版本和修订版。例如:ARMv7处理器修订版3(v7l)
I want to get Processor Model similar to DU Booster. CPU model contains ARM processor version and revision. For Example: ARMv7 Processor rev 3 (v7l)
我已经尝试过
System.getProperty( os.arch)
仅返回体系结构
I have tried this
System.getProperty("os.arch")
which returns only architecture
和
String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
获取CPU信息。我可以在某些设备中获得正确的信息,但不能在所有设备中获得正确的信息。
to get CPU info. I am able to get the right information in some of the devices but not in all.
我在Asus Fonepad 7中尝试了此操作,但它不返回处理器的属性(但返回处理器(小p)
I tried this in Asus Fonepad 7 which doesn't return the property of the Processor(but returns processor(small p)
返回结果
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 53
model name : Intel(R) Atom(TM) CPU Z2520 @ 1.20GHz
stepping : 1
microcode : 0x10e
cpu MHz : 800.000
cache size : 512 KB
physical id : 0
siblings : 4
我想得到类似 ARMv7 Processor rev 3(v7l) 的结果。 p>
I want to get result like "ARMv7 Processor rev 3 (v7l)". Thanks in Advance..
推荐答案
您无需实现单独的方法即可使用不同的处理器类型,只需替换 model_name
指向 cpu_model
的键,同时获取 / proc / cpuinfo
文件:
You don't need to implement separated methods to work with differ processors types, just simply replace the model_name
key to cpu_model
when it needed while getting /proc/cpuinfo
file:
public static Map<String, String> getCPUInfo () throws IOException {
BufferedReader br = new BufferedReader (new FileReader ("/proc/cpuinfo"));
String str;
Map<String, String> output = new HashMap<> ();
while ((str = br.readLine ()) != null) {
String[] data = str.split (":");
if (data.length > 1) {
String key = data[0].trim ().replace (" ", "_");
if (key.equals ("model_name")) key = "cpu_model";
output.put (key, data[1].trim ());
}
}
br.close ();
return output;
}
这篇关于Android获取处理器模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!