sim: backup driver read_imsi by IMSI via EF read

If read_imsi driver function fails, try to obtain IMSI via EF read
This commit is contained in:
Christophe Ronco 2017-01-09 09:34:06 +01:00 committed by Denis Kenzior
parent aaf70beb06
commit c5fbfaa55f
1 changed files with 20 additions and 13 deletions

View File

@ -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) {