fix(bedtime): record only accepted states, urgent wake-up, keep bedtime on old restores

A refused state change is now remembered as owed and forced by every pass
until it lands, instead of recording the opposite state, which could hide
the next real boundary. Any refusal, in the rule rewrite or the state
change, pulls the slot in to a retry, and the slot is armed in a finally
so a throwing step can't leave it unarmed. The wake-up that ends the mode
is armed allow-while-idle (one such fire a night), so Do Not Disturb no
longer lingers into the morning behind a doze deferral.

The manifest filter for the access-changed broadcast is gone: the
platform only delivers it to runtime-registered receivers, and the
screen's resume check covers it. A backup written before bedtime existed
now keeps the current bedtime settings, and a restore goes through the
engine's own field comparison, so a reminder-only difference leaves a
hand-switched mode alone.

Refs #1
This commit is contained in:
makiolaj committed 2026-10-22 12:54:02 +02:00
1 parent 74c0c278ef
commit 817fe77b17
17 files changed
+215 -104

No files matched your search

+3 -8
View File
@@ -279,16 +279,11 @@
</intent-filter>
</receiver>
<!-- The bedtime slot arriving, and Do Not Disturb access changing. The
second is a system broadcast addressed to this package, so the
receiver stays unexported (issue #1). -->
<!-- The bedtime slot arriving (issue #1). Unexported, like the alarm's
and the timer's: only the PendingIntent the app made reaches it. -->
<receiver
android:name=".bedtime.receiver.BedtimeReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED" />
</intent-filter>
</receiver>
android:exported="false" />
<!-- Persists the per-app language on API < 33, where the platform
per-app-languages API is unavailable. On 33+ this is a no-op. -->