Google Groups

Re: Android USIM management


Rajesh Kadhiravan Nagaiah Sep 30, 2011 4:41 PM
Posted in group: android-platform
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