diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-07-27 16:53:03 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-07-27 17:09:56 -0500 |
commit | 555e2e689d3d9b32f5c7946dc37d28bad12ba1c3 (patch) | |
tree | 56a28abc6c334593d9e0adcc0ce9a94bc1095e6e /drivers | |
parent | 5fcbc68f3e54a00580747d33851134cdebd03b69 (diff) | |
download | ofono-555e2e689d3d9b32f5c7946dc37d28bad12ba1c3.tar.bz2 |
Refactor SIM file access code
SIM File Access conditions would be reported similarly between various
stacks, so it seems like the core logic of figuring out the access
conditions belongs up in the daemon.
This also fixes various problems, including:
- access conditions read from bytes 10-12, instead of 9-11.
- read/update, invalidate/rehabilitate and increase conditions
read from the wrong bits (0-3 instead of 4-7 and vice versa)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/atmodem/sim.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index 81b566ae..bfee723d 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -40,13 +40,6 @@ static const char *crsm_prefix[] = { "+CRSM:", NULL }; -static inline enum ofono_sim_file_access file_access_condition_decode(int bcd) -{ - if (bcd >= 4 && bcd <= 14) - return OFONO_SIM_FILE_ACCESS_ADM; - return bcd; -} - static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; @@ -57,7 +50,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) gint sw1, sw2, len; int flen, rlen; enum ofono_sim_file_structure str; - enum ofono_sim_file_access access[__OFONO_SIM_FILE_CONDITION_NUM]; + unsigned char access[3]; dump_response("at_crsm_info_cb", ok, result); decode_at_error(&error, g_at_result_final_response(result)); @@ -94,18 +87,11 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) flen = (response[2] << 8) | response[3]; str = response[13]; - access[OFONO_SIM_FILE_CONDITION_UPDATE] = - file_access_condition_decode((response[9] >> 4) & 0xf); - access[OFONO_SIM_FILE_CONDITION_READ] = - file_access_condition_decode((response[9] >> 0) & 0xf); - access[OFONO_SIM_FILE_CONDITION_INCREASE] = - file_access_condition_decode((response[10] >> 0) & 0xf); - access[OFONO_SIM_FILE_CONDITION_INVALIDATE] = - file_access_condition_decode((response[11] >> 4) & 0xf); - access[OFONO_SIM_FILE_CONDITION_REHABILITATE] = - file_access_condition_decode((response[11] >> 0) & 0xf); - - if (str == 0x01) + + access[0] = response[8]; + access[1] = response[9]; + access[2] = response[10]; + rlen = response[14]; else rlen = 0; |