前提是需要有root权限,才能执行adb命令。
主要是通过adb 命令:"cat /proc/cpuinfo"来读取cpu信息。
然后重数据流中截取Serial。
流程简单。
若是没有root权限,尝试使用以下adb命令获取root权限:
adb root
adb remount
adb disable-verity
adb reboot
adb root
adb remount
adb shell
以下是android代码
public void getCPUinfo(String cmd){
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 + "\n";
}
String line = null;
while ((line = in.readLine()) != null
&& !line.equals("null")) {
data += line + "\n";
ToastUtils.Log(line + "\n" , "CPUinfo");
if (line.contains("Serial\t\t:")){
String[] SerialStr = line.split(":");
if (SerialStr.length == 2){
String mSerial = SerialStr[1];
ToastUtils.show(MapManagerActivity.this, "CPU序列号:"+mSerial);
ToastUtils.Log("CPU序列号:"+mSerial.trim() , "CPUinfo");
}
}
}
}catch (IOException ioe){
ioe.printStackTrace();
}
}
获取安卓应用芯片CPU序列号(芯片ID)
最新推荐文章于 2023-07-03 14:28:39 发布
本文介绍了一种在拥有root权限的Android设备上,通过adb命令读取CPU信息并截取序列号的方法。首先,使用cat/proc/cpuinfo命令获取CPU详细信息,然后从输出中解析出Serial字段,从而得到CPU序列号。若设备未获得root权限,文章还提供了获取root权限的adb命令。
6743

被折叠的 条评论
为什么被折叠?



