From aa223879371fc859bb0f5409f37aef475d1d84d2 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 28 May 2019 17:59:30 +0200 Subject: iface-modem: fix reporting state while registration is denied When registration is denied, we should be reporting the modem with 'enabled' state instead of 'registered'. This was not happening because the logic to build the consolidated state (for 3GPP+3GPP2 modems) was using as default initial state the current old state, and so if the old one was 'registered' it never allowed getting a consolidated state of 'enabled', because 'registered' > 'enabled'. Instead of using the old initial state, the consolidated modem state should use 'enabled' as default initial value, which is the lowest among 'enabled, 'searching' and 'registered'. --- src/mm-iface-modem.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 66db38ab..3f4c577b 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -425,7 +425,7 @@ bearer_list_updated (MMBearerList *bearer_list, /*****************************************************************************/ -static MMModemState get_current_consolidated_state (MMIfaceModem *self, MMModemState modem_state); +static MMModemState get_consolidated_subsystem_state (MMIfaceModem *self); typedef struct { MMBaseBearer *self; @@ -490,7 +490,7 @@ bearer_status_changed (MMBaseBearer *bearer, new_state = MM_MODEM_STATE_DISCONNECTING; break; case MM_BEARER_STATUS_DISCONNECTED: - new_state = get_current_consolidated_state (self, MM_MODEM_STATE_UNKNOWN); + new_state = get_consolidated_subsystem_state (self); break; } @@ -1518,7 +1518,7 @@ __iface_modem_update_state_internal (MMIfaceModem *self, /* Enabled may really be searching or registered */ if (new_state == MM_MODEM_STATE_ENABLED) - new_state = get_current_consolidated_state (self, new_state); + new_state = get_consolidated_subsystem_state (self); /* Update state only if different */ if (new_state != old_state) { @@ -1612,9 +1612,12 @@ subsystem_state_array_free (GArray *array) } static MMModemState -get_current_consolidated_state (MMIfaceModem *self, MMModemState modem_state) +get_consolidated_subsystem_state (MMIfaceModem *self) { - MMModemState consolidated = modem_state; + /* Use as initial state ENABLED, which is the minimum one expected. Do not + * use the old modem state as initial state, as that would disallow reporting + * e.g. ENABLED if the old state was REGISTERED (as ENABLED < REGISTERED). */ + MMModemState consolidated = MM_MODEM_STATE_ENABLED; GArray *subsystem_states; if (G_UNLIKELY (!state_update_context_quark)) @@ -1698,7 +1701,7 @@ get_updated_consolidated_state (MMIfaceModem *self, g_array_append_val (subsystem_states, s); } - return get_current_consolidated_state (self, modem_state); + return get_consolidated_subsystem_state (self); } void -- cgit v1.2.3-70-g09d2