aboutsummaryrefslogtreecommitdiff
path: root/src/mm-broadband-modem-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-12-01 09:58:19 +0000
committerAleksander Morgado <aleksander@aleksander.es>2023-12-01 10:14:45 +0000
commit5fb285664534c1d65fdb446ea20a4900f08dbdef (patch)
tree8d05b64bfd8fa33eef21bf34ddc0952828fdec86 /src/mm-broadband-modem-qmi.c
parentdc4b1ec0f3d81adce37ea2918b7c651a5a783597 (diff)
iface-modem: allow cancellability during unlock required checks
The process doing the unlock required checks may need a lot of retries e.g. to decide whether a SIM card is available or not. If we do a quick SIM eject, so the unlock required check starts looping, and then insert the SIM again, we expect the loop to be cancelled right away, so that the new modem object can be reprobed without any interference from the old modem object. We now take the modem-wide cancellable and bind it to the GTask in mm_iface_modem_update_lock_info(), and we pass it down to every sub-step of the async logic in the operation. We also plug the cancellable to the delayed retries in the interface logic, to allow aborting the checks right away
Diffstat (limited to 'src/mm-broadband-modem-qmi.c')
-rw-r--r--src/mm-broadband-modem-qmi.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 239834bd..ecdfbbc0 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -863,9 +863,9 @@ typedef struct {
} LoadUnlockRequiredContext;
static MMModemLock
-modem_load_unlock_required_finish (MMIfaceModem *self,
- GAsyncResult *res,
- GError **error)
+modem_load_unlock_required_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
{
GError *inner_error = NULL;
gssize value;
@@ -883,7 +883,7 @@ static void load_unlock_required_context_step (GTask *task);
static void
unlock_required_uim_get_card_status_ready (QmiClientUim *client,
GAsyncResult *res,
- GTask *task)
+ GTask *task)
{
MMBroadbandModemQmi *self;
LoadUnlockRequiredContext *ctx;
@@ -928,7 +928,7 @@ unlock_required_uim_get_card_status_ready (QmiClientUim *client,
static void
dms_uim_get_pin_status_ready (QmiClientDms *client,
GAsyncResult *res,
- GTask *task)
+ GTask *task)
{
MMBroadbandModemQmi *self;
LoadUnlockRequiredContext *ctx;
@@ -1025,14 +1025,19 @@ dms_uim_get_pin_status_ready (QmiClientDms *client,
static void
load_unlock_required_context_step (GTask *task)
{
- MMBroadbandModemQmi *self;
+ MMBroadbandModemQmi *self;
LoadUnlockRequiredContext *ctx;
- GError *error = NULL;
- QmiClient *client;
+ GError *error = NULL;
+ QmiClient *client;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
+ if (g_task_return_error_if_cancelled (task)) {
+ g_object_unref (task);
+ return;
+ }
+
switch (ctx->step) {
case LOAD_UNLOCK_REQUIRED_STEP_FIRST:
ctx->step++;
@@ -1066,7 +1071,7 @@ load_unlock_required_context_step (GTask *task)
qmi_client_dms_uim_get_pin_status (QMI_CLIENT_DMS (client),
NULL,
5,
- NULL,
+ g_task_get_cancellable (task),
(GAsyncReadyCallback) dms_uim_get_pin_status_ready,
task);
return;
@@ -1090,7 +1095,7 @@ load_unlock_required_context_step (GTask *task)
qmi_client_uim_get_card_status (QMI_CLIENT_UIM (client),
NULL,
5,
- NULL,
+ g_task_get_cancellable (task),
(GAsyncReadyCallback) unlock_required_uim_get_card_status_ready,
task);
return;
@@ -1101,19 +1106,20 @@ load_unlock_required_context_step (GTask *task)
}
static void
-modem_load_unlock_required (MMIfaceModem *self,
- gboolean last_attempt,
- GAsyncReadyCallback callback,
- gpointer user_data)
+modem_load_unlock_required (MMIfaceModem *self,
+ gboolean last_attempt,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
LoadUnlockRequiredContext *ctx;
- GTask *task;
+ GTask *task;
ctx = g_new0 (LoadUnlockRequiredContext, 1);
ctx->step = LOAD_UNLOCK_REQUIRED_STEP_FIRST;
ctx->last_attempt = last_attempt;
- task = g_task_new (self, NULL, callback, user_data);
+ task = g_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, ctx, g_free);
load_unlock_required_context_step (task);