feat(alarm): make the ring immune to device media volume
Build & Deploy PluriWave / Análisis de código (push) Successful in 41s
Build & Deploy PluriWave / Build APK + AAB release (push) Successful in 2m39s

The alarm's steady-state audio runs on the Flutter media-stream
player after the native handoff, so device volume 0 silenced it
entirely. The ring now forces STREAM_MUSIC to an audible reference:
Dart requests the override before pre-starting alarm audio (fallback
WAV included), Kotlin captures the current volume once and restores
it idempotently on every exit path (dismiss, snooze, dispose), with
a native best-effort backstop in service teardown.

The backstop is handoff-aware via PluriWaveAlarmService.flutterOwnsRing:
confirmFlutterAudio marks the handoff before triggering the native
stop, so the backstop cannot restore the volume mid-ring right as the
Flutter player takes over (that would re-silence the alarm at volume
0). The flag resets at every ring start; Flutter process death after
handoff remains a documented best-effort gap.

The alarm's perceived loudness keeps ramping 5% to the configured
volume through the player as before; normal radio playback and call
ducking never touch the override.

Work unit 2/3 of alarm-volume-ramp-restore (ring volume override).
This commit is contained in:
2026-07-11 09:15:37 +02:00
parent 251d3fd3cd
commit acd903d9a8
9 changed files with 440 additions and 21 deletions
@@ -106,4 +106,32 @@ void main() {
);
},
);
test(
'forzarVolumenMediaParaAlarma invoca overrideMediaVolumeForRing con fraction',
() async {
final servicio = ServicioAlarmasAndroid(channel: channel);
await servicio.forzarVolumenMediaParaAlarma(1.0);
final llamada = llamadas.singleWhere(
(c) => c.method == 'overrideMediaVolumeForRing',
);
expect(llamada.arguments, {'fraction': 1.0});
},
);
test(
'restaurarVolumenMedia invoca restoreMediaVolume sin argumentos',
() async {
final servicio = ServicioAlarmasAndroid(channel: channel);
await servicio.restaurarVolumenMedia();
final llamada = llamadas.singleWhere(
(c) => c.method == 'restoreMediaVolume',
);
expect(llamada.arguments, <String, Object?>{});
},
);
}