前提是需要有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().exec(cmd);String data = null;BufferedReader ie = new BufferedReader(new ErrorStream()));BufferedReader in = new BufferedReader(new InputStream()));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 (ains("Serialtt:")){String[] SerialStr = line.split(":");if (SerialStr.length == 2){String mSerial = SerialStr[1];ToastUtils.show(MapManagerActivity.this, "CPU序列号:"+mSerial);ToastUtils.Log("CPU序列号:"im() , "CPUinfo");}}}}catch (IOException ioe){ioe.printStackTrace();}}
本文发布于:2024-01-31 07:40:48,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170665805126775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |