summaryrefslogtreecommitdiffstats
path: root/src/sim.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-08-23 13:58:14 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-08-23 14:29:22 -0500
commit687e1719490957bc4c29b2e746e441c2b4b4380e (patch)
treeb35c797d7a2e5a5335cf2c56bc634615823c7d83 /src/sim.c
parent38300af0da63988b1e391344b758d71b845475d4 (diff)
downloadofono-687e1719490957bc4c29b2e746e441c2b4b4380e.tar.bz2
sim: Retrieve EFphase according to the spec
Diffstat (limited to 'src/sim.c')
-rw-r--r--src/sim.c82
1 files changed, 37 insertions, 45 deletions
diff --git a/src/sim.c b/src/sim.c
index f6e7bce9..a450b30e 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1116,8 +1116,24 @@ static void sim_ad_read_cb(int ok, int length, int record,
sim->mnc_length = new_mnc_length;
}
+static void sim_efphase_read_cb(int ok, int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+
+ if (!ok || length != 1)
+ sim->phase = OFONO_SIM_PHASE_3G;
+ else
+ sim->phase = data[0];
+}
+
static void sim_initialize_after_pin(struct ofono_sim *sim)
{
+ ofono_sim_read(sim, SIM_EFPHASE_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ sim_efphase_read_cb, sim);
+
ofono_sim_read(sim, SIM_EFAD_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_ad_read_cb, sim);
@@ -1391,47 +1407,6 @@ static void sim_iccid_read_cb(int ok, int length, int record,
&sim->iccid);
}
-static void sim_efphase_read_cb(const struct ofono_error *error,
- const unsigned char *data, int len, void *user)
-{
- struct ofono_sim *sim = user;
-
- if (!error || error->type != OFONO_ERROR_TYPE_NO_ERROR || len != 1)
- sim->phase = OFONO_SIM_PHASE_3G;
- else
- sim->phase = data[0];
-
- /* Proceed with SIM initialization */
- ofono_sim_read(sim, SIM_EF_ICCID_FILEID,
- OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
- sim_iccid_read_cb, sim);
-
- /* According to 31.102 the EFli is read first and EFpl is then
- * only read if none of the EFli languages are supported by user
- * interface. 51.011 mandates the exact opposite, making EFpl/EFelp
- * preferred over EFlp (same EFid as EFli, different format).
- * However we don't depend on the user interface and so
- * need to read both files now.
- */
- ofono_sim_read(sim, SIM_EFLI_FILEID,
- OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
- sim_efli_read_cb, sim);
- ofono_sim_read(sim, SIM_EFPL_FILEID,
- OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
- sim_efpl_read_cb, sim);
-}
-
-static void sim_determine_phase(struct ofono_sim *sim)
-{
- if (!sim->driver->read_file_transparent) {
- sim_efphase_read_cb(NULL, NULL, 0, sim);
- return;
- }
-
- sim->driver->read_file_transparent(sim, SIM_EFPHASE_FILEID, 0, 1,
- sim_efphase_read_cb, sim);
-}
-
static void sim_initialize(struct ofono_sim *sim)
{
/* Perform SIM initialization according to 3GPP 31.102 Section 5.1.1.2
@@ -1457,11 +1432,28 @@ static void sim_initialize(struct ofono_sim *sim)
* At this point we signal the SIM ready condition and allow
* arbitrary files to be written or read, assuming their presence
* in the EFust
- *
- * We utilize the fact that EFphase is always readable and grab it
- * early. We also grab the card ICCID if available.
*/
- sim_determine_phase(sim);
+
+ /* Grab the EFiccid which is always available */
+ ofono_sim_read(sim, SIM_EF_ICCID_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ sim_iccid_read_cb, sim);
+
+ /* EFecc is read by the voicecall atom */
+
+ /* According to 31.102 the EFli is read first and EFpl is then
+ * only read if none of the EFli languages are supported by user
+ * interface. 51.011 mandates the exact opposite, making EFpl/EFelp
+ * preferred over EFlp (same EFid as EFli, different format).
+ * However we don't depend on the user interface and so
+ * need to read both files now.
+ */
+ ofono_sim_read(sim, SIM_EFLI_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ sim_efli_read_cb, sim);
+ ofono_sim_read(sim, SIM_EFPL_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ sim_efpl_read_cb, sim);
}
static void sim_op_error(struct ofono_sim *sim)