通过ADB仅适用于旧版华为手机获取IMEI。

huangapple go评论85阅读模式
英文:

Get IMEI via ADB only for old Huawei models

问题

I can provide translations for the non-code portions of your text:

  1. 我需要一点帮助。我有一部华为 g6-l11 手机(搭载 Android 4.3),我正在尝试通过 ADB 提取 IMEI。我知道这部手机很老,但这是我的一个任务。到目前为止,我尝试了互联网上能找到的所有方法,比如:

  2. adb shell service call iphonesubinfo N | grep "<IMEI>" - 其中 N 是介于 1 和 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>"

因此,我创建了一个 Android 应用程序并在智能手机上运行了以下代码:

val tm = this.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
Log.d("Emy_","The IMEI is ${tm.deviceId}")

这个方法运行得很好,但这是一个 Android 应用程序,而我需要通过 ADB 来执行相同的操作。

此外,我找到了一个 fastboot 命令,可以帮助我(例如:fastboot oem get-psid)。但问题是我需要将手机重启到 fastboot 模式,这需要太长时间。

我的问题是:

  1. 为什么对于安卓 6.0 以下版本的华为手机来说提取 IMEI 不同?

  2. 如何复制 Java 代码中的函数调用,用终端中的 ADB 执行?换句话说,您能向我推荐哪些其他命令来尝试提取 IMEI?

英文:

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 &quot;&lt;IMEI&gt;&quot;

  2. adb shell service call iphonesubinfo N | grep &quot;&lt;IMEI&gt;&quot; - 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 &quot;&lt;IMEI&gt;&quot;

  5. adb shell content query --uri content://settings/system | grep &quot;&lt;IMEI&gt;&quot;

  6. adb shell content query --uri content://settings/global | grep &quot;&lt;IMEI&gt;&quot;

  7. adb shell dumpsys | grep &quot;&lt;IMEI&gt;&quot;

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(&quot;Emy_&quot;,&quot;The IMEI is ${tm.deviceId}&quot;)

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?

答案1

得分: 1

你可以在屏幕上显示它:

adb am start -a android.intent.action.CALL -d tel:*%2306%23
英文:

You could display it on screen:

adb am start -a android.intent.action.CALL -d tel:*%2306%23

答案2

得分: 0

如果您只是想知道IMEI号码,您可以尝试以下代码:*#06#
或者您可以尝试这个:adb shell service call iphonesubinfo 1 | toybox cut -d "&quot;&#39;&quot;" -f2 | toybox grep -Eo '[0-9]' | toybox xargs | toybox sed 's/\ //g'
希望这对您有帮助!

英文:

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 &quot;&#39;&quot; -f2 | toybox grep -Eo &#39;[0-9]&#39; | toybox xargs | toybox sed &#39;s/\ //g&#39;

hop that help you !

huangapple
  • 本文由 发表于 2020年1月6日 16:24:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608810.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定