8

有没有办法通过 adb 获取电话的电话号码?

我将 dumpsys 视为一个可能的答案,但似乎没有任何系统服务跟踪手机自己的号码。

4

1 回答 1

10

iphonesubinfo服务“跟踪”包括电话号码在内的订户信息。不幸的是iphonesubinfo,服务没有实现该dump()方法,因此 dumpsys 什么也没有显示。您将不得不使用service call命令来调用IPhoneSubInfo.getLine1Number()IPhoneSubInfo.getMsisdn()代替

根据 android 版本和您的运营商,以下一两个命令会告诉您电话号码(service call命令需要root特权):

service call iphonesubinfo 4
service call iphonesubinfo 5
service call iphonesubinfo 6
service call iphonesubinfo 7
service call iphonesubinfo 8

如果您想为您的特定设备找出正确的代码 - 从Calling Android services from ADB shell post 下载脚本并像这样运行它:

./get_android_service_call_numbers.sh iphonesubinfo | grep getLine1Number

更新

Android 5.0 的交易代码:

service call iphonesubinfo 11 # getLine1Number()
service call iphonesubinfo 15 # getMsisdn()

Android 5.1 的交易代码:

service call iphonesubinfo 13 # getLine1Number()
service call iphonesubinfo 17 # getMsisdn()
于 2013-10-05T18:57:52.733 回答