aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGjermund Hodnebrog <gjermund.hodnebrog@stericsson.com>2011-05-20 14:58:02 +0200
committerSverre Vegge <sverre.vegge@stericsson.com>2011-08-02 22:15:24 +0200
commitf145c55a967640a355c9052d9cf8d4e454a8be9c (patch)
tree05c0799ddaedd6f59be454d0e3f3f4cdefdf5104
parent71048ccfd6b0839a6bbc6e7fcd8a9a483c5158de (diff)
downloadu300-f145c55a967640a355c9052d9cf8d4e454a8be9c.tar.gz
SIM: Remove SIM_IO workaround and replace AT+CGLA with AT+CRLA
Due to CR that implements AT+CRLA in AT and SIM AT+CRSM stopped working with 2G SIM cards. In case of 3G USIM we should not always issue AT+CRSM first, because it will now fail every time. Now we should use AT+CRLA in case of 3G USIM and AT+CRSM only in case of 2G SIM. Legacy functionality may be enabled under flag USE_LEGACY_CRSM_CGLA_SIM_ACCESS (default off). Signed-off-by: Sverre Vegge <sverre.vegge@stericsson.com>
-rwxr-xr-xAndroid.mk4
-rw-r--r--u300-ril-sim.c97
2 files changed, 96 insertions, 5 deletions
diff --git a/Android.mk b/Android.mk
index 043b58b..8622f2c 100755
--- a/Android.mk
+++ b/Android.mk
@@ -99,6 +99,10 @@ ifneq ($(USE_EXT1_INSTEAD_OF_EXT5_WHEN_SIM_CARD_IS_2G_TYPE),)
LOCAL_CFLAGS += -DUSE_EXT1_INSTEAD_OF_EXT5_WHEN_SIM_CARD_IS_2G_TYPE
endif
+ifneq ($(USE_LEGACY_CRSM_CGLA_SIM_ACCESS),)
+LOCAL_CFLAGS += -DUSE_LEGACY_CRSM_CGLA_SIM_ACCESS
+endif
+
LOCAL_MODULE := libu300-ril
LOCAL_MODULE_TAGS := optional
diff --git a/u300-ril-sim.c b/u300-ril-sim.c
index 5cf3d27..cd15484 100644
--- a/u300-ril-sim.c
+++ b/u300-ril-sim.c
@@ -892,6 +892,8 @@ error:
goto finally;
}
+#ifdef USE_LEGACY_CRSM_CGLA_SIM_ACCESS
+
static int simIOSelectFile(unsigned short fileid)
{
int err = 0;
@@ -1110,6 +1112,89 @@ error:
}
+#else /* USE_LEGACY_CRSM_CGLA_SIM_ACCESS */
+
+int sendSimIOCmdUICC(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_SIM_IO_Response *sr)
+{
+ int err = 0;
+ int resplen;
+ char *line = NULL, *resp = NULL;
+ char *cmd = NULL, *data = NULL;
+ char *fmt = NULL;
+ unsigned short lc = simIOGetLogicalChannel();
+ unsigned char sw1, sw2;
+ char *arg7 = NULL, *arg8 = NULL;
+
+ if (lc == 0) {
+ err = -1;
+ goto error;
+ }
+
+ memset(sr, 0, sizeof(*sr));
+
+ arg7 = ioargs->data;
+ arg8 = ioargs->path;
+
+ if (arg7 != NULL && strlen(arg7) > 0 && arg8 != NULL && strlen(arg8) > 0) {
+ fmt = "AT+CRLA=%d,%d,%d,%d,%d,%d,\"%s\",\"%s\"";
+ } else if (arg8 != NULL && strlen(arg8) > 0) {
+ fmt = "AT+CRLA=%d,%d,%d,%d,%d,%d,,\"%s\"";
+ arg7 = arg8;
+ } else if (arg7 != NULL && strlen(arg7) > 0) {
+ fmt = "AT+CRLA=%d,%d,%d,%d,%d,%d,\"%s\"";
+ } else {
+ fmt = "AT+CRLA=%d,%d,%d,%d,%d,%d";
+ }
+
+ asprintf(&cmd, fmt,
+ lc, ioargs->command, ioargs->fileid,
+ ioargs->p1, ioargs->p2, ioargs->p3,
+ arg7, arg8);
+
+ if (cmd == NULL) {
+ err = -1;
+ goto error;
+ }
+
+ err = at_send_command_singleline(cmd, "+CRLA:", atresponse);
+ if (err < 0)
+ goto error;
+
+ if ((*atresponse)->success == 0) {
+ err = -1;
+ goto error;
+ }
+
+ line = (*atresponse)->p_intermediates->line;
+
+ err = at_tok_start(&line);
+ if (err < 0)
+ goto error;
+
+ err = at_tok_nextint(&line, &(sr->sw1));
+ if (err < 0)
+ goto error;
+
+ err = at_tok_nextint(&line, &(sr->sw2));
+ if (err < 0)
+ goto error;
+
+ if (at_tok_hasmore(&line)) {
+ err = at_tok_nextstr(&line, &(sr->simResponse));
+ if (err < 0)
+ goto error;
+ }
+
+finally:
+ free(cmd);
+ return err;
+
+error:
+ goto finally;
+}
+
+#endif /* USE_LEGACY_CRSM_CGLA_SIM_ACCESS */
+
int sendSimIOCmdICC(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_SIM_IO_Response *sr)
{
int err = 0;
@@ -1184,7 +1269,6 @@ static int sendSimIOCmd(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_S
{
int err = 0;
UICC_Type UiccType;
- ATCmeError cme_error_code = -1;
if (sr == NULL)
return -1;
@@ -1192,6 +1276,7 @@ static int sendSimIOCmd(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_S
/* Detect card type to determine which SIM access command to use */
UiccType = getUICCType();
+#ifdef USE_LEGACY_CRSM_CGLA_SIM_ACCESS
/*
* FIXME WORKAROUND: Currently GCLA works from some files on some cards
* and CRSM works on some files for some cards...
@@ -1199,6 +1284,8 @@ static int sendSimIOCmd(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_S
*/
err = sendSimIOCmdICC(ioargs, atresponse, sr);
if (err < 0 || (sr->sw1 != 0x90 && sr->sw2 != 0x00)) {
+ ATCmeError cme_error_code = -1;
+
/*
* If file operation failed it might be that PIN2 or PUK2 is required
* for file access. This is detected and if PIN2 is provided another
@@ -1221,13 +1308,13 @@ static int sendSimIOCmd(const RIL_SIM_IO *ioargs, ATResponse **atresponse, RIL_S
}
}
/* END WORKAROUND */
-
- /* reintroduce below code when workaround is not needed */
- /* if (UiccType == UICC_TYPE_SIM)
+#else
+ if (UiccType == UICC_TYPE_SIM)
err = sendSimIOCmdICC(ioargs, atresponse, sr);
else {
err = sendSimIOCmdUICC(ioargs, atresponse, sr);
- } */
+ }
+#endif /* USE_LEGACY_CRSM_CGLA_SIM_ACCESS */
exit:
return err;