iface-modem-3gpp: ignore initial registration check result when appropriate

When a modem is being enabled, an initial registration check is
scheduled to determine the current registration state and access
technology. The initial registration check is performed asynchronously
and may not complete before the modem state is transitioned to
'enabled'. When the modem is disabled shortly afterwards, the
registration state is transitioned to 'unknown' and the modem state is
transitioned to 'disabled'. But the completion of the initial
registration check after that can transition the registration state and
modem state to a wrong state. This patch addresses the issue by ignoring
a registration state update if the modem isn't already enabled or being
enabled.
This commit is contained in:
Ben Chan
2018-01-11 23:47:28 -08:00
committed by Aleksander Morgado
parent d8c7251687
commit c9e85b6716

View File

@@ -1205,10 +1205,28 @@ update_registration_state (MMIfaceModem3gpp *self,
new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
MMModemState modem_state;
/* If already reloading registration info, skip it */
if (ctx->reloading_registration_info)
return;
/* If the modem isn't already enabled or being enabled, this
* registration state update is due to a previously scheduled
* initial registration check when the modem was being enabled.
* We need to ignore it as otherwise it may cause an incorrect
* transition of the registration state and modem state when the
* modem is being disabled. */
modem_state = MM_MODEM_STATE_UNKNOWN;
g_object_get (self,
MM_IFACE_MODEM_STATE, &modem_state,
NULL);
if (modem_state < MM_MODEM_STATE_ENABLING) {
mm_dbg ("Modem %s: 3GPP Registration state change ignored as modem isn't enabled",
g_dbus_object_get_object_path (G_DBUS_OBJECT (self)));
return;
}
mm_info ("Modem %s: 3GPP Registration state changed (%s -> registering)",
g_dbus_object_get_object_path (G_DBUS_OBJECT (self)),
mm_modem_3gpp_registration_state_get_string (old_state));