Don't nag for future doses: time-guard escalation resume
'Ta nå' + 'Angre' on a not-yet-due dose leaves a PENDING log with a future scheduledAt; armAll() (every app start/update) then resumed 'escalation' for it as if it were overdue — nagging hours early. Three layers: armAll only resumes escalation for past-due logs, the escalation receiver drops anything scheduled in the future (defense in depth), and undo resets nagCount + cancels any escalation so stale counts can't eat the real quota when the dose actually falls due. Emulator-verified with both cases side by side: past-due PENDING nags within the minute, future PENDING stays silent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
aca0839e0f
commit
8c3cd0c965
3 changed files with 15 additions and 2 deletions
|
|
@ -94,6 +94,9 @@ class DoseAlarmReceiver : BroadcastReceiver() {
|
|||
// Only unresolved doses nag. TAKEN/SKIPPED here means the cancel raced us.
|
||||
if (log.status != DoseStatus.PENDING && log.status != DoseStatus.SNOOZED) return
|
||||
if (log.nagCount >= AlarmScheduler.NAG_CAP) return
|
||||
// A future dose can't be overdue — drop stray escalations (defense in
|
||||
// depth against any path that arms one too early).
|
||||
if (log.scheduledAtMillis > System.currentTimeMillis()) return
|
||||
|
||||
val med = db.medicationDao().getById(log.medId) ?: return
|
||||
val nagged = log.copy(nagCount = log.nagCount + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue