In the emulator, the values of IMEI and IMSI are hardcoded:
2325 { "+CIMI", OPERATOR_HOME_MCCMNC "000000000", NULL }, /* request internation subscriber identification number */
2326 { "+CGSN", "000000000000000", NULL }, /* request model version */
therefore, you will always get null
.
If you still want to use these id numbers for your testing and you want to keep the same code for the emulator and the real device, you must change it in the emulator somehow.
There are at least two ways how to do it:
Change the values in the code and recompile the code for the emulator. However, this might be too complicated and time consuming... :-)
"Hack" the emulator binary (since it is neither compressed or encrypted - you can do it!) and modify the strings (in the right place) right there.
Here's how to do it:
backup the emulator binary (to roll back! later). In Windows, the binary can be found under the name "emulator.exe", located in your android "\tools" folder.
open the binary with your favourite hex editor
search for the +CGSN string followed by a null byte (it should be followed by 15 digits of the IMEI number - see the printscreen below)
edit the number (be careful not to change the original number of the digits)
and save the file!
and maybe change/adjust your code to use the IMEI for your id (as Falmari
points out), or use this trick to change some other values.
0
's – Bisector