Commit Graph

101 Commits

Author SHA1 Message Date
Jonas Bark
f76689c451 cleanup 2026-08-21 08:41:31 +02:00
Jonas Bark
905c2641cd feat(ios/macos): detect the Local Network permission instead of failing silently
Denial of Apple's Local Network privacy permission is the most common cause of
"BikeControl can't see my trainer app" on iOS and macOS, and it fails
completely silently: Bonjour browses return nothing forever, advertisements
never leave the device, nothing throws. An app watching only for errors cannot
tell "permission is off" from "there is nothing out there".

Apple ships no authorization-status API for it (not iOS 14...26, not macOS
15...26), so the new local_network_permission plugin measures it: an NWListener
and an NWBrowser on _bikecontrol-preflight._tcp, then

  browser discovers the listener        -> granted
  kDNSServiceErr_PolicyDenied (-65570)  -> denied
  neither, before the deadline          -> unknown

unknown is a real outcome, not an error — a device with no usable network never
completes the round trip even when the permission is fine — so everything fails
open on it and only a positive denial blocks the user.

The probe *is* the request: the system prompt fires on the first Bonjour
operation, so there is no separate request step, and after the user answers,
System Settings is the only way back.

- LocalNetworkAccess caches the result (probes cost a real round trip while
  getStatus() runs on every tile mount, tap and resume) and collapses
  concurrent probes into one, since two listeners on the same service type
  would resolve each other.
- LocalNetworkRequirement gates the three LAN tiles: MyWhoosh Link, Zwift mDNS
  and OpenBikeControl mDNS. Suppressed in screenshot/demo mode like the rest.
- Diagnostics drop the old guess (inferred from whether a discovery scan
  returned anything, which could not tell denied from an empty LAN) for the
  measured local-network=granted|denied|unknown.
- _bikecontrol-preflight._tcp added to NSBonjourServices on both platforms;
  without it the browse fails for a reason unrelated to the permission.

The Xcode project deployment-target bumps (ios 13.0->15.0, macos 10.15->12.0)
are Flutter's own migration aligning project defaults with the Podfiles; they
happen on any first build.

Verified with real builds on both platforms, not just analysis: flutter build
macos --debug and flutter build ios --no-codesign both succeed, the framework
is linked in, and the preflight service type is present in both built
Info.plists. 35 tests cover the mapping, cache, concurrency and fail-open
behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 07:58:18 +02:00
Jonas Bark
87642a9926 feat(6.2): macOS screen recording backend (ScreenCaptureKit)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:28:09 +02:00
Jonas Bark
1b131b312a chore(6.2): lock new deps + regenerate plugin registrants (gal; no screen_recorder native yet) 2026-06-24 17:12:27 +02:00
Jonas Bark
0573c2544c update modules 2026-06-10 09:35:23 +02:00
Jonas Bark
a60a1384e3 Merge origin/universal-ble-2-peripheral: universal_ble 2.0.0 peripheral mode
Brings the BLE peripheral-mode migration to universal_ble 2.0.0 into the
WiFi DirCon trainer-discovery branch and bumps universal_ble to the latest
fork commit (ref: changes, 2.0.0).

Conflict resolutions:
- prop submodule: merged the universal_ble 2.0 transporter migration with
  the WiFi DirCon TrainerTransport refactor; kept the '0x' short-UUID
  normalisation on startAdvertising. Updated BleCharacteristic call sites
  to the new 3-arg (uuid, properties, descriptors) constructor.
- obc_ble_emulator.dart: took the PeripheralServer / universal_ble 2.0
  write-handler migration; kept the richer Error(button:) context on
  sendAction (using _currentDeviceId, the migrated connection tracker).
- unlock.dart: kept the main.dart import.
- pubspec.yaml: kept version 6.0.0+135; took ref: changes for universal_ble.

Pre-existing prop test failures (composite/dircon/fitness serviceUUIDs) are
unchanged by this merge — they fail identically on the pre-merge branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 09:19:58 +02:00
Jonas Bark
1ce9ab43c0 fix scanner 2026-06-10 07:23:36 +02:00
Jonas Bark
29741e520f migrate peripheral mode to universal_ble 2.0.0
Drop bluetooth_low_energy. Move OBC BLE emulator, Zwift emulator, and
the remote mouse / keyboard pairing flows onto a new PeripheralServer
wrapper around UniversalBlePeripheral that routes per-characteristic
read/write handlers, so multiple peripheral instances coexist without
clobbering universal_ble's process-wide handlers.

Also: onValueChange callback gains a timestamp param (v1.0.0 breaking
change), PeripheralManager().showAppSettings() → openAppSettings(),
UUID.short(0x12) → literal UUID, and prop submodule bumped to the
matching universal_ble peripheral rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 09:28:39 +02:00
Jonas Bark
e4ad6135eb overlay: auto-show on startup when trainer connects + remove debug logs
Auto-show:
- Navigation initState now subscribes to core.connection.connectionStream
  when the persisted overlay_enabled flag is true. The first connected
  smart trainer with a FitnessBikeDefinition triggers
  TrainerOverlayService.show(...) with the persisted overlay fields.
- Subscription is one-shot (cancels itself after a successful show) and
  also checks already-connected devices on mount, so the overlay reopens
  whether the trainer was reconnected before or after Navigation mounted.

Debug-log cleanup:
- Removed the `bikecontrol_dart_alive.log` liveness probe, the
  `[main:entry]` / `[main:entry/stderr]` print + stderr.writeln, the
  `[overlay-main]` step-by-step logs in the sub-window dispatch, the
  `[main:wm-spy]` channel-handler wrapper, the `[overlay-run]` /
  `[overlay-sub]` action logs in desktop_overlay_window, the
  `[overlay-main]` action-receive / dispatch-fail logs in
  desktop_overlay_controller, the `[main]` Android handler-retry logs,
  and the noisy `[multi_window_native] CreateNewWindow` cerr in the
  Windows runner.
- Kept catch handlers as silent (or kDebugMode-guarded) where the
  original error path was still useful.

Also: MainFlutterWindow simplified back to NSWindow — the vendored
multi_window_native plugin now creates the overlay sub-window as an
NSPanel with .screenSaver level + .fullScreenAuxiliary itself, so
the main window no longer needs the canBecomeMain/canBecomeKey
NSPanel overrides or the .normal level pin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:35:31 +02:00
Jonas Bark
29a267eba4 overlay/macos: vendor multi_window_native and make sub-windows NSPanels
Forked the upstream package
(https://github.com/Swatimishra8/multi_window_native) into
packages/multi_window_native and pinned pubspec to the path dep.

Key macOS change in the vendored plugin's createNewWindow:
- NSPanel instead of NSWindow with styleMask = [.titled, .closable,
  .resizable, .nonactivatingPanel, .utilityWindow].
- isFloatingPanel = true, becomesKeyOnlyIfNeeded = true,
  hidesOnDeactivate = false.
- level = .screenSaver (highest standard user-space level).
- collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary,
  .stationary, .ignoresCycle].
- Initial size dropped from 1440x900 / minSize 800x900 to 220x140 /
  minSize 160x80 (closer to what the trainer overlay needs).

With those properties set at construction time, the sub-window sits
above fullscreened trainer apps from the moment it's shown — no more
retry loop chasing the window after the fact.

MainFlutterWindow.swift's onEngineCreatedCallback no longer needs the
elevation retry; it just calls RegisterGeneratedPlugins on the new
engine and leaves the window-level work to the plugin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:18:58 +02:00
Jonas Bark
60fd375a2d macos: bump overlay sub-window level from .statusBar to .screenSaver
`.statusBar` (level 25) plus `.fullScreenAuxiliary` wasn't enough to
keep the trainer overlay above fullscreened trainer apps. `.screenSaver`
(1000) is the highest standard user-space window level and reliably
sits above ordinary fullscreen NSWindow content.

The collection behaviour (canJoinAllSpaces + fullScreenAuxiliary +
stationary + ignoresCycle) is unchanged — the level was the missing
piece.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:11:51 +02:00
Jonas Bark
31bdfa74bb macos: pin main panel to .normal and orderFront sub-window after elevation
User reported the trainer overlay sub-window only appeared after
minimising and restoring the main window, and that it still wasn't
above fullscreened trainer apps. Both rooted in stacking:

- `NSPanel`'s default window level can be `.floating` (3) depending on
  style mask, which sits above the sub-window we just elevated to
  `.statusBar` (25)... unless the OS re-stacks. Pin self.level to
  `.normal` (0) so .statusBar unambiguously wins.

- `window.level = ...` doesn't re-stack the window inside its new level
  group. Without an explicit `orderFront(nil)`, the sub-window stays
  visually behind the main panel until something forces a restack
  (which is what minimising + restoring did). Order it to the front
  right after the level change.

Also logs via NSLog whether elevation found the sub-window so we can
confirm next test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:09:46 +02:00
Jonas Bark
6a69efb5d4 overlay/desktop: fix macOS sub-window size + fullscreen elevation timing
Two macOS regressions reported by the user:

- Initial sub-window size way too large. multi_window_native's macOS
  plugin hard-codes the sub-window at 1000x1000 with minSize 800x900
  (see plugin source createNewWindow ~line 148). Override from Dart
  in `_runOverlay`: setMinimumSize(180, 100) then setSize(220, 140).

- Overlay no longer appears above fullscreened trainer apps. The
  plugin fires `onEngineCreatedCallback` BEFORE it creates the
  NSWindow + sets its contentViewController, so our previous single
  `DispatchQueue.main.async { ... }` raced the plugin's own setup and
  found nothing in NSApp.windows. Retry up to 30 times (0.1s apart)
  until the window with our `engine` appears, then apply
  `.statusBar` level + `.fullScreenAuxiliary` collection behaviour.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:05:41 +02:00
Jonas Bark
08f6c5256e macos: let MainFlutterWindow (NSPanel) become the macOS main window
When MainFlutterWindow was changed from NSWindow to NSPanel, the panel
inherited NSPanel's defaults of canBecomeMain=false and canBecomeKey=false
(designed for utility palettes). As a result, NSApp.mainWindow stayed nil.

multi_window_native's macOS plugin registers the main app's messenger by
looking up `NSApp.mainWindow` in its register(with:) hook (plugin source
line 24). With nil, main's messenger never enters the plugin's static
broadcast list, so secondary-window broadcasts (button taps from the
trainer overlay) fan out to a list that doesn't include main. The Dart
listener on main never fires.

Override canBecomeMain and canBecomeKey so the panel participates as the
app's main window.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:04:19 +02:00
Jonas Bark
05fdcd819b macOS 2026-05-12 12:00:36 +02:00
Jonas Bark
3d5a2b5521 fix background 2026-05-12 11:56:48 +02:00
Jonas Bark
960a12d077 overlay/desktop: use multi_window_native on both platforms with selective plugin registration
Drop desktop_multi_window entirely; unify macOS + Windows on
multi_window_native. Windows runner re-gets the CreateNewWindow /
CloseWindow / SetMainWindowMethodHandler plumbing with selective
sub-engine registration (only WindowManagerPlugin +
MultiWindowNativePlugin) to avoid the deadlock caused by full
RegisterPlugins on secondary engines. macOS MainFlutterWindow narrows
onEngineCreatedCallback from RegisterGeneratedPlugins to the same two
plugins for consistency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 11:14:05 +02:00
Jonas Bark
20fc10395d overlay/desktop: use desktop_multi_window on Windows, keep multi_window_native on macOS
Add `desktop_multi_window: ^0.3.0` alongside `multi_window_native: ^1.0.4`.
On Windows the sub-window is now spawned via `WindowController.create` with a
JSON `role=trainer-overlay` argument (detected in `main()` before any heavy
bootstrap), and state/actions flow over `WindowMethodChannel(kOverlayChannel)`.
macOS continues using `MultiWindowNative.createWindow` / `notifyAllWindows` /
`registerListener` unchanged.

Windows runner reverts all `multi_window_native` plumbing:
`SecondaryWindowContext`, `CreateNewWindow`, `CloseWindow`,
`SetMainWindowMethodHandler`, and the plugin source compiled directly into the
runner are removed. `flutter_window.cpp` instead registers
`DesktopMultiWindowSetWindowCreatedCallback` so every sub-engine gets plugins.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 10:33:14 +02:00
Jonas Bark
aa9283137b fix multi window macOS 2026-05-11 10:02:09 +02:00
Jonas Bark
c39d4191f6 overlay/desktop: switch to multi_window_native
Drops desktop_multi_window 0.3.0 in favour of multi_window_native 1.0.4
on a new branch (feature/trainer-overlay-multi-window-native).

Mechanism is different but the responsibilities map cleanly:
- `MultiWindowNative.createWindow([routeName, argsJson, theme])` spawns
  the sub-window; main() detects it via the first arg.
- Communication is broadcast by method name through
  `notifyAllWindows` + `registerListener`. Conventions:
    main → overlay: trainerOverlay.state
    overlay → main: trainerOverlay.action / ready / positionChanged
  Each side filters by method name; the API has no per-window targeting.
- The overlay window grabs its windowId via `windowManager.getId()` and
  broadcasts `trainerOverlay.ready` so the controller can later close it.
- `notifyUiRendered()` is called after the first frame, per the package's
  black-screen workaround on macOS/Windows.

Native shims:
- macOS MainFlutterWindow.swift: re-register plugins on every new
  sub-engine via `MultiWindowNativePlugin.onEngineCreatedCallback`. Kept
  the `.statusBar` / `.fullScreenAuxiliary` elevation for visibility
  above fullscreened trainer apps; the callback now finds the new
  sub-window's NSWindow by matching the FlutterViewController's engine.
- Windows flutter_window.cpp: reverted the desktop_multi_window callback;
  multi_window_native's Windows wiring requires a more invasive
  flutter_window.h / cpp change (SetOnCloseCallback, GetFlutterViewController,
  callback registration in main.cpp) which is TBD. The overlay is only
  verified on macOS in this branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 09:11:00 +02:00
Jonas Bark
5a803b2a18 fix android 2026-05-10 09:36:13 +02:00
Jonas Bark
b71483f0f0 macos: float overlay sub-window above fullscreen trainer apps
window_manager's setVisibleOnAllWorkspaces+visibleOnFullScreen sets the
right collection-behavior bits but leaves the window at the default
(.normal) level, which Zwift / MyWhoosh on their own fullscreen Space
sit above. Set the sub-window's NSWindow.level to .statusBar and add
.fullScreenAuxiliary + .canJoinAllSpaces + .stationary collection
behavior so it floats above the fullscreen app and stays put across
Space switches.

Done in setOnWindowCreatedCallback (dispatched async since
controller.view.window is nil until the view is hosted), affecting only
sub-windows (currently only the trainer overlay).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:27:07 +02:00
Jonas Bark
12fc7eed87 deps: add desktop_multi_window 0.3.0 and wire macOS plugin callback
Add desktop_multi_window ^0.3.0 alongside window_manager. Update
macos/Runner/MainFlutterWindow.swift with the FlutterMultiWindowPlugin
window-created callback so sub-window engines register all generated
plugins automatically. Also includes flutter pub get generated changes to
linux/windows/macos plugin registrants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 16:07:18 +02:00
Jonas Bark
c847a10ed1 some fixes 2026-05-09 10:26:52 +02:00
Jonas Bark
7bd39748bc fix 2026-04-26 13:02:06 +02:00
Jonas Bark
8167f16ee9 fill prop_public 2026-04-26 11:02:23 +02:00
Jonas Bark
3a5e3835f4 ui fixes 2026-04-24 13:42:45 +02:00
Jonas Bark
7c3092c2c9 chore(workout): add fit_tool + share_plus deps and i18n strings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 11:52:43 +02:00
Jonas Bark
655c01ad85 downgrade path_provider_foundation to potentially fix crash issue
https://www.facebook.com/groups/1892836898778912/posts/1977263700336231/?comment_id=1981595913236343&notif_id=1774027006680009&notif_t=group_comment
2026-03-20 18:24:39 +01:00
Jonas Bark
ada54e05eb create screenshot on Windows + macOS 2026-02-25 20:57:12 +01:00
Jonas Bark
d3f64d3f1d Windows: run any command 2026-02-23 09:07:45 +01:00
Jonas Bark
5b94740220 macOS login 2026-02-16 17:17:52 +01:00
Jonas Bark
e1a7aac3e4 sign in with google, apple 2026-02-16 16:26:22 +01:00
Jonas Bark
90d4e27543 openbikecontrol via dircon 2026-02-08 11:28:48 +01:00
Jonas Bark
bd8c51d6ee iOS: keep app alive in background 2026-02-06 12:51:47 +01:00
Jonas Bark
313c8d6f13 Windows & macOS: allow configuration of volume keys on Bluetooth HID devices 2026-01-22 14:29:57 +01:00
Jonas Bark
7fac3390b1 update dependencies 2026-01-19 11:01:42 +01:00
Jonas Bark
81cd068d45 implement logic 2025-12-26 19:36:20 +01:00
Jonas Bark
f389993ea0 implement logic 2025-12-26 18:48:57 +01:00
Jonas Bark
60a61fd38d fix missing entitlements on release builds for macOS 2025-12-20 20:40:12 +01:00
Jonas Bark
0d40f03f5a check sandbox on iOS / macOS 2025-12-17 15:48:30 +01:00
Jonas Bark
03cd25c729 fix build 2025-12-17 13:05:05 +01:00
Jonas Bark
16c201a4ae fix build 2025-12-17 12:57:32 +01:00
Jonas Bark
2c0fc78a22 remove Podfile.loc 2025-12-17 12:40:29 +01:00
Jonas Bark
b69d41ecb5 in app purchase implementation on macOS / iOS 2025-12-14 19:32:23 +01:00
Jonas Bark
0ce74099fb Merge branch 'main' into copilot/implement-in-app-purchase
# Conflicts:
#	lib/bluetooth/devices/base_device.dart
#	lib/pages/configuration.dart
#	lib/utils/settings/settings.dart
2025-12-14 16:42:50 +01:00
Jonas Bark
cbe995ec52 cleanup, refactoring 2025-12-05 13:22:52 +01:00
Jonas Bark
5cbf864604 work on mDNS 2025-12-05 11:14:16 +01:00
Jonas Bark
5bf9c4df63 work on mDNS 2025-12-05 10:51:40 +01:00
Jonas Bark
6b5ad1d9ce wording 2025-12-01 13:40:00 +00:00