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.
This commit is contained in:
Aleksander Morgado
2021-05-26 13:14:52 +00:00
parent 42bc953749
commit e58d525826
+14 -3
View File
@@ -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);
}