parentalcontrols: fix unreachable device-budget lock notice
- Commit
621b09185000e5b643dc18714343dc08a0095384- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-08 02:20 UTC (28 days ago)
- Parents
05b6fca
notifyDeviceBudgetCrossed() guarded on deviceOverBudgetNow(...) being true and then notified only if the identical re-read was also true, so the DailyLimit notice could never fire: the device still locked via reconcile() but the child never learned why. Invert the guard to return when not over budget, notify otherwise, and drop the redundant second table re-read. The notice stays bounded: onWindowBoundary runs only on window-boundary alarms.
Diff
parentalcontrols/src/main/java/com/vayunmathur/parentalcontrols/platform/Enforcer.kt
diff --git a/parentalcontrols/src/main/java/com/vayunmathur/parentalcontrols/platform/Enforcer.kt b/parentalcontrols/src/main/java/com/vayunmathur/parentalcontrols/platform/Enforcer.ktindex 60529cefed..c4656c016b 100644--- a/parentalcontrols/src/main/java/com/vayunmathur/parentalcontrols/platform/Enforcer.kt+++ b/parentalcontrols/src/main/java/com/vayunmathur/parentalcontrols/platform/Enforcer.kt@@ -133,13 +133,12 @@ class Enforcer(private val context: Context) { private suspend fun notifyDeviceBudgetCrossed() { val day = LocalDate.now().toString()- if (deviceOverBudgetNow(rules.bonusesToday(day))) return+ if (!deviceOverBudgetNow(rules.bonusesToday(day))) return // Device-wide budget crossing is detected here rather than by an observer (the- // platform has no device-total primitive): if the last minute pushed the total over,- // the child gets one notice. Per-app trips already notified via onLimitReached.- if (deviceOverBudgetNow(rules.bonusesToday(LocalDate.now().toString()))) {- LockNotifier.notifyLocked(context, BlockReason.DailyLimit, null)- }+ // platform has no device-total primitive). This runs only on window-boundary alarms,+ // so while the budget stays spent the child gets at most one notice per boundary.+ // Per-app trips already notified via onLimitReached.+ LockNotifier.notifyLocked(context, BlockReason.DailyLimit, null) } /**