diff --git a/openpilot/starpilot/galaxy/web/js/android-auto.js b/openpilot/starpilot/galaxy/web/js/android-auto.js index c78e41ee73..305ea2eda6 100644 --- a/openpilot/starpilot/galaxy/web/js/android-auto.js +++ b/openpilot/starpilot/galaxy/web/js/android-auto.js @@ -773,35 +773,7 @@ export const AndroidAutoPage = { Android Auto uses the comma’s Wi-Fi to project to your car and disconnects it from your current Wi-Fi network. Use the Galaxy hotspot for local access during projection. Remote Galaxy access requires Internet on the comma. {{ error }} {{ error || "Checking Android Auto setup… Reconnecting automatically…" }} -
-
- -

{{ projecting ? 'Connected to ' + connectionName : runtime?.running ? 'Connecting to ' + connectionName : connectionName }}

-

{{ runtime?.running && runtime.state !== 'streaming' && runtime.label ? runtime.label : runtime?.running ? 'Showing StarPilot on your car’s screen.' : wired ? wiredStatus.label : runtime?.auto_connect ? 'Connects automatically when you start driving.' : 'Ready to connect.' }}

-
-
-

{{ expiry.label }}

- - - - ${WIRED_STATUS} - - - -
- Customize Layout - -
-
-
-
    -
  1. +

    Android Auto Support

    {{ expiry.label }}

    Turn on Android Auto and install support. Wireless pairing also needs Bluetooth on; Galaxy will offer to enable it.

    @@ -840,8 +812,35 @@ export const AndroidAutoPage = {
    -
  2. - + +
    +
    + +

    {{ projecting ? 'Connected to ' + connectionName : runtime?.running ? 'Connecting to ' + connectionName : connectionName }}

    +

    {{ runtime?.running && runtime.state !== 'streaming' && runtime.label ? runtime.label : runtime?.running ? 'Showing StarPilot on your car’s screen.' : wired ? wiredStatus.label : runtime?.auto_connect ? 'Connects automatically when you start driving.' : 'Ready to connect.' }}

    +
    +
    +

    {{ expiry.label }}

    + + + + ${WIRED_STATUS} + + + +
    + Customize Layout + +
    +
    +
    +
    1. diff --git a/openpilot/starpilot/system/android_auto/bluetooth_bridge.py b/openpilot/starpilot/system/android_auto/bluetooth_bridge.py index 2b40dbf7ac..3849120545 100644 --- a/openpilot/starpilot/system/android_auto/bluetooth_bridge.py +++ b/openpilot/starpilot/system/android_auto/bluetooth_bridge.py @@ -228,6 +228,27 @@ class SharedBluetoothOwner(BluetoothOwner): def _admission_busy(self) -> bool: return self.phone_lease is not None or super()._admission_busy() + @staticmethod + def _start_scan(client) -> bool: + """BlueZ can hold a stale discovery request; reset it once, and still open the window (the car can pair to us) if it stays stuck.""" + try: + client.operation('scan') + return True + except BluetoothRejected as error: + if 'InProgress' not in str(error): + raise + try: + client.operation('stop_scan') + except BluetoothRejected: + pass + try: + client.operation('scan') + return True + except BluetoothRejected as error: + if 'InProgress' not in str(error): + raise + return False + def acquire_phone_role(self, session: tuple, phone: PhoneProfile, *, seconds: float = 180.0) -> PhoneRoleLease: if not session or not 0 < seconds <= 180: raise ValueError('Invalid phone-role session or duration') @@ -290,8 +311,7 @@ class SharedBluetoothOwner(BluetoothOwner): self.phone_lease = lease self.admission_file = process_lock try: - client.operation('scan') - lease.discovering = True + lease.discovering = self._start_scan(client) except BaseException: self.release_phone_role(lease) raise