From 7835b9aa17d6cc0fa7ef694bbec54c6f57a632d1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 25 Feb 2026 15:24:33 -0800 Subject: [PATCH] WifiManager: no need to update networks in as many places v2 (#37405) * debug * todo * clean up * clean up * fix test --- system/ui/lib/tests/test_handle_state_change.py | 6 ++++-- system/ui/lib/wifi_manager.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/system/ui/lib/tests/test_handle_state_change.py b/system/ui/lib/tests/test_handle_state_change.py index 9e7c39be5..a714eab88 100644 --- a/system/ui/lib/tests/test_handle_state_change.py +++ b/system/ui/lib/tests/test_handle_state_change.py @@ -25,6 +25,7 @@ def _make_wm(mocker: MockerFixture, connections=None): wm._need_auth = [] wm._activated = [] wm._update_networks = mocker.MagicMock() + wm._update_active_connection_info = mocker.MagicMock() wm._get_active_wifi_connection = mocker.MagicMock(return_value=(None, None)) return wm @@ -291,7 +292,7 @@ class TestActivated: assert wm._wifi_state.ssid == "MyNet" def test_activated_side_effects(self, mocker): - """ACTIVATED persists the volatile connection to disk and triggers _update_networks.""" + """ACTIVATED persists the volatile connection to disk and updates active connection info.""" wm = _make_wm(mocker, connections={"Net": "/path/net"}) wm._set_connecting("Net") wm._get_active_wifi_connection.return_value = ("/path/net", {}) @@ -299,7 +300,8 @@ class TestActivated: fire(wm, NMDeviceState.ACTIVATED) wm._conn_monitor.send_and_get_reply.assert_called_once() - wm._update_networks.assert_called_once() + wm._update_active_connection_info.assert_called_once() + wm._update_networks.assert_not_called() # --------------------------------------------------------------------------- diff --git a/system/ui/lib/wifi_manager.py b/system/ui/lib/wifi_manager.py index 4b5711428..4433114b1 100644 --- a/system/ui/lib/wifi_manager.py +++ b/system/ui/lib/wifi_manager.py @@ -424,6 +424,7 @@ class WifiManager: # prev_state guard: real auth failures come from CONFIG (supplicant handshake). # Stale NEED_AUTH from a prior connection during network switching arrives with # prev_state=DISCONNECTED and must be ignored to avoid a false wrong-password callback. + # TODO: sometimes on PC it's observed no future signals are fired if mouse is held down blocking wrong password dialog elif ((new_state == NMDeviceState.NEED_AUTH and change_reason == NMDeviceStateReason.SUPPLICANT_DISCONNECT and prev_state == NMDeviceState.CONFIG) or (new_state == NMDeviceState.FAILED and change_reason == NMDeviceStateReason.NO_SECRETS)): @@ -445,12 +446,12 @@ class WifiManager: cloudlog.warning("Failed to get active wifi connection during ACTIVATED state") self._wifi_state = wifi_state self._enqueue_callbacks(self._activated) - self._update_networks() + self._update_active_connection_info() else: wifi_state.ssid = next((s for s, p in self._connections.items() if p == conn_path), None) self._wifi_state = wifi_state self._enqueue_callbacks(self._activated) - self._update_networks() + self._update_active_connection_info() # Persist volatile connections (created by AddAndActivateConnection2) to disk conn_addr = DBusAddress(conn_path, bus_name=NM, interface=NM_CONNECTION_IFACE) @@ -652,7 +653,6 @@ class WifiManager: conn_addr = DBusAddress(conn_path, bus_name=NM, interface=NM_CONNECTION_IFACE) self._router_main.send_and_get_reply(new_method_call(conn_addr, 'Delete')) - self._update_networks() self._enqueue_callbacks(self._forgotten, ssid) if block: