mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-29 17:43:47 +08:00
AA documentation update and improve network recovery logic
This commit is contained in:
@@ -916,7 +916,7 @@ export const AndroidAutoPage = {
|
||||
<p>Pair each car in step 2 with <strong>Pair another</strong>. All your paired cars appear in the list. Tap <strong>Use</strong> next to the one you’re driving. Disconnect first if Android Auto is running.</p>
|
||||
</details>
|
||||
<details class="gx-aa-wiki"><summary>Is my information private?</summary>
|
||||
<p>Yes. Your extracted Android Auto identity stays on your comma. The app downloads straight to your phone or computer, and the copy you upload is deleted after import. Connection logs also stay on the comma until you download them yourself. They leave out Wi‑Fi passwords, Bluetooth addresses, and your vehicle ID.</p>
|
||||
<p>Your extracted Android Auto identity stays on your comma. The app downloads straight to your phone or computer, and the copy you upload is deleted after import. Full connection logs stay on the comma until you download them. When parked and Android Auto is stopped, StarPilot may send connection errors.</p>
|
||||
</details>
|
||||
|
||||
<h4>Wireless Dongle Woes</h4>
|
||||
|
||||
@@ -134,9 +134,9 @@ class DedicatedLease:
|
||||
if self._cancel.is_set() and self.iface is not None:
|
||||
self.iface.close() # the session already ended; nothing else will close it
|
||||
|
||||
def _finish_opening(self, timeout: float | None = None) -> None:
|
||||
def _finish_opening(self) -> None:
|
||||
if self._opening is not None:
|
||||
self._opening.join(timeout)
|
||||
self._opening.join()
|
||||
self._opening = None
|
||||
error, self._open_error = self._open_error, None
|
||||
if error is not None and not self._cancel.is_set():
|
||||
@@ -191,7 +191,7 @@ class DedicatedLease:
|
||||
def release(self, restore: bool = True) -> None:
|
||||
if restore:
|
||||
self._cancel.set()
|
||||
self._finish_opening(timeout=15)
|
||||
self._finish_opening()
|
||||
if self.lease is not None:
|
||||
self.lease.release(restore=restore)
|
||||
if restore:
|
||||
|
||||
@@ -91,9 +91,10 @@ def recover_autoconnect(log: Callable[..., None], marker: Path = AUTOCONNECT_MAR
|
||||
lease = NetworkLease(log, interface)
|
||||
try:
|
||||
path = next((path for path, name in lease._wifi_devices() if name == interface), "")
|
||||
if path:
|
||||
lease._set(path, NM_DEVICE_IFACE, "Autoconnect", "b", True)
|
||||
log("wifi_autoconnect_recovered", interface=interface)
|
||||
if not path:
|
||||
return False
|
||||
lease._set(path, NM_DEVICE_IFACE, "Autoconnect", "b", True)
|
||||
log("wifi_autoconnect_recovered", interface=interface)
|
||||
except NetworkError as error:
|
||||
log("wifi_autoconnect_recover_failed", error=str(error))
|
||||
return False
|
||||
@@ -346,7 +347,8 @@ class NetworkLease:
|
||||
return
|
||||
try:
|
||||
if self._get(self.device_path, NM_DEVICE_IFACE, "Autoconnect"):
|
||||
self._write_marker()
|
||||
if not self._write_marker():
|
||||
return
|
||||
self._set(self.device_path, NM_DEVICE_IFACE, "Autoconnect", "b", False)
|
||||
self.autoconnect_paused = True
|
||||
elif _paused_interface(self.marker) == self.interface:
|
||||
@@ -354,12 +356,14 @@ class NetworkLease:
|
||||
except NetworkError as error:
|
||||
self.log("wifi_autoconnect_pause_failed", error=str(error))
|
||||
|
||||
def _write_marker(self) -> None:
|
||||
def _write_marker(self) -> bool:
|
||||
try:
|
||||
self.marker.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.marker.write_text(json.dumps({"interface": self.interface, "boot": _boot_id()}))
|
||||
return True
|
||||
except OSError as error:
|
||||
self.log("wifi_autoconnect_marker_failed", error=str(error))
|
||||
return False
|
||||
|
||||
def _networks(self, path: str) -> list:
|
||||
config = self._get(path, NM_DEVICE_IFACE, "Ip4Config")
|
||||
|
||||
@@ -1114,6 +1114,28 @@ def test_recover_autoconnect_keeps_the_marker_when_networkmanager_fails(tmp_path
|
||||
assert marker.exists()
|
||||
|
||||
|
||||
def test_recover_autoconnect_waits_for_missing_wifi_device(tmp_path, monkeypatch):
|
||||
from openpilot.starpilot.system.android_auto import network
|
||||
marker = tmp_path / "paused.json"
|
||||
marker.write_text(json.dumps({"interface": "wlan0", "boot": network._boot_id()}))
|
||||
monkeypatch.setattr(network.NetworkLease, "_wifi_devices", lambda self: [])
|
||||
assert not network.recover_autoconnect(lambda event, **fields: None, marker)
|
||||
assert marker.exists()
|
||||
|
||||
|
||||
def test_autoconnect_stays_on_when_recovery_marker_cannot_be_written(tmp_path, monkeypatch):
|
||||
from openpilot.starpilot.system.android_auto import network
|
||||
lease = network.NetworkLease(lambda *args, **kwargs: None)
|
||||
lease.device_path = "/dev/wlan0"
|
||||
lease.marker = tmp_path / "missing" / "paused.json"
|
||||
monkeypatch.setattr(lease, "_get", lambda *args: True)
|
||||
monkeypatch.setattr(lease, "_write_marker", lambda: False)
|
||||
changes = []
|
||||
monkeypatch.setattr(lease, "_set", lambda *args: changes.append(args))
|
||||
lease._pause_autoconnect()
|
||||
assert not lease.autoconnect_paused and changes == []
|
||||
|
||||
|
||||
def test_supervisor_retries_wifi_recovery_while_idle(monkeypatch):
|
||||
from openpilot.starpilot.system.android_auto import network, supervisor
|
||||
results = [False, True]
|
||||
|
||||
Reference in New Issue
Block a user