diff options
author | Christophe Ronco <c.ronco@kerlink.fr> | 2017-01-09 09:34:06 +0100 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2017-01-09 12:25:00 -0600 |
commit | c5fbfaa55fea50d89bfd7df30170baec7ac101a9 (patch) | |
tree | a05a5f3ca7fc1b274b633e5eec68b55709967a1a /src/sim.c | |
parent | aaf70beb0653fed6aeb87c91534431bdf75da955 (diff) | |
download | ofono-c5fbfaa55fea50d89bfd7df30170baec7ac101a9.tar.gz |
sim: backup driver read_imsi by IMSI via EF read
If read_imsi driver function fails, try to obtain IMSI via EF read
Diffstat (limited to 'src/sim.c')
-rw-r--r-- | src/sim.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -1472,19 +1472,6 @@ static void sim_imsi_obtained(struct ofono_sim *sim, const char *imsi) } -static void sim_imsi_cb(const struct ofono_error *error, const char *imsi, - void *data) -{ - struct ofono_sim *sim = data; - - if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { - ofono_error("Unable to read IMSI, emergency calls only"); - return; - } - - sim_imsi_obtained(sim, imsi); -} - static void sim_efimsi_cb(const struct ofono_error *error, const unsigned char *data, int len, void *user) { @@ -1524,6 +1511,26 @@ error: ofono_error("Unable to read IMSI, emergency calls only"); } +static void sim_imsi_cb(const struct ofono_error *error, const char *imsi, + void *data) +{ + struct ofono_sim *sim = data; + + if (error->type == OFONO_ERROR_TYPE_NO_ERROR) { + sim_imsi_obtained(sim, imsi); + return; + } + + /* Driver function failed, try via EF reads if possible */ + if (sim->driver->read_file_transparent == NULL) { + ofono_error("Unable to read IMSI, emergency calls only"); + return; + } + + sim->driver->read_file_transparent(sim, SIM_EFIMSI_FILEID, 0, 9, + NULL, 0, sim_efimsi_cb, sim); +} + static void sim_retrieve_imsi(struct ofono_sim *sim) { if (sim->driver->read_imsi) { |