mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 00:53:45 +08:00
AA connection handling and improve UI messaging for wired connections
This commit is contained in:
@@ -2015,9 +2015,10 @@ def make_server(*, port=8082, host='127.0.0.1', monitor=None, owner=None, crashe
|
||||
runtime = aa_client().call('status')['status']
|
||||
if runtime.get('pairing_ready'):
|
||||
raise ValueError('Finish or cancel pairing first')
|
||||
if command == 'start' and ((not runtime.get('receiver_address') and runtime.get('connection') != 'wired') or
|
||||
not aa_setup_owner().identity_status().get('installed')):
|
||||
raise ValueError('Select a car and verify your Android Auto package first')
|
||||
if command == 'start' and not runtime.get('receiver_address') and runtime.get('connection') != 'wired':
|
||||
raise ValueError('Select a car first')
|
||||
if command == 'start' and not aa_setup_owner().identity_status().get('installed'):
|
||||
raise ValueError('Verify your Android Auto package first')
|
||||
self.aa_command(identity, command, **arguments)
|
||||
current = aa_client().call('status')['status']
|
||||
except ValueError as error:
|
||||
|
||||
@@ -72,6 +72,7 @@ def api(tmp_path):
|
||||
self.receiver = ''
|
||||
self.running = False
|
||||
self.auto_connect = False
|
||||
self.connection = 'wireless'
|
||||
self.available = True
|
||||
self.stop_error = False
|
||||
self.stop_completes = True
|
||||
@@ -80,13 +81,16 @@ def api(tmp_path):
|
||||
self.calls.append((command, dict(kwargs)))
|
||||
if command == 'status':
|
||||
return {'status': {'receiver_address': self.receiver, 'receiver_name': 'My car', 'state': 'streaming' if self.running else 'idle',
|
||||
'running': self.running, 'auto_connect': self.auto_connect, 'pairing_ready': False}}
|
||||
'running': self.running, 'auto_connect': self.auto_connect, 'pairing_ready': False,
|
||||
'connection': self.connection}}
|
||||
if command == 'devices':
|
||||
return {'devices': [{'address': 'AA:BB:CC:DD:EE:FF', 'name': 'Saved car', 'paired': True, 'android_auto': True}]}
|
||||
if command == 'select_receiver':
|
||||
self.receiver = kwargs['address']
|
||||
if command == 'set_auto_connect':
|
||||
self.auto_connect = kwargs['enabled']
|
||||
if command == 'set_connection':
|
||||
self.connection = kwargs['connection']
|
||||
if command == 'start':
|
||||
self.running = True
|
||||
if command == 'stop':
|
||||
@@ -399,6 +403,29 @@ def test_existing_paired_car_controls_are_local_authenticated_and_source_bound(a
|
||||
cookie=cookie, content_type='application/json')[0] == 401
|
||||
|
||||
|
||||
def test_wired_connection_requires_park_but_not_a_paired_receiver(api):
|
||||
request, _, state, client = api
|
||||
code, _, headers = request('POST', '/api/auth/login', json.dumps({'password': 'password123'}),
|
||||
content_type='application/json')
|
||||
assert code == 200
|
||||
cookie = headers['Set-Cookie'].split(';', 1)[0]
|
||||
payload = json.dumps({'action': 'connection', 'connection': 'wired'})
|
||||
state['parked'] = False
|
||||
assert request('POST', '/api/android-auto/control', payload, cookie=cookie, content_type='application/json')[0] == 403
|
||||
state['parked'] = True
|
||||
code, result, _ = request('POST', '/api/android-auto/control', payload, cookie=cookie, content_type='application/json')
|
||||
assert code == 200 and result['status']['connection'] == 'wired'
|
||||
assert request('POST', '/api/android-auto/control', json.dumps({'action': 'start'}), cookie=cookie,
|
||||
content_type='application/json')[0] == 200
|
||||
assert client.running
|
||||
|
||||
client.running = False
|
||||
state['identity_installed'] = False
|
||||
code, result, _ = request('POST', '/api/android-auto/control', json.dumps({'action': 'start'}), cookie=cookie,
|
||||
content_type='application/json')
|
||||
assert code == 409 and result['error'] == 'Verify your Android Auto package first'
|
||||
|
||||
|
||||
def test_local_enable_then_upload_bundle_preserves_binary_bytes(api):
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
@@ -454,7 +454,17 @@ export const AndroidAutoPage = {
|
||||
},
|
||||
supportReady() { return !!(this.setup?.enabled && this.setup.identity.installed) },
|
||||
// Returning drivers see a status card; the setup steps fold away below it.
|
||||
setupDone() { return !!(this.supportReady && this.selected && !this.pairing?.active) },
|
||||
wired() { return this.runtime?.connection === "wired" },
|
||||
connectionName() { return this.wired ? "car" : this.selected?.name || "car" },
|
||||
setupDone() { return !!(this.supportReady && (this.selected || this.wired) && !this.pairing?.active) },
|
||||
wiredRow() {
|
||||
const detail = "Project over a USB cable from the car to the comma’s USB-C port instead of Bluetooth and Wi-Fi."
|
||||
return switchRow("Wired USB Connection", this.wired, detail + (this.runtime?.wired_blocked ? ` ${this.runtime.wired_blocked}.` : ""))
|
||||
},
|
||||
wiredDisabled() {
|
||||
return !this.setup?.enabled || !this.setup.parked || !!this.pairing?.active || !!this.runtime?.running ||
|
||||
(!!this.runtime?.wired_blocked && !this.wired)
|
||||
},
|
||||
download() { return downloadLink(this.setup?.download, this.setup?.downloadPending === true) },
|
||||
uploadPercent() {
|
||||
const { loaded, total } = this.uploadProgress || {}
|
||||
@@ -637,15 +647,15 @@ export const AndroidAutoPage = {
|
||||
<section class="gx-driving" aria-label="Android Auto setup" :inert="busy" :aria-busy="busy || undefined">
|
||||
<header class="gx-page-header">
|
||||
<h2>Android Auto</h2>
|
||||
<p>Show the StarPilot driving view on your car’s screen. Set up support, pair your car, then connect.</p>
|
||||
<p>Show the StarPilot driving view on your car’s screen. Set up support, {{ wired ? 'plug in your car' : 'pair your car' }}, then connect.</p>
|
||||
</header>
|
||||
<GxNotice tone="warn">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.</GxNotice>
|
||||
<GxNotice tone="warn" v-if="!wired">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.</GxNotice>
|
||||
<GxNotice tone="danger" v-if="error && setup">{{ error }}</GxNotice>
|
||||
<GxNotice v-if="!setup" :busy="!error" :tone="error ? 'danger' : 'info'">{{ error || "Checking Android Auto setup… Reconnecting automatically…" }}</GxNotice>
|
||||
<section v-if="setup && setupDone" class="gx-card gx-aa-step gx-aa-home" aria-labelledby="gx-aa-home-title">
|
||||
<div class="gx-aa-step__head">
|
||||
<span class="gx-aa-step__num" :class="{ 'gx-aa-home__icon--live': projecting }" aria-hidden="true"><i class="bi bi-car-front"></i></span>
|
||||
<div><h3 id="gx-aa-home-title">{{ projecting ? 'Connected to ' + selected.name : runtime?.running ? 'Connecting to ' + selected.name : selected.name }}</h3>
|
||||
<div><h3 id="gx-aa-home-title">{{ projecting ? 'Connected to ' + connectionName : runtime?.running ? 'Connecting to ' + connectionName : connectionName }}</h3>
|
||||
<p role="status">{{ runtime?.running && runtime.state !== 'streaming' && runtime.label ? runtime.label : runtime?.running ? 'Showing StarPilot on your car’s screen.' : runtime?.auto_connect ? 'Connects automatically when you start driving.' : 'Ready to connect.' }}</p></div>
|
||||
</div>
|
||||
<div class="gx-aa-step__body">
|
||||
@@ -655,8 +665,7 @@ export const AndroidAutoPage = {
|
||||
<GalaxySettingRow :row="switchRow('Automatic Connection', runtime?.auto_connect, 'Connect to your car whenever you start driving.')"
|
||||
:index="0" :busy="busy" :disabled="!setup.enabled || !setup.parked || !!pairing?.active"
|
||||
:save-value="(index, value) => control('auto_connect', { enabled: value === 'On' })" />
|
||||
<GalaxySettingRow :row="switchRow('Wired USB Connection', runtime?.connection === 'wired', 'Project over a USB cable from the car to the comma’s USB-C port instead of Bluetooth and Wi-Fi.' + (runtime?.wired_blocked ? ' ' + runtime.wired_blocked + '.' : ''))"
|
||||
:index="0" :busy="busy" :disabled="!setup.enabled || !setup.parked || !!pairing?.active || !!runtime?.running || (!!runtime?.wired_blocked && runtime?.connection !== 'wired')"
|
||||
<GalaxySettingRow :row="wiredRow" :index="0" :busy="busy" :disabled="wiredDisabled"
|
||||
:save-value="(index, value) => control('connection', { connection: value === 'On' ? 'wired' : 'wireless' })" />
|
||||
<div class="gx-actions">
|
||||
<a class="gx-btn gx-btn--tonal" href="#/theme_maker/android_auto"><i class="bi bi-layout-text-window" aria-hidden="true"></i> Customize Layout</a>
|
||||
@@ -785,13 +794,12 @@ export const AndroidAutoPage = {
|
||||
<GalaxySettingRow :row="switchRow('Automatic Connection', runtime?.auto_connect, 'Connect to your car whenever you start driving.')"
|
||||
:index="0" :busy="busy" :disabled="!setup.enabled || !setup.parked || !!pairing?.active"
|
||||
:save-value="(index, value) => control('auto_connect', { enabled: value === 'On' })" />
|
||||
<GalaxySettingRow :row="switchRow('Wired USB Connection', runtime?.connection === 'wired', 'Project over a USB cable from the car to the comma’s USB-C port instead of Bluetooth and Wi-Fi.' + (runtime?.wired_blocked ? ' ' + runtime.wired_blocked + '.' : ''))"
|
||||
:index="0" :busy="busy" :disabled="!setup.enabled || !setup.parked || !!pairing?.active || !!runtime?.running || (!!runtime?.wired_blocked && runtime?.connection !== 'wired')"
|
||||
<GalaxySettingRow :row="wiredRow" :index="0" :busy="busy" :disabled="wiredDisabled"
|
||||
:save-value="(index, value) => control('connection', { connection: value === 'On' ? 'wired' : 'wireless' })" />
|
||||
<p v-if="runtime?.companion_name" class="gx-note">Car: {{ runtime.companion_name }}</p>
|
||||
<details class="gx-aa-wiki"><summary>Stuck connecting? Wi-Fi and screen troubleshooting</summary>
|
||||
<ul>
|
||||
<li><strong>How it connects:</strong> after Bluetooth, the car (or adapter) creates its own hidden 5 GHz Wi-Fi network and tells the comma how to join. The picture streams over that Wi-Fi.</li>
|
||||
<li v-if="!wired"><strong>How it connects:</strong> after Bluetooth, the car (or adapter) creates its own hidden 5 GHz Wi-Fi network and tells the comma how to join. The picture streams over that Wi-Fi.</li>
|
||||
<li><strong>First connection:</strong> stay in Park or offroad mode, and keep the car’s screen on.</li>
|
||||
<li><strong>Black or frozen screen:</strong> tap Disconnect, wait a few seconds, then connect again. If it keeps happening, turn the car off and on.</li>
|
||||
<li><strong>Car says the phone isn’t compatible:</strong> make sure wireless Android Auto (sometimes called “smartphone connection”) is turned on in the car’s settings, and that step 1 shows Ready.</li>
|
||||
|
||||
Reference in New Issue
Block a user