diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-23 12:35:07 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-26 13:14:52 +0000 |
commit | e58d525826c7693a6c2cf3a31485b62d870e59d2 (patch) | |
tree | c3158a248b5ee065cc9f1bcc1517a67d18c6566c /src | |
parent | 42bc953749fc4f38aeb6430704a7f6571fbf1b23 (diff) |
broadband-modem: skip synchronization after resume if not needed
The synchronization after resume should only be needed on enabled
modems, as otherwise there is really no chance that the state of the
modem may have changed during suspend.
E.g. if a modem is failed because it doesn't have a SIM card, or if
the SIM-PIN is locked, or if the modem has never been enabled, there
is no point in attempting to synchronize the runtime state of the
modem.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-modem.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 38ddeca7..3466e833 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -11996,13 +11996,24 @@ synchronize (MMBaseModem *self, SyncingContext *ctx; GTask *task; + task = g_task_new (MM_BROADBAND_MODEM (self), NULL, callback, user_data); + + /* Synchronization after resume is not needed on modems that have never + * been enabled. + */ + if (MM_BROADBAND_MODEM (self)->priv->modem_state < MM_MODEM_STATE_ENABLED) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE, + "Synchronization after resume not needed in modem state '%s'", + mm_modem_state_get_string (MM_BROADBAND_MODEM (self)->priv->modem_state)); + g_object_unref (task); + return; + } + /* Create SyncingContext */ ctx = g_new0 (SyncingContext, 1); ctx->step = SYNCING_STEP_FIRST; - - /* Create sync steps task and execute it */ - task = g_task_new (MM_BROADBAND_MODEM (self), NULL, callback, user_data); g_task_set_task_data (task, ctx, (GDestroyNotify)g_free); + syncing_step (task); } |