How to get Android phone number via adb?

Is there any way to get the phone number over adb?

I looked at dumpsys as the likely answer, but none of the system services seem to be tracking their own phone number.

+6
source share
1 answer

iphonesubinfo service monitors subscriber information, including phone numbers. Unfortunately, the iphonesubinfo service iphonesubinfo not implement the dump() method, so dumpsys shows nothing. You will need to use the service call command to call IPhoneSubInfo.getLine1Number() or IPhoneSubInfo.getMsisdn() instead

Depending on the version of Android and your operator, one or two of the following commands 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 correct code for your specific device, download the script from the Android Services Call from the ADB shell and execute it as follows:

 ./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() 
+7
source

Source: https://habr.com/ru/post/955310/


All Articles