I would like to get the cell phone number of any android device using the command line.
I have tried using:
adb shell service call iphonesubinfo 4
and
adb shell service call iphonesubinfo 5/6/7/8
and it returns Permission denied.
I was wondering if anyone has another solution?
Ps: phones are android 4.1 and above
Thanks you in advance.
You have to obtain root access by using :
adb root
Then you'll find those command work. Usually the phone number will be returned by :
adb shell service call iphonesubinfo 5
or by :
adb shell service call iphonesubinfo 6
It depends on the device is single or dual sim. You'll need to do some string parsing work if you need this result to be recognized by machine.
Related
I'm trying to track devices, SIMs and airtime cards for test purposes. I have multiple devices plugged into a computer and since the recent update to Android 12, I am not able to get the device IMEI. The IMEI is basically the device's FCC-required serial number and can be obtained from the UI with relative ease, but how can I obtain it via ADB or in some automated method on multiple devices from multiple carriers and OEMs?
Prior to Android 12 FEB patch, I would use service call iphonesubinfo 1 or service call iphonesubinfo 4. But unfortunately after the update I receive back Result: Parcel(ffffffffc ffffffff 00000000 '................') whereas before I would receive a parcel containing the IMEI for processing via script.
Is there a way to get IMEI on Android 12+? I am trying to stay away from using an app. This is a simple thing, from a privileged user (adb shell). It seems like a basic necessity for tracking and logistics purposes.
This command works to obtain IMEI. It works by pressing the dialer key, then typing *#06#, then parsing the text on screen to find the IMEI Label and the next element which contains the actual IMEI. Finally it parses that element by removing all before text=" and all after ".
adb shell "imei=$(input keyevent KEYCODE_CALL;sleep 1;input text '*#06#'; uiautomator dump --compressed /dev/stdout|sed s/\>\<\/\\n/g|grep -A1 IMEI|tail -n1|sed -e 's/.*text=\"//' -e 's/\".*//'); echo ${imei}"
to get just the 16-digit IMEI without checksum, replace the final echo statement with echo ${imei:0:16}
I found a good solution for Samsung One UI
First, run the About menu
adb shell am start -a com.android.settings.ACTION_DEVICE_INFO_SETTINGS
Then dump the UI
adb shell uiautomator dump
View the dump file
adb shell cat /sdcard/window_dump.xml
The IMEI1 in the <node index="12" and IMEI 2 in <node index="13"
I have a ODROID C2 with Android 5.1. It has an UART pin.
I want to communicate with pic micro controller using UART serial communication.
I tried this. i can see uart port on device manager.but the problem is i cant install app on the device. it shows error:
pkg: /data/local/tmp/com.example.windows10.uart_app
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]
DEVICE SHELL COMMAND: pm uninstall com.example.windows10.uart_app
Unknown failure (Failure)
First, u need to check the voltage level of PIC UART. Maybe it is 5V.
And, ODROID C2 uses 3V3 UART level. (Must use UART1 from C2 GPIO. if u use UART0, u'll need some modifing at boot.ini)
Second, test with some serial APP. if the APP shows same error, u'll need to give permission as
chmod 777 /dev/tty1
Also, why don't you use Hardkernel's forum?
EDIT
Sorry, #chmod 777 /dev/tty1 is wrong. retry #chmod 777 /dev/ttyS1
i am working on a project to read the sms of my android mobile,but on internet didn't find much about it. in my search i found following points
You can access android mobile phone through ADB shell commands ,but
only certain limited features.
ADB is a best method to communicate, as it do not require user to add any extension on android device
I use the shell command (found on internet) to send
message ,but it also didn't work
adb shell service call isms 5 s16 "com.android.mms" s16 "+01234567890" s16 "+01000000000" s16 "Hello world !" i32 0 i32 0
Moreover i found that if i want to
use AT commands to do so i have to root the mobile phone
even i tried accessing
com.android.internal.telephony
it shows result permission denied
above are my search results related to reading sms from my android device,
so i just want know,how can i read the sms from my android device
using adb shell commands?
if there is any other way to do so please suggest.
You can Read sms from android mobile using sqlite3, i m also working on the same project. but for this you have to do few things:
1) You must root your mobile (using any root app e.g Kingoroot app)
2) You should know the exact path for sms database of your mobile and you must install sqlite3 (simply google it and you will find it)
3) Only Super User can access that database
4) You must put sqlite.exe file into device/system/xbin (root directory)
5) how to accomplish step 4 ,you need (Titanium backup, root browser )
if done every thing written above all u need is
C:\Users\Ray>cd appdata/local/android/sdk/platform-tools
adb
adb shell
shell#htc_v02_dug:/ $ su
root#htc_v02_dug:/ # cd /data/data/com.android.providers.telephony/databases
root#htc_v02_dug:/data/data/com.android.providers.telephony/databases # sqlite3 mmssms.db
SQLite version 3.7.6.3-Titanium
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select body from sms where read=0;
hi
i m using htc mobile. And the sms i just read hi.
I'm working on a non phone device that run Android 2.3.3. We have a custom Android version (with some additionnal driver) and my application has "system" privileges since we build our apps with the same key used to build android.
I had unlocked full Android API (including com.android.internal.*) following this post : https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/.
I deleted the Phone.apk from the device to ensure that no process is using rild.
I can instanciate a GSMPhone from my app, but after, I'm unable to execute any commands like supplyPin or getImei. I always have the same error :
CommandException: RADIO_NOT_AVAILABLE.
I'm really stuck here, any help would be precious.
CommandException: RADIO_NOT_AVAILABLE indicates that the rild socket is not opened. In other words, the rild service is not attached to the underlying basebane/modem you are using.
Run ps in adb shell to check if rild service is in the list. If it is in the list, run ls -l /dev/tty* and check if the modem device attached with the Android platform exists here or not. If it does not exist, it means that the Kernel is unable to enumerate your modem device and you need to add support in kernel for it. If it exists, run adb logcat -b radio and check the radio logs output which would really be helpful to diagnose the issue further.
adb shell ps | grep rild to check if RILD is in runing.
Since you can access all the api, do some initialization like PhoneApp do in Phone application OnCreate(mostly like setting params to modem, set radio power which will power on/off the modem, etc)
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.
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()