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.
This commit is contained in:
Danny
2026-11-25 13:45:15 -08:00
parent 3d6d69b70d
commit 8aa143deb0
2 changed files with 7 additions and 6 deletions
+5 -3
View File
@@ -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}
@@ -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()