From 0e47ba404174fcebedf4a349971d1eb07f2d714b Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Sun, 14 Mar 2021 09:53:49 +0100 Subject: iface-modem: synchronize state when resuming Refresh signal strength and access technologies, check for SIM swaps, and check if the SIM is locked. The modem may have switched to a different access technologies or have a different signal strength when resuming. Moreover, the user may swap or remove the SIM when suspended. --- src/mm-broadband-modem.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/mm-broadband-modem.c') diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 39b5e500..ec00afdf 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -11943,6 +11943,7 @@ enable (MMBaseModem *self, typedef enum { SYNCING_STEP_FIRST, + SYNCING_STEP_IFACE_MODEM, SYNCING_STEP_IFACE_3GPP, SYNCING_STEP_IFACE_TIME, SYNCING_STEP_LAST, @@ -11998,6 +11999,36 @@ iface_modem_3gpp_sync_ready (MMIfaceModem3gpp *self, syncing_step (task); } +static void +iface_modem_sync_ready (MMIfaceModem *self, + GAsyncResult *res, + GTask *task) +{ + SyncingContext *ctx; + MMModemLock lock; + g_autoptr (GError) error = NULL; + + ctx = g_task_get_task_data (task); + lock = mm_iface_modem_get_unlock_required (self); + + if (!mm_iface_modem_sync_finish (self, res, &error)) { + mm_obj_warn (self, "synchronizing Modem interface failed: %s", error->message); + } + + /* SIM is locked, skip synchronization */ + if (lock == MM_MODEM_LOCK_UNKNOWN || lock == MM_MODEM_LOCK_SIM_PIN || lock == MM_MODEM_LOCK_SIM_PUK) { + mm_obj_warn (self, "SIM is locked... Synchronization skipped"); + ctx->step = SYNCING_STEP_LAST; + syncing_step (task); + } + + /* Not locked, go on to next step */ + mm_obj_dbg (self, "modem unlocked, continue synchronization"); + ctx->step++; + syncing_step (task); + return; +} + static void syncing_step (GTask *task) { @@ -12012,6 +12043,19 @@ syncing_step (GTask *task) ctx->step++; /* fall through */ + case SYNCING_STEP_IFACE_MODEM: + /* + * Start interface Modem synchronization. + * We want to make sure that the SIM is unlocked and not swapped before + * synchronizing other interfaces. + */ + mm_obj_info (self, "resume synchronization state (%d/%d): Modem interface sync", + ctx->step, SYNCING_STEP_LAST); + mm_iface_modem_sync (MM_IFACE_MODEM (self), + (GAsyncReadyCallback)iface_modem_sync_ready, + task); + return; + case SYNCING_STEP_IFACE_3GPP: /* * Start interface 3GPP synchronization. -- cgit v1.2.3-70-g09d2