diff options
author | Teijo Kinnunen <teijo.kinnunen@uros.com> | 2020-09-07 15:18:52 +0300 |
---|---|---|
committer | Teijo Kinnunen <teijo.kinnunen@uros.com> | 2020-09-07 15:18:52 +0300 |
commit | e52ad1cc88601b2da1946678a2743465362d88c6 (patch) | |
tree | 7e849130fd236ffd852eabc1a3b8950daf1f947c | |
parent | 49b4e6a6ff1104393edb53a812f4a23d32f04ff1 (diff) |
iface-modem: add an optional iccid parameter to check_for_sim_swap
If the new iccid is already available, reading the iccid from the
card can be skipped.
-rw-r--r-- | plugins/quectel/mm-shared-quectel.c | 1 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 23 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 1 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 1 |
4 files changed, 25 insertions, 1 deletions
diff --git a/plugins/quectel/mm-shared-quectel.c b/plugins/quectel/mm-shared-quectel.c index 33f05665..bfd29593 100644 --- a/plugins/quectel/mm-shared-quectel.c +++ b/plugins/quectel/mm-shared-quectel.c @@ -153,6 +153,7 @@ quectel_qusim_unsolicited_handler (MMPortSerialAt *port, mm_obj_dbg (self, "checking SIM swap"); MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap ( self, + NULL, (GAsyncReadyCallback)quectel_qusim_check_for_sim_swap_ready, NULL); } diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 8441a2cf..61a07406 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -4120,7 +4120,8 @@ load_sim_identifier_ready (MMBaseSim *sim, } if (g_strcmp0 (current_simid, cached_simid) != 0) { - mm_obj_info (self, "sim identifier has changed: possible SIM swap during power down/low"); + mm_obj_info (self, "sim identifier has changed: %s -> %s - possible SIM swap", + cached_simid, current_simid); mm_broadband_modem_sim_hot_swap_detected (self); } @@ -4146,6 +4147,7 @@ load_sim_identifier (GTask *task) static void modem_check_for_sim_swap (MMIfaceModem *self, + const gchar *iccid, GAsyncReadyCallback callback, gpointer user_data) { @@ -4171,6 +4173,25 @@ modem_check_for_sim_swap (MMIfaceModem *self, return; } + /* We may or may not get the new SIM identifier (iccid). In case + * we've got it, the load_sim_identifier phase can be skipped. */ + if (iccid) { + const gchar *cached_simid; + + cached_simid = mm_gdbus_sim_get_sim_identifier (MM_GDBUS_SIM (ctx->sim)); + if (!cached_simid || g_strcmp0 (iccid, cached_simid) != 0) { + mm_obj_info (self, "detected ICCID change (%s -> %s), handle as SIM hot-swap", + cached_simid ? cached_simid : "<none>", + iccid); + mm_broadband_modem_sim_hot_swap_detected (MM_BROADBAND_MODEM (self)); + } else + mm_obj_dbg (self, "ICCID not changed"); + + g_task_return_boolean (task, TRUE); + g_object_unref (task); + return; + } + if (!MM_BASE_SIM_GET_CLASS (ctx->sim)->load_sim_identifier || !MM_BASE_SIM_GET_CLASS (ctx->sim)->load_sim_identifier_finish) { g_task_return_new_error (task, diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 955453be..40a56c74 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -4040,6 +4040,7 @@ interface_enabling_step (GTask *task) MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap_finish) { MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap ( self, + NULL, (GAsyncReadyCallback)check_for_sim_swap_ready, task); return; diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index c40323fc..10f22d1e 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -290,6 +290,7 @@ struct _MMIfaceModem { * Useful for when the modem changes power states since we might * not get the relevant notifications from the modem. */ void (*check_for_sim_swap) (MMIfaceModem *self, + const gchar *iccid, GAsyncReadyCallback callback, gpointer user_data); gboolean (*check_for_sim_swap_finish) (MMIfaceModem *self, |