prop_public: stub the API 7.7 uses, restore ble_connection_options

A clone without the private prop builds against prop_public, and 7.7 no
longer compiled there: the stub lacked SuspensionWatch, RecoverableAdvertiser,
the keep-alive status, the TCP connection log and rebind, the Click unlock
relay, the Bluetooth bridge name, the peripheral permission exception and the
Shimano shifter sides, and ble_connection_options.dart had been deleted.
lib now analyzes without errors against the stub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonas Acker
2026-11-24 17:11:50 +01:00
parent fc078b0560
commit e332c65ef8
9 changed files with 135 additions and 3 deletions

View File

@@ -70,6 +70,7 @@ class ShimanoConfig {
void Function(ShimanoWiredSwitchEvent event)? onWiredSwitch,
void Function(Uint8List frame)? onUnknownFrame,
required void Function(String step, Object error, StackTrace stack) onStepError,
ShimanoShifterSides? sides,
}) =>
throw UnsupportedError('Shimano Di2 button mode is not available in this build');
@@ -91,7 +92,7 @@ class ShimanoConfig {
/// Decodes the paddle presses a Di2 relays. The stub never finds any.
class ShimanoButtons {
static List<ShimanoPaddleEvent> decode(Uint8List frame) => const [];
static List<ShimanoPaddleEvent> decode(Uint8List frame, {ShimanoShifterSides? sides}) => const [];
}
/// A press of a wired switch, reported by the Di2.
@@ -139,6 +140,18 @@ enum ShimanoSwitchFunction {
}
}
/// Which shifter is on which pairing slot. The stub learns nothing: slot 0 is
/// the left.
class ShimanoShifterSides {
ShimanoShifter of(int slot) => slot == 0 ? ShimanoShifter.left : ShimanoShifter.right;
void learn(ShimanoShifterSwitches switches) {}
void learnAll(Iterable<ShimanoShifterSwitches> switches) {}
void learnFrame(Uint8List frame) {}
}
/// The four switches of one wireless shifter, by its pairing [slot].
class ShimanoShifterSwitches {
const ShimanoShifterSwitches({
@@ -164,7 +177,7 @@ class ShimanoShifterSwitches {
bool get paddlesOnDfly => (a, b) == dflyPaddles;
ShimanoShifterSwitches withDflyPaddles() {
ShimanoShifterSwitches withDflyPaddles({ShimanoShifter? side}) {
final (pa, pb) = dflyPaddles;
return ShimanoShifterSwitches(slot: slot, a: pa, b: pb, c: c, s: s);
}

View File

@@ -1,11 +1,20 @@
//INFO: This is a stub - contact me if you need the full implementation.
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show Uint8List;
class ClickEmulator {
final ValueNotifier<bool> isStarted = ValueNotifier(false);
final ValueNotifier<bool> isConnected = ValueNotifier(false);
/// Called with the controller's answer to a relayed unlock challenge.
void Function(Uint8List authResponse)? onAuthResponse;
/// Relays an unlock challenge to the connected app. No-op in the stub.
void sendChallenge(List<int> challenge) {}
void clearChallenge() {}
Future<void> startServer(bool hello, {String? name}) async {
isStarted.value = true;
}

View File

@@ -87,7 +87,13 @@ class DirconEmulator {
/// trainer-app / trial / device-name callbacks.
String get advertisementName => 'BikeControl';
bool processCharacteristic(String characteristic, Uint8List bytes) => false;
/// The name the Bluetooth bridge advertises under, once it advertises.
ValueListenable<String?> get bluetoothLocalName => _bluetoothLocalName;
final ValueNotifier<String?> _bluetoothLocalName = ValueNotifier(null);
/// [from] is the definition the frame came from, when several trainers
/// share the bridge.
bool processCharacteristic(String characteristic, Uint8List bytes, {FitnessBikeDefinition? from}) => false;
Future<void> startServer({
required RetrofitMode mode,

View File

@@ -28,3 +28,12 @@ class BluetoothTransporter extends Transporter {
@override
void dispose() {}
}
/// The platform refuses the BLE peripheral role (on Android: no
/// BLUETOOTH_ADVERTISE permission).
class BluetoothPeripheralUnauthorizedException implements Exception {
const BluetoothPeripheralUnauthorizedException();
@override
String toString() => 'Bluetooth advertise permission not granted';
}

View File

@@ -62,6 +62,21 @@ abstract class ServiceAdvertiser {
static final ValueListenable<String?> untrackedAddress = ValueNotifier<String?>(null);
}
/// An advertiser that can check its advertisement and publish it again.
abstract interface class RecoverableAdvertiser {
Future<void> recover({bool force = false});
String? get recoveryStatus;
/// [recover] on [ServiceAdvertiser.instance] when it supports it.
static Future<void> recoverInstance({bool force = false}) async {
final advertiser = ServiceAdvertiser.instance;
if (advertiser is RecoverableAdvertiser) {
await (advertiser as RecoverableAdvertiser).recover(force: force);
}
}
}
/// Hostname-label rules shared by the backends that publish their own host
/// record. Stubbed here.
abstract final class MdnsHostLabel {

View File

@@ -0,0 +1,17 @@
import 'package:universal_ble/universal_ble.dart';
/// Platform options for every BLE central connect BikeControl makes.
///
/// iOS/macOS: ask CoreBluetooth to wake a suspended app for connection,
/// disconnection and notification events, so controllers and trainers keep
/// working while BikeControl is in the background behind the trainer app.
/// Ignored on the other platforms.
///
/// A fresh instance per call: the pigeon config classes are mutable.
ConnectionPlatformConfig bleConnectionPlatformConfig() => ConnectionPlatformConfig(
apple: AppleConnectionOptions(
notifyOnConnection: true,
notifyOnDisconnection: true,
notifyOnNotification: true,
),
);

View File

@@ -6,6 +6,20 @@
import 'dart:io';
/// One client connection, for the support diagnostics. The stub records none.
class TcpConnectionLogEntry {
TcpConnectionLogEntry({required this.at, required this.server, required this.port, required this.remote});
final DateTime at;
final String server;
final int port;
final String remote;
DateTime? closedAt;
int bytesReceived = 0;
String? note;
}
class ResilientTcpServer {
ResilientTcpServer({
required this.preferredPort,
@@ -36,6 +50,12 @@ class ResilientTcpServer {
/// Every currently-running server, for the diagnostics block.
static final List<ResilientTcpServer> activeServers = [];
/// Recent client connections. Always empty in the stub.
static List<TcpConnectionLogEntry> get connectionLog => const [];
/// Binds every running server's listeners again. No-op in the stub.
static Future<void> rebindAllListeners() async {}
final void Function(Socket socket) onClientConnected;
final void Function(Socket socket, List<int> data) onData;
final void Function() onClientDisconnected;

View File

@@ -13,6 +13,10 @@ class SharedLogic {
static void keepAlive() {}
static void stopKeepAlive() {}
static void refreshKeepAlive() {}
static String get keepAliveStatus => 'not available in this build';
}
class Logger {

View File

@@ -0,0 +1,39 @@
//INFO: This is a stub - contact me if you need the full implementation.
//
// The full implementation notices when the process stood still (suspended,
// machine asleep) and tells its listeners how long. The stub never sees one.
import 'dart:async';
class SuspensionWatch {
SuspensionWatch({
this.tick = const Duration(seconds: 5),
this.threshold = const Duration(seconds: 20),
DateTime Function() now = DateTime.now,
});
static final SuspensionWatch instance = SuspensionWatch();
final Duration tick;
final Duration threshold;
DateTime? lastGapEndedAt;
Duration? lastGap;
int gapCount = 0;
bool get isRunning => false;
void addListener(FutureOr<void> Function(Duration gap) listener) {}
void removeListener(FutureOr<void> Function(Duration gap) listener) {}
void start() {}
void stop() {}
void check() {}
String get status => 'not running';
void reset() {}
}