I'm working in Android, writing some JNI code, and I'm looking for a way to query the Mobile Equipment Identifier (MEID) from the device.
http://en.wikipedia.org/wiki/Mobile_equipment_identifier
I'm trying to write C or C++ code that can run by itself on an Android device, so I don't think I can use Java (i.e., get MEID from TelephonyManager
).
A search of StackOverflow finds: Is there an android shell or adb command that I could use to get a device's IMEI/MEID?
Okay great, dumpsys iphonesubinfo
can get the info I need. And it works!
I couldn't find the source for dumpsys
except as part of the source for Android. So I downloaded that... my hard disk filled up before the download finished, but I did get the source code to dumpsys
. It is a surprisingly short C++ file. All it does is query Android's IBinder
interface.
So, my questions:
0) Is there any way I can write a query against IBinder
using just the stuff in the NDK? The include files used by dumpsys.cpp
are not in the NDK, and grep
in the NDK directory didn't find IBinder
in any include files or code samples, so my guess is "no" (but I would like to be wrong).
1) Is there any other good way to get the MEID?
I'm seriously thinking I should just use system("dumpsys iphonesubinfo > /tmp/myprogname_dumpsys.tmp"
and then open the resulting file and parse it. That should work, but I would hardly call it elegant... and I'm not sure if dumpsys
is available on every Android device or not.
EDIT: The idea of using system()
to run dumpsys
will not work, because dumpsys
needs android.permission.DUMP
and Android no longer allows non-system apps to have that permission.
Dumpsys permission denial in java
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…