Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

How to get the phone number of an android phone via adb?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...