adb获取安卓手机厂商型号

某些时候需要获取安卓手机厂商型号等信息,运行adb命令即可。

adb shell getprop ro.product.model

adb devices -l

adb shell getprop | grep product

Java示例代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public String runCommand(String command) throws IOException {
String str = "";
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(command);
try {
if (proc.waitFor() != 0) {
System.err.println("exit value = " + proc.exitValue());
}
BufferedReader in = new BufferedReader(new InputStreamReader(
proc.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
String line = null;
while ((line = in.readLine()) != null) {
stringBuffer.append(line + " ");
}
str = stringBuffer.toString();
} catch (InterruptedException e) {
System.err.println(e);
} finally {
try {
proc.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
return str;
}

@Test
public void Test() throws IOException{
System.out.println(runCommand("adb shell getprop ro.product.model"));
System.out.println(runCommand("adb devices -l"));
System.out.println(runCommand("adb shell getprop | grep product"));
}

输出:

HUAWEI MT7-TL00
List of devices attached P4M7N15411025011 device usb:336723968X product:MT7-TL00 model:HUAWEI_MT7_TL00 device:hwmt7
[ro.boardid.product]: [41031] [ro.build.product]: [hi3630] [ro.config.browser_useragent1]: [HUAWEI_productName_TD/5.0 Android/androidVersion (Linux; U; Android androidVersion; zh-cn] [ro.product.CustCVersion]: [C01] [ro.product.CustDVersion]: [D570] [ro.product.board]: [MT7-TL00] [ro.product.brand]: [Huawei] [ro.product.canplaypause]: [true] [ro.product.cmcc.rtspcon]: [true] [ro.product.cpu.abi]: [armeabi-v7a] [ro.product.cpu.abi2]: [armeabi] [ro.product.cpu.abilist]: [armeabi-v7a,armeabi] [ro.product.cpu.abilist32]: [armeabi-v7a,armeabi] [ro.product.cpu.abilist64]: [] [ro.product.cucc.rtsplive]: [true] [ro.product.device]: [hwmt7] [ro.product.hardwareversion]: [HL1TGRACEM] [ro.product.locale.language]: [zh] [ro.product.locale.region]: [CN] [ro.product.manufacturer]: [HUAWEI] [ro.product.member.level]: [10011] [ro.product.model]: [HUAWEI MT7-TL00] [ro.product.name]: [MT7-TL00] [ro.product.only_2Gnetwork]: [false] [ro.product.platform.pseudonym]: [1ARB9CV] [ro.product.playreq.range]: [true] [ro.product.rtsp.startTime]: [true] [ro.product.streaming.custom]: [true]