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).
This commit is contained in:

committed by
Aleksander Morgado

parent
9fca046780
commit
e24a8240cb
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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 */);
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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,13 +3400,28 @@ 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;
|
||||
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;
|
||||
|
||||
@@ -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 */
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user