fix(alarm): fail-safe alarm system overhaul (SDD alarm-system-overhaul, slice A)
Root-cause fix for the unstoppable-alarm incident (alarm rang 15 minutes, only uninstall silenced it) plus systematic hardening of every stop path. Native (Kotlin): - Verified stop: stopActiveAlarm now derives its result from the real post-teardown state (companion instance + synchronous stopEverything + activeRingingId check) instead of reporting unconditional success. - Atomic teardown: every stop path (stop action, notification button, snooze, missed, onDestroy, startForeground failure) funnels through one stopEverything() covering audio, wakelock, notification, foreground state and firing-record cleanup; player.release() guarded. - Bounded ringing: 10-minute auto-silence armed via AlarmManager fires a FIRED->MISSED transition with a localized missed-alarm notification; repeating alarms keep their native rearm, deleted alarms never produce ghost MISSED notifications. - Durable firing record with onStartCommand re-validation (resurrection guard) and boot-time stale cleanup; firing records cleared on every refuse/mismatch/cancel path. - New notification-only dismissal channel (dismissAlarmNotificationOnly) so UI-level dedup can never kill a live ring's audio. Flutter (Dart): - Stop/disable/edit/delete of a ringing alarm always attempt to silence it; on native-query failure the stop falls back toward silence via the id-scoped legacy stop. - Verified-stop results surface failures: the ringing screen keeps dismiss-by-design on success, but on a verified failure it stays up with a persistent force-stop banner (guarded against double-dismiss) and auto-dismisses if the ring ends externally (missed/notification). - Missed events sync alarm bookkeeping without opening the ringing UI. - 4 new l10n keys translated across all 13 locales (ARB guard green). 550 tests green, analyzer clean. Reviewed in 3 adversarial 4-lens rounds (2 deterministic + 1 refuter-corroborated critical fixed); formal gentle-ai receipt waived by maintainer authorization (correction scope legitimately exceeded the frozen genesis paths). On-device QA checklist in openspec/changes/alarm-system-overhaul/tasks.md pending before archive.
This commit is contained in:
+13
-8
@@ -281,6 +281,12 @@ class _PaginaPrincipalState extends State<_PaginaPrincipal>
|
||||
// nothing to open for this event.
|
||||
return;
|
||||
}
|
||||
if (evento.accion == EventoAlarmaAndroid.accionMissed) {
|
||||
// EstadoAlarmas' own native-event listener already recorded this
|
||||
// transition (RES-1); the ring already ended, so opening the ringing
|
||||
// screen here would only show a stale, already-silent alarm.
|
||||
return;
|
||||
}
|
||||
final estado = context.read<EstadoAlarmas>();
|
||||
if (estado.alarmas.isEmpty) {
|
||||
await estado.cargarPersistidasSinRecalcular();
|
||||
@@ -361,15 +367,14 @@ class _PaginaPrincipalState extends State<_PaginaPrincipal>
|
||||
);
|
||||
// A duplicate delivery of the SAME ring's own fire event (the live
|
||||
// eventosAlarma stream and the one-shot obtenerEventoInicial() read
|
||||
// the same native event and can both reach here) must be a no-op:
|
||||
// ocultarNotificacionAlarma -> dismissAlarmNotification unconditionally
|
||||
// stops PluriWaveAlarmService for that id on the native side, which
|
||||
// would tear down the currently-ringing service and undo the
|
||||
// ring-scoped media-volume override long before the real handoff.
|
||||
// Only hide the notification when a genuinely DIFFERENT alarm fired
|
||||
// while this one is active (single-ring-at-a-time by design).
|
||||
// the same native event and can both reach here) must be a no-op.
|
||||
// When a genuinely DIFFERENT alarm fired while this one is active
|
||||
// (single-ring-at-a-time by design), hide ONLY its notification
|
||||
// (RES-1): ocultarNotificacionAlarma -> dismissAlarmNotification
|
||||
// unconditionally stops PluriWaveAlarmService, which would silently
|
||||
// kill the OTHER alarm's ring if it is the one genuinely sounding.
|
||||
if (alarma.id != _alarmaSonandoId) {
|
||||
await alarmas.android.ocultarNotificacionAlarma(alarma.id);
|
||||
await alarmas.android.ocultarSoloNotificacion(alarma.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user