fix: reschedule when exact alarms are allowed again

Granting "Alarms & reminders" again left the next alarm on the inexact
fallback until something else re-registered it. The system's permission
broadcast now reschedules alarms and timers.
This commit is contained in:
makiolaj committed 2026-10-21 17:31:26 +02:00
1 parent d7d958971f
commit 7ca8d54b4a
2 files changed
+15 -1

No files matched your search

+1
View File
@@ -269,6 +269,7 @@
<action android:name="android.intent.action.TIME_SET" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
@@ -17,7 +17,9 @@ import javax.inject.Inject
/**
* Everything that invalidates a registration: a reboot clears AlarmManager, an
* app update clears it too, and a clock or zone change moves what "07:00" means.
* All four are answered the same way — re-resolve from now.
* All four are answered the same way — re-resolve from now. So is the user
* granting "Alarms & reminders" again, which turns an inexact registration
* back into an exact one.
*
* Both engines are told, in that order. For the timers a clock change
* reschedules nothing (their slot is elapsed-realtime anchored); it re-anchors
@@ -65,6 +67,11 @@ class SystemEventReceiver : HiltBroadcastReceiver() {
stopwatchEngine.resync()
}
ACTION_EXACT_ALARM_PERMISSION_CHANGED -> {
engine.reschedule()
timerEngine.resync()
}
Intent.ACTION_TIME_CHANGED,
Intent.ACTION_TIMEZONE_CHANGED,
-> {
@@ -93,4 +100,10 @@ class SystemEventReceiver : HiltBroadcastReceiver() {
}
}
}
private companion object {
/** `AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED`, API 31+. */
const val ACTION_EXACT_ALARM_PERMISSION_CHANGED =
"android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED"
}
}