mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-29 09:11:17 +01:00
Checking a permission means *asking* for it on Apple platforms — instantiating
the BLE stack raises the Bluetooth dialog, and probing Bonjour raises the Local
Network one. Connection.initialize() runs from _StarterState.initState, so a
fresh install got both before the wizard had explained anything.
Launch-time checks are still the right thing for everyone else: a rider who
revoked a permission in System Settings should find out then, not from a
connection that silently does nothing. So defer only the case with nothing to
check for — onboarding not yet run *and* no connection method switched on:
deferLaunchPermissionChecks(onboardingAction:, anyConnectionMethodEnabled:)
kept as a pure function beside decideOnboardingTrigger so navigation and
Connection cannot drift, and reachable as core.logic.deferLaunchPermissions.
Reading it during Connection.initialize() is safe: setLastSeenVersion is
written later (navigation.dart), so the pref still holds the previous launch's
value. An existing install upgrading reads markCompleted and is not degraded.
hasAnyConnectionMethodEnabled is new rather than !hasNoConnectionMethod: that
one mixes in show* visibility predicates, so it answers "should the UI nag"
rather than "did the rider turn something on".
startEnabledConnectionMethod() now gates the three network methods on Local
Network, mirroring what the BLE branches already did. They previously started
regardless and failed silently when the permission was off — the shape behind
the support tickets. The probe only runs when one of them is enabled, so a
BLE-only rider never sees the dialog, and a denial raises a warning instead of
a server listening into a black hole.
Third path, found only because a test that should have passed did not:
PermissionsSnapshot.gather() forced a probe, and _persistCrash builds a
diagnostics bundle on every recorded error —
LocalNetworkAccess.status <- PermissionsSnapshot.gather <- DebugDiagnostics.gather
<- debugText (menu.dart) <- _persistCrash (main.dart)
so any error at launch could pop the dialog past every gate above. Tie the
probe to the existing includeDiscovery seam, which the crash handler already
passes false for precisely because it must not do live network work.
User-initiated support bundles still get a fresh probe.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>