Android USIM management

2,710 views
Skip to first unread message

paldan

unread,
Sep 22, 2011, 5:15:11 AM9/22/11
to android-platform
Hello,

I'm trying to use some functions of the class TelephonyManager
(android.telephony package), for example:

getLine1Number()
getVoiceMailNumber()
getSimOperatorName()

and I've seen that these functions return correct results only for GSM
SIM cards, but not for USIM. Looking at the radio log I've seen a
different flow related to the SimCard class. Let's take the MSISDN
example:

USIM SIM card

D/AT ( 1037): AT> AT+CRSM=192,28480,0,0,15
D/AT ( 1037): AT< +CRSM:
144,0,"624782050221001C0183026F40A503C001408A0105AB2C800103A406830101950108800118A40683010F9501088401ECA40683010F9501088401D4A40683010F9501088002001C8800"
D/RILJ ( 1232): < iccIO: 0x90 0x0
624782050221001C0183026F40A503C001408A0105AB2C800103A406830101950108800118A40683010F9501088401ECA40683010F9501088401D4A40683010F9501088002001C8800
D/RILJ ( 1232): [0043]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0
D/GSM ( 1232): Invalid or missing EF[MSISDN]

GSM SIM card

D/AT ( 1038): AT> AT+CRSM=192,28480,0,0,15
D/AT ( 1038): AT< +CRSM: 144,0,"0000003A6F4004001100BB0102011D"
D/AT ( 1038): AT< OK
D/RIL ( 1038): onRequest: SIM_IO
D/RILJ ( 1250): < iccIO: 0x90 0x0 0000003A6F4004001100BB0102011D
D/RILJ ( 1250): [0041]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0
D/RILJ ( 1250): [0061]> iccIO: SIM_IO 0xb2 0x6f40 path:
3F007F10,1,4,29
****************************************************************************
D/AT ( 1038): AT> AT+CRSM=178,28480,1,4,29
D/AT ( 1038): AT< +CRSM:
144,0,"4D61757269206C61766F726FFFFFFF0791932309656921FFFFFFFFFFFF"
D/RIL ( 1038): onRequest: SIM_IO
D/RILJ ( 1250): < iccIO: 0x90 0x0
4D61757269206C61766F726FFFFFFF0791932309656921FFFFFFFFFFFF
D/RILJ ( 1250): [0061]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0
D/GSM ( 1250): MSISDN: xxxxxxx

It seems that in the first case the returned value from +CRSM is not
correctly managed (problems are not related to the RIL native layer
because commands/responses are sent/received correctly).

This happens also for some other +CRSM requests (SPN, mailbox...). Is
this a limitation of the Android platform? Or is there a setting that
tells Android we are using an USIM card?

I'm using Android 2.3.4.

Thanks in advance,
Daniele

paldan

unread,
Sep 30, 2011, 5:57:20 AM9/30/11
to android-platform
Is it possible to have an official response from one of Google Android
developers?

The question is: does the open source version of Android (until 2.3.4)
supports USIM cards (e.g. reading contacts, reading sms, reading
voicemail files..)?

Thanks,
Daniele

Rajesh Kadhiravan Nagaiah

unread,
Sep 30, 2011, 7:41:25 PM9/30/11
to android-...@googlegroups.com
Hi Daniele,

To read a EF data from the ICC/UICC card, first GET RESPONSE(192) for the corresponding file id is sent via AT+CRSM, to read the file and record size.
Then using READ BINARY / READ RECORD request (based on EF type Transparent or Linear fixed), actual data is read from the ICC/UICC card of the specified size. But the GET RESPONSE data its different in case of SIM(or 2G card or ICC card) and USIM card (or 3G card or UICC card), as the USIM card gives the response in TLV format.

From your eg:
GSM SIM card 

D/AT      ( 1038): AT> AT+CRSM=192,28480,0,0,15
D/AT      ( 1038): AT< +CRSM: 144,0,"0000003A6F4004001100BB0102011D"
D/AT      ( 1038): AT< OK
D/RIL     ( 1038): onRequest: SIM_IO
D/RILJ    ( 1250): < iccIO:  0x90 0x0 0000003A6F4004001100BB0102011D
D/RILJ    ( 1250): [0041]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0

Record size = 1D (Byte 14)
File size = 00 3A (Byte 2 3)
Number of Records = File size / Record size = 3A / 1D = 2

Then using the READ RECORD (178), record number 1 and data of 29 bytes is read using (AT+CRSM=178,28480,1,4,29)


D/RILJ    ( 1250): [0061]> iccIO: SIM_IO 0xb2 0x6f40  path: 3F007F10,1,4,29
****************************************************************************
D/AT      ( 1038): AT> AT+CRSM=178,28480,1,4,29
D/AT      ( 1038): AT< +CRSM: 144,0,"4D61757269206C61766F726FFFFFFF0791932309656921FFFFFFFFFFFF"
D/RIL     ( 1038): onRequest: SIM_IO
D/RILJ    ( 1250): < iccIO:  0x90 0x0 4D61757269206C61766F726FFFFFFF0791932309656921FFFFFFFFFFFF
D/RILJ    ( 1250): [0061]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0
D/GSM     ( 1250): MSISDN: xxxxxxx

For MSISDN, always the 1st record is read. So after reading the 1st record, the data is returned to the client.

USIM SIM card: 

D/AT      ( 1037): AT> AT+CRSM=192,28480,0,0,15
D/AT      ( 1037): AT< +CRSM: 144,0,"624782050221001C0183026F40A503C001408A0105AB2C800103A406830101950108800118A40683010F9501088401ECA40683010F9501088401D4A40683010F9501088002001C8800"
D/RILJ    ( 1232): < iccIO:  0x90 0x0
624782050221001C0183026F40A503C001408A0105AB2C800103A406830101950108800118A40683010F9501088401ECA40683010F9501088401D4A40683010F9501088002001C8800
D/RILJ    ( 1232): [0043]< SIM_IO IccIoResponse sw1:0x90 sw2:0x0

In the USIM case, the data we get for the GET RESPONSE is of TLV format. But currently the ICC file handler in the Android telephony framework only parses the response based on the ICC card reponse format. As a result, it will not be able to parse the reponse data content from GET REPONSE and so READ BINARY / READ RECORD request will not be issued to read the actual content in case of 3G card.

As a result we see this error messase in the log.

D/GSM     ( 1232): Invalid or missing EF[MSISDN]

Typically, in the ICC file handler in the Android telephony framework, we have to handle the GET RESPONSE data as below:

1. Check the response data 1st byte:
   if (data[0] == 0x62) {
   // we should use the parsing based on the UICC card TLV format, as 0x62 is FCP tag for UICC card
   UsimResponseDataParsing(data);
   } else {
   // we should use the parsing based on ICC card response data format, which already done by Android
   SimResponseDataParsing(data);
   }
 
in UsimResponseDataParsing(data) {

1. Read TLV data of tag 0x80 (File size tag) (Refer 11.1.1.4.1 of ETSI TS 102 221)
   Byte 1 - TLV Tag
   Byte 2 - TLV length
   Byte 3+ will be File size

   From you eg: for tag 80 its 02 00 1C
   File size = 1C

2. Read TLV data of tag 0x82 (File descriptor tag) (Refer 11.1.1.4.3 of ETSI TS 102 221)
   Byte 1 - TLV Tag
   Byte 2 - TLV length
   Byte 3 - File decriptor byte
   Byte 4 - Data coding byte (should be 0x21)
   Byte 5,6 - Record length
   Byte 7 - Number of records

   From you eg: for tag 82 its 05 02 21 00 1C 01
   
   Record size = 00 1C
   Number of Records = 01

   From this info, using the READ RECORD (178), record number 1 and data of 28 bytes is read using (AT+CRSM=178,28480,1,4,28)
}

READ RECORD response data format will be same for SIM and USIM, so the exisiting code should work there after.

BR,
Rajesh

paldan

unread,
Oct 3, 2011, 3:21:19 AM10/3/11
to android-platform
Rajesh thank you very much.

Your answer was very detailed and qualified.

I wonder why no one has ever submitted a patch for managing this kind
of scenario in Android...

Regards,
Daniele

On 1 Ott, 01:41, Rajesh Kadhiravan Nagaiah
Reply all
Reply to author
Forward
0 new messages