summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Caruso <ejcaruso@chromium.org>2020-06-12 15:18:28 -0700
committerAleksander Morgado <aleksander@aleksander.es>2020-10-19 20:38:43 +0000
commite24a8240cb957c1875f2f3eab14aa5005c3b8f40 (patch)
tree369a6c88566a5721bbb7681c8294525c1cbfe668
parent9fca0467801d41598666dd63e9394ed806c5a399 (diff)
mm-shared-qmi: load EID during SIM slot loading
SIMs can be created with an EID fetched during load_sim_slots while initializing the modem, if present. Since load_eid would be implemented with the same mechanism we avoid using it here (if Get Slot Status fails once, it probably doesn't make a lot of sense to try it again).
-rw-r--r--src/mm-base-sim.c2
-rw-r--r--src/mm-base-sim.h1
-rw-r--r--src/mm-modem-helpers-qmi.c14
-rw-r--r--src/mm-modem-helpers-qmi.h4
-rw-r--r--src/mm-shared-qmi.c43
-rw-r--r--src/mm-sim-qmi.c2
-rw-r--r--src/mm-sim-qmi.h1
7 files changed, 61 insertions, 6 deletions
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c
index d692554d..b8570a3c 100644
--- a/src/mm-base-sim.c
+++ b/src/mm-base-sim.c
@@ -1472,6 +1472,7 @@ mm_base_sim_new_initialized (MMBaseModem *modem,
gboolean active,
const gchar *sim_identifier,
const gchar *imsi,
+ const gchar *eid,
const gchar *operator_identifier,
const gchar *operator_name,
const GStrv emergency_numbers)
@@ -1484,6 +1485,7 @@ mm_base_sim_new_initialized (MMBaseModem *modem,
"active", active,
"sim-identifier", sim_identifier,
"imsi", imsi,
+ "eid", eid,
"operator-identifier", operator_identifier,
"operator-name", operator_name,
"emergency-numbers", emergency_numbers,
diff --git a/src/mm-base-sim.h b/src/mm-base-sim.h
index 7e860f56..ed582528 100644
--- a/src/mm-base-sim.h
+++ b/src/mm-base-sim.h
@@ -175,6 +175,7 @@ MMBaseSim *mm_base_sim_new_initialized (MMBaseModem *modem,
gboolean active,
const gchar *sim_identifier,
const gchar *imsi,
+ const gchar *eid,
const gchar *operator_identifier,
const gchar *operator_name,
const GStrv emergency_numbers);
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index e9291a71..52cad511 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -2026,3 +2026,17 @@ mm_qmi_uim_get_card_status_output_parse (gpointer log_
*o_lock = lock;
return TRUE;
}
+
+/*************************************************************************/
+/* EID parsing */
+
+#define EID_BYTE_LENGTH 16
+
+gchar *
+mm_qmi_uim_decode_eid (const gchar *eid, gsize eid_len)
+{
+ if (eid_len != EID_BYTE_LENGTH)
+ return NULL;
+
+ return mm_bcd_to_string ((const guint8 *) eid, eid_len, FALSE /* low_nybble_first */);
+}
diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h
index baa993e0..9d69e99a 100644
--- a/src/mm-modem-helpers-qmi.h
+++ b/src/mm-modem-helpers-qmi.h
@@ -168,4 +168,8 @@ gboolean mm_qmi_uim_get_card_status_output_parse (gpointer
guint *o_puk2_retries,
GError **error);
+/*****************************************************************************/
+/* UIM Get Slot Status parsing */
+gchar *mm_qmi_uim_decode_eid (const gchar *eid, gsize eid_len);
+
#endif /* MM_MODEM_HELPERS_QMI_H */
diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c
index 4530057a..b0b061b2 100644
--- a/src/mm-shared-qmi.c
+++ b/src/mm-shared-qmi.c
@@ -3384,6 +3384,8 @@ uim_get_slot_status_ready (QmiClientUim *client,
MMIfaceModem *self;
GError *error = NULL;
GArray *physical_slots = NULL;
+ GArray *ext_information = NULL;
+ GArray *slot_eids = NULL;
guint i;
self = g_task_get_source_object (task);
@@ -3398,15 +3400,30 @@ uim_get_slot_status_ready (QmiClientUim *client,
return;
}
+ /* It's fine if we don't have EID information, but it should be well-formed if present. If it's malformed,
+ * there is probably a modem firmware bug. */
+ if (qmi_message_uim_get_slot_status_output_get_physical_slot_information (output, &ext_information, NULL) &&
+ qmi_message_uim_get_slot_status_output_get_slot_eid_information (output, &slot_eids, NULL) &&
+ (ext_information->len != physical_slots->len || slot_eids->len != physical_slots->len)) {
+ g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "UIM Get Slot Status returned malformed response");
+ g_object_unref (task);
+ return;
+ }
+
ctx->sim_slots = g_ptr_array_new_full (physical_slots->len, (GDestroyNotify) sim_slot_free);
for (i = 0; i < physical_slots->len; i++) {
- QmiPhysicalSlotStatusSlot *slot_status;
- MMBaseSim *sim;
- g_autofree gchar *raw_iccid = NULL;
- g_autofree gchar *iccid = NULL;
- g_autoptr(GError) inner_error = NULL;
- gboolean sim_active = FALSE;
+ QmiPhysicalSlotStatusSlot *slot_status;
+ QmiPhysicalSlotInformationSlot *slot_info;
+ MMBaseSim *sim;
+ g_autofree gchar *raw_iccid = NULL;
+ g_autofree gchar *iccid = NULL;
+ g_autofree gchar *eid = NULL;
+ g_autoptr(GError) inner_error = NULL;
+ gboolean sim_active = FALSE;
/* Store active slot info */
slot_status = &g_array_index (physical_slots, QmiPhysicalSlotStatusSlot, i);
@@ -3438,12 +3455,26 @@ uim_get_slot_status_ready (QmiClientUim *client,
continue;
}
+ if (ext_information && slot_eids) {
+ slot_info = &g_array_index (ext_information, QmiPhysicalSlotInformationSlot, i);
+ if (slot_info->is_euicc) {
+ GArray *slot_eid;
+
+ slot_eid = g_array_index (slot_eids, GArray *, i);
+ if (slot_eid->len)
+ eid = mm_qmi_uim_decode_eid (slot_eid->data, slot_eid->len);
+ if (!eid)
+ mm_obj_dbg (self, "SIM in slot %d is marked as eUICC, but has malformed EID", i + 1);
+ }
+ }
+
sim = mm_sim_qmi_new_initialized (MM_BASE_MODEM (self),
TRUE, /* consider DMS UIM deprecated if we're creating SIM slots */
i + 1, /* slot number is the array index starting at 1 */
sim_active,
iccid,
NULL, /* imsi unknown */
+ eid, /* may be NULL, which is fine */
NULL, /* operator id unknown */
NULL, /* operator name unknown */
NULL); /* emergency numbers unknown */
diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c
index bbe2352c..d8ef4c70 100644
--- a/src/mm-sim-qmi.c
+++ b/src/mm-sim-qmi.c
@@ -1454,6 +1454,7 @@ mm_sim_qmi_new_initialized (MMBaseModem *modem,
gboolean active,
const gchar *sim_identifier,
const gchar *imsi,
+ const gchar *eid,
const gchar *operator_identifier,
const gchar *operator_name,
const GStrv emergency_numbers)
@@ -1467,6 +1468,7 @@ mm_sim_qmi_new_initialized (MMBaseModem *modem,
"active", active,
"sim-identifier", sim_identifier,
"imsi", imsi,
+ "eid", eid,
"operator-identifier", operator_identifier,
"operator-name", operator_name,
"emergency-numbers", emergency_numbers,
diff --git a/src/mm-sim-qmi.h b/src/mm-sim-qmi.h
index 98b75526..c0fe91b9 100644
--- a/src/mm-sim-qmi.h
+++ b/src/mm-sim-qmi.h
@@ -60,6 +60,7 @@ MMBaseSim *mm_sim_qmi_new_initialized (MMBaseModem *modem,
gboolean active,
const gchar *sim_identifier,
const gchar *imsi,
+ const gchar *eid,
const gchar *operator_identifier,
const gchar *operator_name,
const GStrv emergency_numbers);