From 8aa143deb08b16d8e55ef8bedaeb63576df38690 Mon Sep 17 00:00:00 2001 From: Danny Date: Wed, 25 Nov 2026 13:45:15 -0800 Subject: [PATCH] Galaxy: Accept phone internet when the phone starts sharing The Galaxy web card that turned phone internet on is gone, and the Android app now offers the switch in its own connection options. A heartbeat from a phone on the Galaxy hotspot now turns sharing on, so the comma accepts the phone without a separate setting. The phone's own opt-in, with its disclosure, is the consent. LAN, remote and second-phone heartbeats are still refused. --- openpilot/starpilot/galaxy/companion.py | 8 +++++--- openpilot/starpilot/galaxy/tests/test_companion.py | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openpilot/starpilot/galaxy/companion.py b/openpilot/starpilot/galaxy/companion.py index 27779e2973..47596b3fdc 100644 --- a/openpilot/starpilot/galaxy/companion.py +++ b/openpilot/starpilot/galaxy/companion.py @@ -102,9 +102,11 @@ class CompanionRegistry: # The same hotspot peer may rotate credentials (app restart); only a different phone is refused. if previous and previous['peer'] != peer: raise FileExistsError('Another phone is sharing data') - enabled = self.enabled() - if enabled: - atomic_json(self.lease_path, {**lease, 'updated': self.clock()}) + # The phone's own opt-in (with its disclosure) is consent: a hotspot heartbeat turns sharing on. + if not self.enabled(): + atomic_json(self.path, {'enabled': True}) + enabled = True + atomic_json(self.lease_path, {**lease, 'updated': self.clock()}) return {'ok': True, 'enabled': enabled, 'active': phone_uplink_active(self.status_path, self.clock), 'protocol': COMPANION_PROTOCOL, 'uploadDenyHosts': UPLOAD_DENY_HOSTS} diff --git a/openpilot/starpilot/galaxy/tests/test_companion.py b/openpilot/starpilot/galaxy/tests/test_companion.py index 8468a826d4..9a794c2995 100644 --- a/openpilot/starpilot/galaxy/tests/test_companion.py +++ b/openpilot/starpilot/galaxy/tests/test_companion.py @@ -18,10 +18,9 @@ def registry(tmp_path, now=lambda: 100): def test_opt_in_and_stale_lease(tmp_path): now = [100] owner = registry(tmp_path, lambda: now[0]) - assert not owner.heartbeat(PAYLOAD, PEER)['enabled'] - assert owner.lease() is None - owner.save({'enabled': True}) + owner.save({'enabled': False}) assert owner.heartbeat(PAYLOAD, PEER)['enabled'] + assert owner.enabled() assert stat.S_IMODE(owner.lease_path.stat().st_mode) == 0o600 assert owner.snapshot()['connected'] assert 'pass' not in owner.snapshot()