summaryrefslogtreecommitdiff
path: root/src/sim.c
diff options
context:
space:
mode:
authorChristophe Ronco <c.ronco@kerlink.fr>2017-01-09 09:34:06 +0100
committerDenis Kenzior <denkenz@gmail.com>2017-01-09 12:25:00 -0600
commitc5fbfaa55fea50d89bfd7df30170baec7ac101a9 (patch)
treea05a5f3ca7fc1b274b633e5eec68b55709967a1a /src/sim.c
parentaaf70beb0653fed6aeb87c91534431bdf75da955 (diff)
downloadofono-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.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/sim.c b/src/sim.c
index 63c7b3c8..ac5b6fde 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -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) {