Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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.

like image 486
Paru Shimazak Avatar asked Oct 05 '13 17:10

Paru Shimazak


1 Answers

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()
like image 162
Alex P. Avatar answered Sep 20 '22 00:09

Alex P.