diff options
author | Michal Mazur <michamazur@google.com> | 2023-11-29 12:03:57 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2023-11-30 13:36:48 +0000 |
commit | dc4b1ec0f3d81adce37ea2918b7c651a5a783597 (patch) | |
tree | 6f5f7a4e76ddab87d1f935d57ca60e71a0b29790 /src | |
parent | 3ccf847284e7b946995b2b82cf318c2a4027a24d (diff) |
broadband-modem-mbim: fix detection of SIM hot swap
Previous patch for hotswap detection caused the modem to be reprobed
after unlocking or changing PIN for SIM card lock (commit 7b878765c6c8).
This change allows to differentiate between hotswap and PIN lock events.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 2b03c560..b46dce72 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -1633,14 +1633,13 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device, mm_obj_dbg (self, "processed subscriber ready status response"); } - if (g_error_matches (error, MBIM_STATUS_ERROR, MBIM_STATUS_ERROR_NOT_INITIALIZED)) { - g_clear_error (&error); - ready_state = MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED; - } - if (!error) { - /* Store last valid status loaded */ - self->priv->enabled_cache.last_ready_state = ready_state; + /* Store last valid ready state until it is NOT_INITIALIZED which is temporary */ + if (ready_state != MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED) { + self->priv->enabled_cache.last_ready_state = ready_state; + } else { + self->priv->enabled_cache.last_ready_state = prev_ready_state; + } switch (ready_state) { case MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED: @@ -1664,6 +1663,11 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device, } } + if (g_error_matches (error, MBIM_STATUS_ERROR, MBIM_STATUS_ERROR_NOT_INITIALIZED)) { + g_clear_error (&error); + ready_state = MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED; + } + /* Fatal errors are reported right away */ if (error) { g_task_return_error (task, error); @@ -5152,18 +5156,17 @@ basic_connect_notification_subscriber_ready_status (MMBroadbandModemMbim *self, if ((self->priv->enabled_cache.last_ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED && ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) || (self->priv->enabled_cache.last_ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED && - ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) || - /*SIM state becomes "not initialized" when queried shortly after being inserted. Its state - * transitions are: "not inserted" --> "not initialized" --> "initialized". To detect SIM - * hotswap event from this sequence, we need the check condition below*/ - (self->priv->enabled_cache.last_ready_state == MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED && ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED)) { /* SIM has been removed or reinserted, re-probe to ensure correct interfaces are exposed */ mm_obj_dbg (self, "SIM hot swap detected"); active_sim_event = TRUE; } - self->priv->enabled_cache.last_ready_state = ready_state; + /* Ignore NOT_INITIALIZED state when setting the last_ready_state as it is + * reported regardless of whether SIM was inserted or unlocked */ + if (ready_state != MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED) { + self->priv->enabled_cache.last_ready_state = ready_state; + } if (active_sim_event) { mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); |