mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-04-07 12:43:59 +08:00
@@ -343,20 +343,16 @@ class WifiUIMici(BigMultiOptionDialog):
|
||||
self.set_back_callback(back_callback)
|
||||
|
||||
self._network_info_page = NetworkInfoPage(wifi_manager, self._connect_to_network, wifi_manager.forget_connection, self._open_network_manage_page)
|
||||
self._network_info_page.set_connecting(lambda: self._connecting)
|
||||
self._network_info_page.set_connecting(lambda: wifi_manager.connecting_to_ssid)
|
||||
|
||||
self._loading_animation = LoadingAnimation()
|
||||
|
||||
self._wifi_manager = wifi_manager
|
||||
self._connecting: str | None = None
|
||||
self._networks: dict[str, Network] = {}
|
||||
|
||||
self._wifi_manager.add_callbacks(
|
||||
need_auth=self._on_need_auth,
|
||||
activated=self._on_activated,
|
||||
forgotten=self._on_forgotten,
|
||||
networks_updated=self._on_network_updated,
|
||||
disconnected=self._on_disconnected,
|
||||
)
|
||||
|
||||
def show_event(self):
|
||||
@@ -402,7 +398,6 @@ class WifiUIMici(BigMultiOptionDialog):
|
||||
|
||||
def _connect_with_password(self, ssid: str, password: str):
|
||||
if password:
|
||||
self._connecting = ssid
|
||||
self._wifi_manager.connect_to_network(ssid, password)
|
||||
self._update_buttons()
|
||||
|
||||
@@ -420,11 +415,9 @@ class WifiUIMici(BigMultiOptionDialog):
|
||||
return
|
||||
|
||||
if network.is_saved:
|
||||
self._connecting = network.ssid
|
||||
self._wifi_manager.activate_connection(network.ssid)
|
||||
self._update_buttons()
|
||||
elif network.security_type == SecurityType.OPEN:
|
||||
self._connecting = network.ssid
|
||||
self._wifi_manager.connect_to_network(network.ssid, "")
|
||||
self._update_buttons()
|
||||
else:
|
||||
@@ -443,16 +436,6 @@ class WifiUIMici(BigMultiOptionDialog):
|
||||
gui_app.set_modal_overlay_tick(self._wifi_manager.process_callbacks)
|
||||
gui_app.set_modal_overlay(dlg, on_close)
|
||||
|
||||
def _on_activated(self):
|
||||
self._connecting = None
|
||||
|
||||
def _on_forgotten(self, ssid):
|
||||
if self._connecting == ssid:
|
||||
self._connecting = None
|
||||
|
||||
def _on_disconnected(self):
|
||||
self._connecting = None
|
||||
|
||||
def _render(self, _):
|
||||
super()._render(_)
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ class WifiManager:
|
||||
|
||||
# State
|
||||
self._connections: dict[str, str] = {} # ssid -> connection path, updated via NM signals
|
||||
self._connecting_to_ssid: str = ""
|
||||
self._prev_connecting_to_ssid: str = ""
|
||||
self._connecting_to_ssid: str | None = None
|
||||
self._prev_connecting_to_ssid: str | None = None
|
||||
self._ipv4_address: str = ""
|
||||
self._current_network_metered: MeteredType = MeteredType.UNKNOWN
|
||||
self._tethering_password: str = ""
|
||||
@@ -236,7 +236,7 @@ class WifiManager:
|
||||
return self._current_network_metered
|
||||
|
||||
@property
|
||||
def connecting_to_ssid(self) -> str:
|
||||
def connecting_to_ssid(self) -> str | None:
|
||||
return self._connecting_to_ssid
|
||||
|
||||
@property
|
||||
@@ -333,21 +333,21 @@ class WifiManager:
|
||||
if failed_ssid:
|
||||
self._enqueue_callbacks(self._need_auth, failed_ssid)
|
||||
self.forget_connection(failed_ssid, block=True)
|
||||
self._prev_connecting_to_ssid = ""
|
||||
self._prev_connecting_to_ssid = None
|
||||
if self._connecting_to_ssid == failed_ssid:
|
||||
self._connecting_to_ssid = ""
|
||||
self._connecting_to_ssid = None
|
||||
|
||||
elif new_state == NMDeviceState.ACTIVATED:
|
||||
if len(self._activated):
|
||||
self._update_networks()
|
||||
self._enqueue_callbacks(self._activated)
|
||||
self._prev_connecting_to_ssid = ""
|
||||
self._connecting_to_ssid = ""
|
||||
self._prev_connecting_to_ssid = None
|
||||
self._connecting_to_ssid = None
|
||||
|
||||
elif new_state == NMDeviceState.DISCONNECTED and change_reason != NM_DEVICE_STATE_REASON_NEW_ACTIVATION:
|
||||
self._enqueue_callbacks(self._forgotten, self._connecting_to_ssid)
|
||||
self._prev_connecting_to_ssid = ""
|
||||
self._connecting_to_ssid = ""
|
||||
self._prev_connecting_to_ssid = None
|
||||
self._connecting_to_ssid = None
|
||||
|
||||
def _network_scanner(self):
|
||||
while not self._exit:
|
||||
|
||||
Reference in New Issue
Block a user