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 /src/sim.c | |
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 'src/sim.c')
-rw-r--r-- | src/sim.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -417,30 +417,38 @@ static gboolean sim_op_retrieve_next(gpointer user) static void sim_op_info_cb(const struct ofono_error *error, int length, enum ofono_sim_file_structure structure, int record_length, - enum ofono_sim_file_access *access, void *data) + const unsigned char access[3], void *data) { struct ofono_modem *modem = data; struct sim_manager_data *sim = modem->sim_manager; struct sim_file_op *op = g_queue_peek_head(sim->simop_q); - char *imsi = sim->imsi; char *path; unsigned char fileinfo[6]; int fd = -1; + enum sim_file_access update; + enum sim_file_access invalidate; + enum sim_file_access rehabilitate; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { sim_op_error(modem); return; } + /* TS 11.11, Section 9.3 */ + update = file_access_condition_decode(access[0] & 0xf); + rehabilitate = file_access_condition_decode((access[2] >> 4) & 0xf); + invalidate = file_access_condition_decode(access[2] & 0xf); + op->structure = structure; op->length = length; /* Never cache card holder writable files */ - op->cache = ( - access[OFONO_SIM_FILE_CONDITION_UPDATE] == - OFONO_SIM_FILE_ACCESS_ADM || - access[OFONO_SIM_FILE_CONDITION_UPDATE] == - OFONO_SIM_FILE_ACCESS_NEVER); + op->cache = (update == SIM_FILE_ACCESS_ADM || + update == SIM_FILE_ACCESS_NEVER) && + (invalidate == SIM_FILE_ACCESS_ADM || + invalidate == SIM_FILE_ACCESS_NEVER) && + (rehabilitate == SIM_FILE_ACCESS_ADM || + rehabilitate == SIM_FILE_ACCESS_NEVER); if (structure == OFONO_SIM_FILE_STRUCTURE_TRANSPARENT) op->record_length = length; |