Issue
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.
Solution
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}
Answered By - AdamOutler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.