fix conn usage

pull/36039/head
Shane Smiskol 3 days ago
parent 2f0a44511d
commit e026359931
  1. 17
      system/ui/lib/wifi_manager.py

@ -247,8 +247,6 @@ class WifiManager:
def _monitor_state(self):
device_path: str = self._wait_for_wifi_device()
conn = open_dbus_connection(bus="SYSTEM")
rule = MatchRule(
type="signal",
interface=NM_DEVICE_IFACE,
@ -257,10 +255,9 @@ class WifiManager:
)
# Filter for StateChanged signal
conn.send_and_get_reply(message_bus.AddMatch(rule))
self._conn_monitor.send_and_get_reply(message_bus.AddMatch(rule))
try:
with conn.filter(rule, queue=deque(maxlen=10)) as q: # TODO: not sure what to choose for this
with self._conn_monitor.filter(rule, queue=deque(maxlen=10)) as q: # TODO: not sure what to choose for this
while not self._exit:
# TODO: now that we have a nice poller we can run always?
# TODO: actually nah since it affects UI currently? or not?
@ -270,7 +267,7 @@ class WifiManager:
# Block until a matching signal arrives
try:
msg = conn.recv_until_filtered(q, timeout=1)
msg = self._conn_monitor.recv_until_filtered(q, timeout=1)
except TimeoutError:
continue
@ -282,9 +279,14 @@ class WifiManager:
if new_state == NMDeviceState.NEED_AUTH and change_reason == NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT and len(self._connecting_to_ssid):
print('------ NEED AUTH - SUPPLICANT DISCONNECT')
# TODO: this didn't show wrong password dialog but we were here
print('forgetting connection to', self._connecting_to_ssid)
self.forget_connection(self._connecting_to_ssid, block=True)
print('forgot successful')
print('need auth is none?', self._need_auth is None)
if self._need_auth is not None:
print('CALLING NEED AUTH CALLBACK')
self._need_auth(self._connecting_to_ssid)
print('done calling')
self._connecting_to_ssid = ""
elif new_state == NMDeviceState.ACTIVATED:
print('------ ACTIVATED')
@ -299,9 +301,6 @@ class WifiManager:
if self._disconnected is not None:
self._disconnected()
finally:
conn.close()
def _network_scanner(self):
self._wait_for_wifi_device()

Loading…
Cancel
Save