fix(android): always reschedule alarm on boot by skipping PendingIntent idempotence
Boot recovery was skipping reschedule when it found an "existing" PendingIntent. AlarmManager alarms are not guaranteed to persist across reboot; on devices that clear them, the skip caused the next notification (initial or rollover) to never fire until the app was opened. Pass skipPendingIntentIdempotence = true for all BOOT_RECOVERY call sites (BootReceiver, ReactivationManager.rescheduleAlarmForBoot) so the alarm is always re-registered after reboot. Setting the same PendingIntent again replaces any existing alarm, so no duplicate alarms.
This commit is contained in:
@@ -88,11 +88,12 @@ class BootReceiver : BroadcastReceiver() {
|
|||||||
priority = "normal"
|
priority = "normal"
|
||||||
)
|
)
|
||||||
NotifyReceiver.scheduleExactNotification(
|
NotifyReceiver.scheduleExactNotification(
|
||||||
context,
|
context,
|
||||||
nextRunTime,
|
nextRunTime,
|
||||||
config,
|
config,
|
||||||
scheduleId = schedule.id,
|
scheduleId = schedule.id,
|
||||||
source = ScheduleSource.BOOT_RECOVERY
|
source = ScheduleSource.BOOT_RECOVERY,
|
||||||
|
skipPendingIntentIdempotence = true
|
||||||
)
|
)
|
||||||
Log.i(TAG, "Rescheduled notification for schedule: ${schedule.id}")
|
Log.i(TAG, "Rescheduled notification for schedule: ${schedule.id}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,11 +308,12 @@ class ReactivationManager(private val context: Context) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
NotifyReceiver.scheduleExactNotification(
|
NotifyReceiver.scheduleExactNotification(
|
||||||
context,
|
context,
|
||||||
nextRunTime,
|
nextRunTime,
|
||||||
config,
|
config,
|
||||||
scheduleId = schedule.id,
|
scheduleId = schedule.id,
|
||||||
source = ScheduleSource.BOOT_RECOVERY
|
source = ScheduleSource.BOOT_RECOVERY,
|
||||||
|
skipPendingIntentIdempotence = true
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update schedule in database (best effort)
|
// Update schedule in database (best effort)
|
||||||
@@ -1080,11 +1081,12 @@ class ReactivationManager(private val context: Context) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
NotifyReceiver.scheduleExactNotification(
|
NotifyReceiver.scheduleExactNotification(
|
||||||
context,
|
context,
|
||||||
nextRunTime,
|
nextRunTime,
|
||||||
config,
|
config,
|
||||||
scheduleId = schedule.id,
|
scheduleId = schedule.id,
|
||||||
source = ScheduleSource.BOOT_RECOVERY
|
source = ScheduleSource.BOOT_RECOVERY,
|
||||||
|
skipPendingIntentIdempotence = true
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update schedule in database (best effort)
|
// Update schedule in database (best effort)
|
||||||
|
|||||||
Reference in New Issue
Block a user