fix(devices): cache platform device names, dedupe placeholder ids, purge collided EQ entries
Dart half of bt-device-identity. EstadoEcualizador now caches each device's platform-reported name in memory so the settings screen shows the device's own Bluetooth name instead of its raw id when no custom rename exists, and skips auto-creating preset entries for the composite-placeholder sentinel. Enabling multi-device EQ triggers the Bluetooth permission request through the new channel contract. A flag-guarded one-time migration purges only entries keyed by the exact literal placeholder id from the three per-device preference maps, since those collided entries cannot be attributed to a device. Work unit 2/2 of bt-device-identity (Dart state + migration).
This commit is contained in:
@@ -438,6 +438,9 @@ class FakeServicioDispositivoAudioThrows extends ServicioDispositivoAudio {
|
||||
throw Exception('Platform channel error: device unavailable');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> solicitarPermisoBluetooth() async => true;
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
await _controller.close();
|
||||
@@ -449,6 +452,16 @@ class FakeServicioDispositivoAudioThrows extends ServicioDispositivoAudio {
|
||||
/// Use [emitirDispositivo] to push device change events without needing
|
||||
/// a real platform channel.
|
||||
class FakeServicioDispositivoAudio extends ServicioDispositivoAudio {
|
||||
FakeServicioDispositivoAudio({this.permisoBluetoothConcedido = true});
|
||||
|
||||
/// Value returned by [solicitarPermisoBluetooth] (bt-device-identity
|
||||
/// Phase 2/4 testing strategy — defaults to granted so existing tests
|
||||
/// that don't care about the permission flow are unaffected).
|
||||
final bool permisoBluetoothConcedido;
|
||||
|
||||
/// Number of times [solicitarPermisoBluetooth] was called.
|
||||
int solicitarPermisoBluetoothCalls = 0;
|
||||
|
||||
final _controller = StreamController<DispositivoAudio>.broadcast();
|
||||
DispositivoAudio? _dispositivoActual;
|
||||
|
||||
@@ -468,6 +481,12 @@ class FakeServicioDispositivoAudio extends ServicioDispositivoAudio {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> solicitarPermisoBluetooth() async {
|
||||
solicitarPermisoBluetoothCalls++;
|
||||
return permisoBluetoothConcedido;
|
||||
}
|
||||
|
||||
/// Helper for tests: push a device change event.
|
||||
void emitirDispositivo(DispositivoAudio dispositivo) {
|
||||
_dispositivoActual = dispositivo;
|
||||
|
||||
Reference in New Issue
Block a user