there are two OPPO phones, using adb cannot accurately read IMEI 1 and 2, but only MEID. How can I read IMEI?
Android version 11 Model PEAM00 and PEMM20
Tried the following command, but it doesn't work, only MEID is returned.
adb shell service call iphonesubinfo 1
adb shell service call iphonesubinfo 2
Found in a different StackOverflow thread that I can't find now:
adb shell "service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'"
This is working on Android 11. If it's not working straight from CMD then type
adb shell
and then the rest of the command (service call ...)
Related
There is a question about Getting IMEI number using ADB commands Android 12.
adb root
adb shell "service call iphonesubinfo 1 i64 0 | cut -c 52-66 | tr -d '.[:space:]'"
I tested the method, and it works well on Android 12.
But from android 13 on, it just returns an error message: "Package does not belong to ..."
Does anyone can help? Thanks!
Below ADB command uses UIAutomator of Android.
Method: Call app -> *#06# -> Get value
adb shell "imei=$(input keyevent KEYCODE_WAKEUP;input keyevent KEYCODE_CALL;sleep 1;input text '*#06#'; uiautomator dump --compressed /dev/stdout|sed s/\>\<\/\\n/g|grep -A1 IMEI1|tail -n1|sed -e 's/.*text=\"//' -e 's/\".*//'); echo ${imei:0:16}"
You can edit to get IMEI1, IMEI2, SN. My phone is Samsung Galaxy, if you use other phone brands, edit it accordingly.
Note: Not work when your phone is locked
I need a bit of assistance. I have a Huawei g6-l11 (with Android 4.3) from which I am trying to extract the IMEI via ADB. I know that this device is ancient, but this is one of my tasks. So far I had tried everything I could find on the internet, like:
1) adb shell getprop | grep "<IMEI>"
2) adb shell service call iphonesubinfo N | grep "<IMEI>" - Where N is a number between 1 and 50
3) adb shell settings get secure android_id
4) adb shell content query --uri content://settings/secure | grep "<IMEI>"
5) adb shell content query --uri content://settings/system | grep "<IMEI>"
6) adb shell content query --uri content://settings/global | grep "<IMEI>"
7) adb shell dumpsys | grep "<IMEI>"
So I had made an Android app and run this piece of code on the smartphone:
val tm = this.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
Log.d("Emy_","The IMEI is ${tm.deviceId}")
That worked fine but it is an Android app when I need to do the same thing but only via ADB.
Also, I had found a fastboot command that would help me (like: fastboot oem get-psid). But the problem is that I need to reboot the phone into fast boot mode. Which is taking too long.
My questions are:
1) why is it different for Huawei models with the OS version below Marshmallow to extract the IMEI?
2) how could I replicate the function call done by the Java code to be done with the ADB in the terminal? Or in other words, what other commands would you recommend to me to try to extract the IMEI?
You could display it on screen:
adb am start -a android.intent.action.CALL -d tel:*%2306%23
If you just searching to know the IMEI, You can try this code : *#06#
Or you can try this : adb shell
service call iphonesubinfo 1 | toybox cut -d "'" -f2 | toybox grep -Eo '[0-9]' | toybox xargs | toybox sed 's/\ //g'
hop that help you !
I found how to call , but even when the device has no sim card it returns no error, so it doesn't help me:
adb -s <device number> shell am start -a android.intent.action.CALL -d tel:55678888
You can read the content of telephony.registry by using - adb shell dumpsys telephony.registry and then parse it. Look for the value of mServiceState:
0 - In Service
1 - Out of Service
2 - Emergency Only
Below is code I've written that is supposed to take a list of all devices connected, extract their serial numbers, and than spit them out to the terminal. When I run this script I get error: unknown host service which spawns out of my Return Serial function
ReturnSerial () {
adb -s $usb shell getprop | grep ro.serial | awk '{print $2}'
}
for usb in $(adb devices -l | awk '/ device usb:/{print $2}'); do ReturnSerial ; done
I don't understand what this error means. I have many other functions that I run in the same fashion that do not get caught.
Also worth noting, the devices I work with do not spit out their serial number on a simple adb devices command, thus why I need to use their usb locator and extract the serial number from their properties.
We used to get Device ID/IMEI using the following command:
adb shell dumpsys iphonesubinfo
But since last Android update (5.0 - Lollilop), this command doesn't return anything, I performed this test on both Nexus 4 and Nexus 5.
I know I can get the IMEI from code, which is still working, but does anyone has a workaround for ADB ?
You can always just use service call command to call the service methods.
here are the TRANSACTION CODES for the iphonesubinfo service in android-5.0.0_r1:
1 getDeviceId
2 getDeviceIdForSubscriber
3 getImeiForSubscriber
4 getDeviceSvn
5 getSubscriberId
6 getSubscriberIdForSubscriber
7 getGroupIdLevel1
8 getGroupIdLevel1ForSubscriber
9 getIccSerialNumber
10 getIccSerialNumberForSubscriber
11 getLine1Number
12 getLine1NumberForSubscriber
13 getLine1AlphaTag
14 getLine1AlphaTagForSubscriber
15 getMsisdn
16 getMsisdnForSubscriber
17 getVoiceMailNumber
18 getVoiceMailNumberForSubscriber
19 getCompleteVoiceMailNumber
20 getCompleteVoiceMailNumberForSubscriber
21 getVoiceMailAlphaTag
22 getVoiceMailAlphaTagForSubscriber
23 getIsimImpi
24 getIsimDomain
25 getIsimImpu
26 getIsimIst
27 getIsimPcscf
28 getIsimChallengeResponse
29 getIccSimChallengeResponse
Most methods require root. But fortunately getDeviceId (the one you need to get device's IMEI/MEID) does not.
For proper parsing of the service call command output on the device side and without external dependencies see my answer here
Also read Calling Android services from ADB shell for more details.
IMEI for sim 1
adb shell service call iphonesubinfo 1 | awk -F "'" '{print $2}' | sed '1 d' | tr -d '.' | awk '{print}' ORS=
ADB command to get device IMEI:
adb shell "service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'"
ADB command to get device phone number:
adb shell "service call iphonesubinfo 18 | cut -c 52-66 | tr -d '.[:space:]+'"
ADB command to get Android ID:
adb shell settings get secure android_id
ADB command to get device Serial Number:
adb shell getprop ro.serialno
Note: No root is needed for any of the above commands
i agree with alex P and jeremy we can get phone IMEI by service call but that results in packet which is complicated to see so after so much juggling with cmd as im not a programmer i have found solution to get IMEI alone and decided to share it as it can help to many .
so here is script i made to get IMEI from lollypop 5.1 and it works with non rooted phones
#echo off
setlocal enabledelayedexpansion
for /f "tokens=6*" %%a in ('adb shell "service call iphonesubinfo 1 ^| grep -m 1 \"'\""') do (
set imei1=%%a)
for /f "tokens=6*" %%b in ('adb shell "service call iphonesubinfo 1 ^| grep -m 2 \"'\""') do (
set imei2=%%b)
for /f "tokens=4*" %%c in ('adb shell "service call iphonesubinfo 1 ^| grep -m 3 \"'\""') do (
set imei3=%%c)
set imei=!imei1!!imei2!!imei3!
echo !imei! > imei.txt
for /f "delims=" %%d in (imei.txt) do (
set DeviceIMEI=%%d
set DeviceIMEI=!DeviceIMEI:'=!
set DeviceIMEI=!DeviceIMEI:.=!
set OIMEI=Phone IMEI !DeviceIMEI!
)
echo %OIMEI%
pause
it will result in " Phone IMEI 'whatever phone IMEI is'"
*keep in mind it will only show imei of sim port which is default set for calling.
if anyone can short this script it would be great.