Persist the exploration, proposal, spec, design, tasks, and verify/archive reports produced during the multi-device EQ, alarm-countdown, and notification-visual-polish SDD cycles.
3.3 KiB
3.3 KiB
Exploration: snooze-reschedule-fix
Root Cause (single defect explains all 3 symptoms)
lib/estado/estado_alarmas.dart — posponerAlarma() (L194-212) and posponerProximaDesdePreaviso() (L214-236) call await android.programar(actualizada) with no try/catch, unlike guardarAlarma() (L98-115) which wraps the identical call in try/catch and still reaches notifyListeners() on failure.
Failure chain
- Native
scheduleMainAlarm()likely fails (most probable: exact-alarm permission revoked on Android 14+/OEM battery manager —posponerAlarmanever re-requests permission before scheduling, unlikeguardarAlarmawhich calls_solicitarPermisosNecesariosParaAlarma()first) AlarmScheduler.scheduleSpec()(Kotlin, L108-118): ifscheduleMainAlarm()returnsfalse, returnsfalseimmediately — before reachingscheduleSnoozeCountdown()at L126. This is why the countdown notification never appears too — same root cause as the no-refire bug.scheduleAlarm()returnsfalse→ServicioAlarmasAndroid.programar()throwsStateError- Exception propagates out of
posponerAlarma()uncaught —notifyListeners()(L211) never reached, even though_aplicar(config)(L206) already mutated_alarmasin memory _posponer()inpantalla_alarma_sonando.dart(L181-187) catches it only todebugPrintand dismiss the screen — no user feedback, no retry- Result: (A) no real fire alarm scheduled; (B)
scheduleSnoozeCountdownnever runs; (C)proximaAlarma/proximaProgramablegetters hold correct data in memory but UI never rebuilds becausenotifyListeners()was skipped
Ruled out (verified)
- PendingIntent requestCode collision — different formulas (31x vs 47x), correctly scoped
- Notification channel mismatch — channel created identically by both classes
- "Missing initial countdown post" —
scheduleSnoozeCountdown()posts notification AND arms first tick in one call - Dart→Kotlin Long encoding,
alarma.activaflag, periodic resync, fire-vs-snooze race — all verified correct
Affected Areas
lib/estado/estado_alarmas.dart—posponerAlarma(),posponerProximaDesdePreaviso(): missing try/catch, missing notifyListeners()-on-failure, missing permission pre-checkandroid/.../AlarmScheduler.kt—scheduleSpec()(81-137): early return false skips scheduleSnoozeCountdown entirely (by design, but compounds the silent Dart-side failure)lib/pantallas/pantalla_alarma_sonando.dart—_posponer(): swallows exception with only debugPrint, no user-facing signal
Recommendation
- Wrap
android.programar()in both snooze methods in try/catch mirroringguardarAlarma()— always reachnotifyListeners() - Add the same permission pre-check (
_solicitarPermisosNecesariosParaAlarma()) before scheduling in both snooze methods - Surface failure to user in
_posponer()(SnackBar) since the screen always dismisses regardless by design - Device-test with exact-alarm permission both granted and revoked
Risks
- Root cause is permission-dependent; cannot be 100% confirmed without
adb logcatfrom the device at failure time. Fix should land regardless since missing try/catch + missing notifyListeners is a confirmed defect independent of which native call failed underneath posponerProximaDesdePreavisoshares the identical defect, must be fixed together