3

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!

James Feng
  • 184
  • 1
  • 14

2 Answers2

6
adb shell "service call iphonesubinfo 1 s16 com.android.shell | cut -c 52-66 | tr -d '.[:space:]'"

Here is what you want

Sergei Kozelko
  • 691
  • 4
  • 17
kalbo zhu
  • 61
  • 2
  • 1
    Great job! But how did you find the command? Is there any trick? – James Feng Apr 01 '23 at 10:22
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 05 '23 at 13:25
-1

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

  • It produces some privilege exceptions like "Exception occurred while executing 'keyevent': java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission." – James Feng Feb 03 '23 at 11:30