API to create a sim context for a given AID. This AID based context is only relevant for an ISIM application, so during AID discovery, if an ISIM is found, a new fs object is initialized for the ISIM. If any atom wants to create an AID based context for the ISIM AID, the ISIM fs object will be used. --- src/sim.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/sim.c b/src/sim.c index 53eb048..8b466c9 100644 --- a/src/sim.c +++ b/src/sim.c @@ -122,6 +122,7 @@ struct ofono_sim { unsigned int cphs_spn_short_watch; struct sim_fs *simfs; + struct sim_fs *simfs_isim; struct ofono_sim_context *context; struct ofono_sim_context *early_context; @@ -1477,6 +1478,14 @@ static void discover_apps_cb(const struct ofono_error *error, memcpy(&s->record, app, sizeof(struct sim_app_record)); sim->aid_sessions = g_slist_prepend(sim->aid_sessions, s); + if (app->type == SIM_APP_TYPE_ISIM) { + /* + * If an ISIM application is found, we should init + * the FS structure so the ISIM EF's can be accessed. + */ + sim->simfs_isim = sim_fs_new(sim, sim->driver); + } + g_free(app); iter = g_slist_next(iter); @@ -2235,6 +2244,36 @@ struct ofono_sim_context *ofono_sim_context_create(struct ofono_sim *sim) return sim_fs_context_new(sim->simfs); } +struct ofono_sim_context *ofono_sim_context_create_isim( + struct ofono_sim *sim) +{ + GSList *iter = sim->aid_sessions; + + if (sim == NULL || sim->simfs_isim == NULL) + return NULL; + + /* + * Check if the AID is even valid + */ + while (iter) { + struct sim_app_record *app = iter->data; + + /* + * This AID based context is only relevant for an ISIM AID. A + * USIM application can be accessed with the 'default' FS + * context API's. + */ + if (app->type == SIM_APP_TYPE_ISIM) { + return sim_fs_context_new_with_aid(sim->simfs_isim, + app->aid); + } + + iter = g_slist_next(iter); + } + + return NULL; +} + void ofono_sim_context_free(struct ofono_sim_context *context) { return sim_fs_context_free(context); @@ -3056,6 +3095,8 @@ static void sim_remove(struct ofono_atom *atom) sim_fs_free(sim->simfs); sim->simfs = NULL; + sim_fs_free(sim->simfs_isim); + sim->simfs_isim = NULL; g_free(sim); } -- 2.7.4