mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 17:13:54 +08:00
Trim trivial verbose comments
This commit is contained in:
@@ -320,7 +320,6 @@ class SharedBluetoothOwner(BluetoothOwner):
|
||||
self.phone_lease = None
|
||||
window = self.pairing
|
||||
if isinstance(window, OpenPairingSession) and not window.done.is_set():
|
||||
# Let the phone window put its visibility back before the lease restores the original.
|
||||
window.cancel()
|
||||
window.done.wait(5.0)
|
||||
if lease.session is not None:
|
||||
@@ -639,7 +638,6 @@ class SharedBluetoothOwner(BluetoothOwner):
|
||||
raise BluetoothRejected('Stop projection before changing its adapter', code='projection_active')
|
||||
device = lease.phone.device(address)
|
||||
if operation == 'forget':
|
||||
# Any other device on this adapter, never the projection receiver (rejected above).
|
||||
if device is None or not device['path'].startswith(lease.adapter_path + '/'):
|
||||
raise BluetoothRejected('Device is unavailable', code='changed')
|
||||
client.operation('forget', address)
|
||||
@@ -707,7 +705,6 @@ class SharedBluetoothOwner(BluetoothOwner):
|
||||
window = OpenPairingSession(session, lambda: self.session_valid(session) and self.parked(), self.clock)
|
||||
self.pairing = window
|
||||
self.window_paired = None
|
||||
# The lease already journals the original visibility; the window only returns it to the lease's state.
|
||||
threading.Thread(target=self._accept_worker, args=(window, lambda *_: None, lambda: None), daemon=True).start()
|
||||
threading.Thread(target=self._watch_pair, args=(window,), daemon=True).start()
|
||||
elif operation == 'cancel_pair':
|
||||
|
||||
@@ -50,7 +50,6 @@ JOIN_TIMEOUT_S = 120.0
|
||||
BSSID_SHARE = 0.75
|
||||
CONNECTION_ID = "starpilot-android-auto"
|
||||
SECURITY_WPA3 = (32,)
|
||||
# Written before a session turns wlan0 autoconnect off, removed once it is back on; a crash leaves it for recovery.
|
||||
AUTOCONNECT_MARKER = DATA_DIR / "wifi_autoconnect_paused.json"
|
||||
|
||||
|
||||
@@ -189,7 +188,7 @@ class NetworkLease:
|
||||
if self._get(path, NM_DEVICE_IFACE, "DeviceType") == DEVICE_TYPE_WIFI:
|
||||
devices.append((path, self._get(path, NM_DEVICE_IFACE, "Interface")))
|
||||
except NetworkError:
|
||||
continue # removed while listing
|
||||
continue
|
||||
return devices
|
||||
|
||||
def _wifi_device(self) -> str:
|
||||
@@ -321,7 +320,6 @@ class NetworkLease:
|
||||
if self.device_ready:
|
||||
return
|
||||
deadline = time.monotonic() + DEVICE_READY_TIMEOUT_S
|
||||
# NetworkManager registers a new interface a moment after the kernel creates it.
|
||||
while not (path := next((path for path, name in self._wifi_devices() if name == self.interface), "")):
|
||||
self._wait_step(deadline, cancelled, f"{self.interface} is not a NetworkManager Wi-Fi device")
|
||||
self.device_path = path
|
||||
@@ -352,7 +350,7 @@ class NetworkLease:
|
||||
self._set(self.device_path, NM_DEVICE_IFACE, "Autoconnect", "b", False)
|
||||
self.autoconnect_paused = True
|
||||
elif _paused_interface(self.marker) == self.interface:
|
||||
self.autoconnect_paused = True # an earlier session paused it and never got to turn it back on
|
||||
self.autoconnect_paused = True
|
||||
except NetworkError as error:
|
||||
self.log("wifi_autoconnect_pause_failed", error=str(error))
|
||||
|
||||
@@ -430,7 +428,6 @@ class NetworkLease:
|
||||
reactivated only when the session finally stops, avoiding churn between attempts.
|
||||
"""
|
||||
with self._lock:
|
||||
# Each attempt's release closes D-Bus; the final one may still owe a restore.
|
||||
if self.router is None and not (restore and (self.previous_connection or self.autoconnect_paused)):
|
||||
return
|
||||
ours_active = False
|
||||
@@ -455,7 +452,7 @@ class NetworkLease:
|
||||
self._set(self.device_path, NM_DEVICE_IFACE, "Autoconnect", "b", True)
|
||||
self.marker.unlink(missing_ok=True)
|
||||
except (NetworkError, OSError) as error:
|
||||
self.log("wifi_autoconnect_restore_failed", error=str(error)) # the marker stays; the daemon retries while idle
|
||||
self.log("wifi_autoconnect_restore_failed", error=str(error))
|
||||
self.autoconnect_paused = False
|
||||
if restore and ours_active and self.previous_connection and self.device_path:
|
||||
try:
|
||||
|
||||
@@ -78,8 +78,8 @@ class FakeHeadUnit:
|
||||
unsolicited_focus: bool = False, version: tuple[int, int] = (1, 7), ack_codec_config: bool | int = True,
|
||||
connect_to: tuple[str, int] | None = None, ack_fragments: bool = False):
|
||||
self.unsolicited_focus = unsolicited_focus
|
||||
self.connect_to = connect_to # dial the phone, as HeadunitPad does, instead of waiting for it
|
||||
self.ack_fragments = ack_fragments # like HeadunitPad: one ACK per received video fragment
|
||||
self.connect_to = connect_to
|
||||
self.ack_fragments = ack_fragments
|
||||
self.fragments = 0
|
||||
self.ack_codec_config = ack_codec_config
|
||||
self.codec_configs: list[tuple[int | None, bytes, int]] = [] # (session, SPS/PPS, frames received before it)
|
||||
|
||||
@@ -101,7 +101,6 @@ def test_sender_is_best_effort_when_native_ui_unavailable(tmp_path):
|
||||
|
||||
|
||||
def test_tap_after_a_frame_draw_still_sends(transport):
|
||||
# The car screen reads car state, draws for ~25 ms, then handles taps: past carState's 20 ms control limit.
|
||||
import time
|
||||
from openpilot.starpilot.system.android_auto.projection_bookmark import request_bookmark
|
||||
from openpilot.starpilot.ui.runtime_snapshot import current_message, display_message
|
||||
|
||||
@@ -468,7 +468,6 @@ class TestProjectionOnroad(unittest.TestCase):
|
||||
self.assertIs(view._with_mode_notice(experimental, 1_000 + projection.MODE_NOTICE_NS), experimental)
|
||||
self.assertEqual(view._with_mode_notice(chill, 5_000_000_000).alert.text1, 'Chill Mode')
|
||||
|
||||
# Conditional mode: automatic switching and unreported frames stay quiet; a driver override is announced.
|
||||
view = projection.ProjectionOnroad(dependencies=native)
|
||||
def conditional(reason, effective=True):
|
||||
return State(experimental_enabled=effective, conditional_configured=ModeChoice.CEM,
|
||||
@@ -479,7 +478,6 @@ class TestProjectionOnroad(unittest.TestCase):
|
||||
self.assertIs(view._with_mode_notice(frame, now), frame)
|
||||
self.assertEqual(view._with_mode_notice(conditional('manual_chill', False), 10).alert.text1, 'Chill Mode')
|
||||
|
||||
# Disengaged, conditional mode reports nothing, so the banner follows the mode flag.
|
||||
view = projection.ProjectionOnroad(dependencies=native)
|
||||
def parked(experimental):
|
||||
return State(experimental_enabled=experimental, conditional_configured=ModeChoice.CCM, engaged=False)
|
||||
@@ -487,7 +485,6 @@ class TestProjectionOnroad(unittest.TestCase):
|
||||
self.assertEqual(view._with_mode_notice(parked(True), 1).alert.text1, 'Experimental Mode')
|
||||
self.assertEqual(view._with_mode_notice(parked(False), 3_000_000_000).alert.text1, 'Chill Mode')
|
||||
|
||||
# The planner handing back to conditional mode, and engaging or disengaging, are not the driver's doing.
|
||||
view = projection.ProjectionOnroad(dependencies=native)
|
||||
view._with_mode_notice(conditional('manual_chill', False), 0)
|
||||
for now, frame in enumerate((conditional('lead', True), conditional('manual_experimental', True)), start=1):
|
||||
|
||||
@@ -177,10 +177,9 @@ def test_projected_taps_tolerate_touchscreen_drift():
|
||||
emitted = []
|
||||
gesture = OnroadInput(emitted.append, slop=30)
|
||||
gesture.press(x, y, state)
|
||||
gesture.move(x + 12, y - 9, state) # 8 by 6 physical pixels on the head unit
|
||||
gesture.move(x + 12, y - 9, state)
|
||||
gesture.release(x + 15, y - 12, state)
|
||||
assert emitted == [OnroadRequest('set_experimental', True, '')]
|
||||
# A drag is still not a tap.
|
||||
gesture.press(x, y, state)
|
||||
gesture.release(x + 40, y, state)
|
||||
assert len(emitted) == 1
|
||||
|
||||
@@ -27,7 +27,6 @@ ACTION_POINTER_UP = 6
|
||||
MAX_INPUT_BYTES = 16 * 1024
|
||||
MAX_KEYCODES = 256
|
||||
DEFAULT_TOUCH_SOCKET = "/tmp/starpilot-android-auto-touch.sock"
|
||||
# Android keycodes the head unit sends for the steering wheel and its own media buttons.
|
||||
MEDIA_KEYS = {85: "play_pause", 87: "next", 88: "previous", 126: "play", 127: "pause"}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class HomeState:
|
||||
temperature_c: float | None = None
|
||||
vehicle_online: bool = True
|
||||
connection: str = "OFFLINE"
|
||||
bluetooth: str = "" # off, on, connected; empty hides the icon
|
||||
bluetooth: str = ""
|
||||
gpu_present: bool = False
|
||||
gpu_active: bool = False
|
||||
recording_audio: bool = False
|
||||
@@ -78,7 +78,7 @@ class HomeState:
|
||||
gpu_state: str = "disconnected"
|
||||
metric: bool = False
|
||||
temperature_high: bool = False
|
||||
jetlink: str = "off" # off, plugged (host on the cable), connected (host on the link)
|
||||
jetlink: str = "off"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
@@ -335,7 +335,7 @@ class OnroadInput:
|
||||
def __init__(self, emit: Callable[[OnroadRequest | SlcUiRequest], None], profile: Profile = Profile.LARGE, slop: float = 5):
|
||||
self.emit = emit
|
||||
self.profile = profile
|
||||
self.slop = slop # how far a tap may drift before it stops being a tap
|
||||
self.slop = slop
|
||||
self._press: tuple[float, float, bool, str] | None = None
|
||||
self._slc_press: tuple[float, float, SlcUiRequest] | None = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user