How to get the phone number of an android phone vi

2020-01-29 08:01发布

Is there a way to get the phone number of a phone over adb?

I looked at dumpsys as a likely answer, but none of the system services seem to keep track of the phone's own number.

标签: android adb
1条回答
Viruses.
2楼-- · 2020-01-29 08:46

iphonesubinfo service "keeps track" of the subscriber information including phone numbers. Unfortunately iphonesubinfo service does not implement the dump() method so dumpsys shows nothing. You will have to use service call command to call IPhoneSubInfo.getLine1Number() or IPhoneSubInfo.getMsisdn() instead

Depending on the android version and your carrier one or two of the following commands will tell you the phone number (service call commands require root privileges):

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

If you want to find out the proper code for your specific device - download the script from Calling Android services from ADB shell post and run it like this:

./get_android_service_call_numbers.sh iphonesubinfo | grep getLine1Number

UPDATE

Transaction codes for Android 5.0:

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

Transaction codes for Android 5.1:

service call iphonesubinfo 13 # getLine1Number()
service call iphonesubinfo 17 # getMsisdn()
查看更多
登录 后发表回答