mici remember networks
This commit is contained in:
@@ -23,7 +23,7 @@ from openpilot.selfdrive.ui.mici.layouts.onboarding import TrainingGuide
|
||||
from openpilot.system.ui.lib.application import gui_app, FontWeight, MousePos
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.widgets import Widget, NavWidget
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from openpilot.selfdrive.ui.ui_state import device, ui_state
|
||||
from openpilot.system.ui.widgets.label import MiciLabel
|
||||
from openpilot.system.ui.widgets.html_render import HtmlModal, HtmlRenderer
|
||||
from openpilot.system.athena.registration import UNREGISTERED_DONGLE_ID
|
||||
@@ -322,6 +322,8 @@ class GalaxyBigButton(BigButton):
|
||||
|
||||
|
||||
UPDATER_TIMEOUT = 10.0 # seconds to wait for updater to respond
|
||||
UPDATE_SCREEN_TIMEOUT = 180 # Keep display awake for 3 minutes during long-running update phases.
|
||||
EXTENDED_TIMEOUT_UPDATER_STATES = {"downloading...", "finalizing update..."}
|
||||
|
||||
|
||||
class UpdateOpenpilotBigButton(BigButton):
|
||||
@@ -334,6 +336,7 @@ class UpdateOpenpilotBigButton(BigButton):
|
||||
self._waiting_for_updater_t: float | None = None
|
||||
self._hide_value_t: float | None = None
|
||||
self._state: UpdaterState = UpdaterState.IDLE
|
||||
self._extended_timeout_enabled = False
|
||||
|
||||
ui_state.add_offroad_transition_callback(self.offroad_transition)
|
||||
|
||||
@@ -361,6 +364,17 @@ class UpdateOpenpilotBigButton(BigButton):
|
||||
|
||||
threading.Thread(target=run, daemon=True).start()
|
||||
|
||||
def hide_event(self):
|
||||
super().hide_event()
|
||||
self._set_extended_timeout(False)
|
||||
|
||||
def _set_extended_timeout(self, enabled: bool):
|
||||
if self._extended_timeout_enabled == enabled:
|
||||
return
|
||||
|
||||
self._extended_timeout_enabled = enabled
|
||||
device.set_override_interactive_timeout(UPDATE_SCREEN_TIMEOUT if enabled else None)
|
||||
|
||||
def set_value(self, value: str):
|
||||
super().set_value(value)
|
||||
if value:
|
||||
@@ -370,10 +384,12 @@ class UpdateOpenpilotBigButton(BigButton):
|
||||
|
||||
def _update_state(self):
|
||||
if ui_state.started:
|
||||
self._set_extended_timeout(False)
|
||||
self.set_enabled(False)
|
||||
return
|
||||
|
||||
updater_state = ui_state.params.get("UpdaterState") or ""
|
||||
should_extend_timeout = updater_state in EXTENDED_TIMEOUT_UPDATER_STATES
|
||||
failed_count = ui_state.params.get("UpdateFailedCount")
|
||||
failed = False if failed_count is None else int(failed_count) > 0
|
||||
|
||||
@@ -437,6 +453,8 @@ class UpdateOpenpilotBigButton(BigButton):
|
||||
if self._state != UpdaterState.WAITING_FOR_UPDATER:
|
||||
self._waiting_for_updater_t = None
|
||||
|
||||
self._set_extended_timeout(should_extend_timeout)
|
||||
|
||||
|
||||
class DeviceLayoutMici(NavWidget):
|
||||
def __init__(self, back_callback: Callable):
|
||||
|
||||
@@ -448,8 +448,9 @@ class WifiManager:
|
||||
|
||||
if "802-11-wireless" in settings:
|
||||
ssid = settings['802-11-wireless']['ssid'][1].decode("utf-8", "replace")
|
||||
if ssid != "":
|
||||
conns[ssid] = conn_path
|
||||
ssid_key = _canonicalize_ssid(ssid)
|
||||
if ssid_key != "":
|
||||
conns[ssid_key] = conn_path
|
||||
return conns
|
||||
|
||||
def _get_active_connections(self):
|
||||
@@ -626,7 +627,7 @@ class WifiManager:
|
||||
return
|
||||
|
||||
def worker():
|
||||
conn_path = self._get_connections().get(ssid, None)
|
||||
conn_path = self._get_connections().get(_canonicalize_ssid(ssid), None)
|
||||
if conn_path is not None:
|
||||
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'))
|
||||
@@ -680,7 +681,7 @@ class WifiManager:
|
||||
return
|
||||
|
||||
def worker():
|
||||
conn_path = self._get_connections().get(ssid, None)
|
||||
conn_path = self._get_connections().get(_canonicalize_ssid(ssid), None)
|
||||
if conn_path is not None:
|
||||
if self._wifi_device is None:
|
||||
cloudlog.warning("No WiFi device found")
|
||||
@@ -717,7 +718,7 @@ class WifiManager:
|
||||
ap_addr = DBusAddress(specific_obj_path, bus_name=NM, interface=NM_ACCESS_POINT_IFACE)
|
||||
ap_ssid = bytes(self._router_main.send_and_get_reply(Properties(ap_addr).get('Ssid')).body[0][1]).decode("utf-8", "replace")
|
||||
|
||||
if ap_ssid == ssid:
|
||||
if _canonicalize_ssid(ap_ssid) == _canonicalize_ssid(ssid):
|
||||
self._router_main.send_and_get_reply(new_method_call(self._nm, 'DeactivateConnection', 'o', (conn_path,)))
|
||||
return
|
||||
|
||||
@@ -1026,7 +1027,7 @@ class WifiManager:
|
||||
cloudlog.exception(f"Failed to parse AP properties for {ap_path}")
|
||||
|
||||
known_connections = self._get_connections()
|
||||
networks = [Network.from_dbus(ssid, ap_list, ssid in known_connections) for ssid, ap_list in aps.items()]
|
||||
networks = [Network.from_dbus(ssid, ap_list, _canonicalize_ssid(ssid) in known_connections) for ssid, ap_list in aps.items()]
|
||||
# sort with quantized strength to reduce jumping
|
||||
networks.sort(key=lambda n: (-n.is_connected, -round(n.strength / 100 * 2), n.ssid.lower()))
|
||||
self._networks = networks
|
||||
|
||||
Reference in New Issue
Block a user