如何在Android 5.0上使用adb命令获取MEID和IMEI信息?

问题描述:

我知道在其他版本上可用的唯一命令是 adb shell dumpsys iphonesubinfo,但在Android 5.0上似乎不起作用。

The only command that I know that works on other versions is "adb shell dumpsys iphonesubinfo" but it doesn't seem to work on Android 5.0.

要获取 TelephonyManager.getDeviceId(),您可以执行以下操作:

To get TelephonyManager.getDeviceId() you can do:

adb shell service call iphonesubinfo 1

如果您在解析服务调用输出以检出 https://gist.github.com/ ktnr74 / 60ac7bcc2cd17b43f2cb

If you have problems with parsing service call output check out https://gist.github.com/ktnr74/60ac7bcc2cd17b43f2cb

或者您也可以使用此Windows一线版在设备端进行操作:

Or you can do it on the device side with this Windows one-liner:

adb shell "service call iphonesubinfo 1 | grep -o '[0-9a-f]\{8\} ' | tail -n+3 | while read a; do echo -n \\u${a:4:4}\\u${a:0:4}; done"

或在Linux中:

adb shell 'service call iphonesubinfo 1 | grep -o "[0-9a-f]\{8\} " | tail -n+3 | while read a; do echo -n "\u${a:4:4}\u${a:0:4}"; done'