diff options
author | Eric Caruso <ejcaruso@chromium.org> | 2020-06-12 15:18:28 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-10-19 20:38:43 +0000 |
commit | e24a8240cb957c1875f2f3eab14aa5005c3b8f40 (patch) | |
tree | 369a6c88566a5721bbb7681c8294525c1cbfe668 /src/mm-shared-qmi.c | |
parent | 9fca0467801d41598666dd63e9394ed806c5a399 (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).
Diffstat (limited to 'src/mm-shared-qmi.c')
-rw-r--r-- | src/mm-shared-qmi.c | 43 |
1 files changed, 37 insertions, 6 deletions
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 */ |