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.
This commit is contained in:
@@ -153,6 +153,7 @@ quectel_qusim_unsolicited_handler (MMPortSerialAt *port,
|
|||||||
mm_obj_dbg (self, "checking SIM swap");
|
mm_obj_dbg (self, "checking SIM swap");
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap (
|
MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap (
|
||||||
self,
|
self,
|
||||||
|
NULL,
|
||||||
(GAsyncReadyCallback)quectel_qusim_check_for_sim_swap_ready,
|
(GAsyncReadyCallback)quectel_qusim_check_for_sim_swap_ready,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
@@ -4120,7 +4120,8 @@ load_sim_identifier_ready (MMBaseSim *sim,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (current_simid, cached_simid) != 0) {
|
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);
|
mm_broadband_modem_sim_hot_swap_detected (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4146,6 +4147,7 @@ load_sim_identifier (GTask *task)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
modem_check_for_sim_swap (MMIfaceModem *self,
|
modem_check_for_sim_swap (MMIfaceModem *self,
|
||||||
|
const gchar *iccid,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -4171,6 +4173,25 @@ modem_check_for_sim_swap (MMIfaceModem *self,
|
|||||||
return;
|
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 ||
|
if (!MM_BASE_SIM_GET_CLASS (ctx->sim)->load_sim_identifier ||
|
||||||
!MM_BASE_SIM_GET_CLASS (ctx->sim)->load_sim_identifier_finish) {
|
!MM_BASE_SIM_GET_CLASS (ctx->sim)->load_sim_identifier_finish) {
|
||||||
g_task_return_new_error (task,
|
g_task_return_new_error (task,
|
||||||
|
@@ -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_finish) {
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap (
|
MM_IFACE_MODEM_GET_INTERFACE (self)->check_for_sim_swap (
|
||||||
self,
|
self,
|
||||||
|
NULL,
|
||||||
(GAsyncReadyCallback)check_for_sim_swap_ready,
|
(GAsyncReadyCallback)check_for_sim_swap_ready,
|
||||||
task);
|
task);
|
||||||
return;
|
return;
|
||||||
|
@@ -290,6 +290,7 @@ struct _MMIfaceModem {
|
|||||||
* Useful for when the modem changes power states since we might
|
* Useful for when the modem changes power states since we might
|
||||||
* not get the relevant notifications from the modem. */
|
* not get the relevant notifications from the modem. */
|
||||||
void (*check_for_sim_swap) (MMIfaceModem *self,
|
void (*check_for_sim_swap) (MMIfaceModem *self,
|
||||||
|
const gchar *iccid,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean (*check_for_sim_swap_finish) (MMIfaceModem *self,
|
gboolean (*check_for_sim_swap_finish) (MMIfaceModem *self,
|
||||||
|
Reference in New Issue
Block a user