一.使用
1.1.root 权限
1.2.cat proc/cpuinfo | grep Seria
public String getCPUinfo() {
String cpuAddress = "0000000000000000";
String cmd = "cat /proc/cpuinfo";
try {
Process p = Runtime.getRuntime().exec(cmd);
String data = null;
BufferedReader ie = new BufferedReader(new InputStreamReader(p.getErrorStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String error = null;
while ((error = ie.readLine()) != null && !error.equals("null")) {
data += error + "
";
}
String line = null;
while ((line = in.readLine()) != null && !line.equals("null")) {
data += line + "
";
// Log.d("gatsby", "CPUinfo line->" + line);
if (line.contains("Serial:")) {
String[] SerialStr = line.split(":");
if (SerialStr.length == 2) {
String mSerial = SerialStr[1];
// Cpu 序列号
// Log.d("gatsby", "CPUinfo mSerial ->" + mSerial.trim());
cpuAddress = mSerial.trim();
return cpuAddress;
}
}
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
return cpuAddress;
}