Android emulator and the SIM card serial number

After publishing the post about changing the IMEI number, I was asked about modifying the SIM card serial number. Yes, it is perfectly possible, but requires a bit more investigation.

In general, the mechanism used is the same (i.e. AT commands sent to the emulated GSM modem). The telephony subsystem sends the following command to the emulated modem to retrieve the SIM card serial number (use any GSM modem manual for reference):

AT+CRSM=176,12258,0,0,10

The first numerical parameter denotes a command to execute on the SIM card, 176 stands for READ BINARY. Second parameter is the field identifier – Integrated Circuit Card identification, that is the SIM card serial number (for the full list of fields, called Elementary Files, refer to 3GPP TS 51.011 specification). Emulated modem responds with the following hard-coded response:

+CRSM: 144,0,98101430121181157002

The string of digits following the second comma is what we’re looking for, however, with every pair of digits swapped. All the SIM card commands and responses can be found in external/qemu/telephony/sim_card.c.

Changing the emulated SIM card serial number is now as easy changing the IMEI. To change the SIM card serial to e.g. 12345678901234567890, one has to:

  • backup the emulator binary ;)
  • open the binary in the hex editor
  • search for 98101430121181157002
  • replace it with 21436587092143658709 (remember about swapping)
About these ads
Posted in Android. Tags: , . 2 Comments »

2 Responses to “Android emulator and the SIM card serial number”

  1. Kurt Says:

    Thanks a lot.
    This is very useful. Can’t understand why they hardcoded this information.

    • codepainters Says:

      Well, I can’t understand it either. Seems like they just hacked the GSM modem emulation in a hurry.

      I’ve made a patch permitting to configure IMEI/IMSI in the AVD settings file, but it’s not yet ready for release.

      Actually, there are many things to improve about the Android SDK. I do not understand why they decided to emulate the whole software stack, including ARM CPU. iPhone simulator is a simple API re-implementation, amazingly fast compared to Android’s one :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: