Dismiss WiFi boot prompt when mobile session opens

This commit is contained in:
2026-10-09 12:26:55 +08:00
parent a277da0f96
commit c0e26b97fe
16 changed files with 250 additions and 18 deletions
+21 -10
View File
@@ -112,6 +112,7 @@ class WifiNetworkService:
self.monotonic = monotonic
self.poll_seconds = poll_seconds
self._lock = threading.RLock()
self._indicator_lock = threading.RLock()
self.configuration_lock = self._lock
self.settings_revision = str(uuid4())
self._stop = threading.Event()
@@ -156,13 +157,14 @@ class WifiNetworkService:
self.display.dismiss_wifi_indicator()
def dismiss_for_boot(self) -> None:
try:
changed = self.store.dismiss_for_boot()
except Exception:
logger.exception("Failed to persist WiFi indicator dismissal")
changed = True
if changed or self.display.get_status()["state"].get("wifi_indicator_active"):
self.display.dismiss_wifi_indicator()
with self._indicator_lock:
try:
changed = self.store.dismiss_for_boot()
except Exception:
logger.exception("Failed to persist WiFi indicator dismissal")
changed = True
if changed or self.display.get_status()["state"].get("wifi_indicator_active"):
self.display.dismiss_wifi_indicator()
def get_status(self, *, include_secret: bool = False) -> dict[str, Any]:
managed_uuid = self.store.config["managed_connection_uuid"]
@@ -342,6 +344,8 @@ class WifiNetworkService:
self._stop.wait(self.poll_seconds)
def _refresh_indicator(self) -> None:
if self.store.session["dismissed"]:
return
managed_uuid = self.store.config["managed_connection_uuid"]
try:
active = self.backend.read_active()
@@ -350,7 +354,7 @@ class WifiNetworkService:
f"SSID: {active['ssid']} "
f"IP: http://{active['ipv4_address']}:8080/"
)
self.display.show_wifi_indicator(connected=True, message=message)
self._show_indicator_unless_dismissed(connected=True, message=message)
return
if managed_uuid:
@@ -359,6 +363,13 @@ class WifiNetworkService:
message = f"SSID: {saved.get('ssid') or '未配置'} 密码: {password}"
else:
message = "尚未配置 WiFi"
self.display.show_wifi_indicator(connected=False, message=message)
self._show_indicator_unless_dismissed(connected=False, message=message)
except NetworkManagerError:
self.display.show_wifi_indicator(connected=False, message="WiFi 状态不可用")
self._show_indicator_unless_dismissed(connected=False, message="WiFi 状态不可用")
def _show_indicator_unless_dismissed(self, *, connected: bool, message: str) -> None:
# NetworkManager reads happen outside this lock so opening a mobile
# session never waits for them. Recheck at the actual submission point.
with self._indicator_lock:
if not self.store.session["dismissed"]:
self.display.show_wifi_indicator(connected=connected, message=message)