Merge request !1318 from 'pin-unlock-swap-fix'
broadband-modem,iface-modem: don't treat SIM unlocks as hot-swaps https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1318
This commit is contained in:
@@ -4545,6 +4545,8 @@ complete_sim_swap_check (GTask *task,
|
||||
SimSwapContext *ctx;
|
||||
const gchar *cached;
|
||||
const gchar *str;
|
||||
gboolean ignore_sim_event = FALSE;
|
||||
gboolean same;
|
||||
|
||||
self = MM_BROADBAND_MODEM (g_task_get_source_object (task));
|
||||
ctx = g_task_get_task_data (task);
|
||||
@@ -4557,20 +4559,30 @@ complete_sim_swap_check (GTask *task,
|
||||
ctx->imsi_check_done = TRUE;
|
||||
cached = mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (ctx->sim));
|
||||
str = "imsi";
|
||||
|
||||
/* If the modem is locked and we couldn't previously read the IMSI
|
||||
* (because it was locked) then the IMSI change is probably not a swap.
|
||||
*/
|
||||
ignore_sim_event = (self->priv->modem_state == MM_MODEM_STATE_LOCKED && !cached);
|
||||
} else
|
||||
g_assert_not_reached();
|
||||
|
||||
if (g_strcmp0 (current, cached) != 0) {
|
||||
same = (g_strcmp0 (current, cached) == 0);
|
||||
if (same) {
|
||||
mm_obj_info (self, "SIM %s has not changed: %s",
|
||||
str, mm_log_str_personal_info (current));
|
||||
} else {
|
||||
mm_obj_msg (self, "SIM %s has changed: '%s' -> '%s'",
|
||||
str,
|
||||
mm_log_str_personal_info (cached ? cached : ""),
|
||||
mm_log_str_personal_info (current ? current : ""));
|
||||
}
|
||||
|
||||
if (same || ignore_sim_event) {
|
||||
ctx->step++;
|
||||
} else {
|
||||
mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self));
|
||||
ctx->step = SIM_SWAP_CHECK_STEP_LAST;
|
||||
} else {
|
||||
mm_obj_info (self, "SIM %s has not changed: %s",
|
||||
str, mm_log_str_personal_info (current));
|
||||
ctx->step++;
|
||||
}
|
||||
|
||||
sim_swap_check_step (task);
|
||||
|
||||
+17
-3
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user