diff options
author | Dan Williams <dan@ioncontrol.co> | 2025-03-23 09:04:21 -0500 |
---|---|---|
committer | Dan Williams <dan@ioncontrol.co> | 2025-03-23 09:04:42 -0500 |
commit | 57d1f21b36d97849c499d777925b94d336a09255 (patch) | |
tree | faa9b57f5fad4719eeb05388d57275d36c108888 /src/mm-iface-modem.c | |
parent | 3b4bb4544215173048a0feb674cfcba7a7ad0d07 (diff) |
broadband-modem,iface-modem: don't treat SIM unlocks as hot-swaps
If the old IMSI was unavailable because the SIM was locked, but now
is available because the SIM was unlocked, don't treat the SIM
properties change as a hotswap that may trigger dropping and re-probing
the modem.
Signed-off-by: Dan Williams <dan@ioncontrol.co>
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r-- | src/mm-iface-modem.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 92ff8214..de25296b 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -160,6 +160,8 @@ check_basic_sim_details_ready (MMIfaceModem *self, g_autofree gchar *current_iccid = NULL; g_autofree gchar *current_imsi = NULL; gboolean sim_inserted; + gboolean iccid_changed; + gboolean imsi_changed; if (!MM_IFACE_MODEM_GET_IFACE (self)->check_basic_sim_details_finish ( self, res, &sim_inserted, ¤t_iccid, ¤t_imsi, &error)) { @@ -175,6 +177,9 @@ check_basic_sim_details_ready (MMIfaceModem *self, old_imsi = mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (sim)); } + iccid_changed = (g_strcmp0 (current_iccid, old_iccid) != 0); + imsi_changed = (g_strcmp0 (current_imsi, old_imsi) != 0); + if (!sim && !sim_inserted) { mm_obj_info (self, "No SIM inserted before and after"); } else if (sim && !sim_inserted) { @@ -183,8 +188,9 @@ check_basic_sim_details_ready (MMIfaceModem *self, } else if (!sim && sim_inserted) { mm_obj_info (self, "SIM inserted"); mm_iface_modem_process_sim_event (self); - } else if ((g_strcmp0 (current_iccid, old_iccid) != 0) || - (g_strcmp0 (current_imsi, old_imsi) != 0)) { + } else if (iccid_changed || imsi_changed) { + MMModemState state = MM_MODEM_STATE_UNKNOWN; + mm_obj_info (self, "new SIM detected"); mm_obj_info (self, "ICCID: %s -> %s", mm_log_str_personal_info (old_iccid), @@ -192,7 +198,15 @@ check_basic_sim_details_ready (MMIfaceModem *self, mm_obj_info (self, "IMSI: %s -> %s", mm_log_str_personal_info (old_imsi), mm_log_str_personal_info (current_imsi)); - mm_iface_modem_process_sim_event (self); + + g_object_get (self, + MM_IFACE_MODEM_STATE, &state, + NULL); + if (state == MM_MODEM_STATE_LOCKED && !old_imsi && imsi_changed) { + /* Don't treat SIM unlocks as SIM swaps */ + } else { + mm_iface_modem_process_sim_event (self); + } } else { mm_obj_info (self, "SIM not changed. ICCID: %s, IMSI: %s", mm_log_str_personal_info (current_iccid), |