Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fix race condition for missing alerts after boot up.
Browse files Browse the repository at this point in the history
After boot up, it was possible to miss scheduling alerts due to improper synchronization of the BOOT_COMPLETED and TIME_CHANGED actions.

Bug:7221716
Change-Id: Id97266a19bb1ff8182576f687c34e10ef8644dc6
  • Loading branch information
Sara Ting committed Oct 16, 2012
1 parent 65dd538 commit 49b7d3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/com/android/providers/calendar/CalendarAlarmManager.java
Expand Up @@ -137,7 +137,13 @@ protected void initializeWithContext(Context context) {
}

void scheduleNextAlarm(boolean removeAlarms) {
if (!mNextAlarmCheckScheduled.getAndSet(true)) {
// We must always run the following when 'removeAlarms' is true. Previously it
// was possible to have a race condition on startup between TIME_CHANGED and
// BOOT_COMPLETED broadcast actions. This resulted in alarms being
// missed (Bug 7221716) when the TIME_CHANGED broadcast ('removeAlarms' = false)
// happened right before the BOOT_COMPLETED ('removeAlarms' = true), and the
// BOOT_COMPLETED action was skipped since there was concurrent scheduling in progress.
if (!mNextAlarmCheckScheduled.getAndSet(true) || removeAlarms) {
if (Log.isLoggable(CalendarProvider2.TAG, Log.DEBUG)) {
Log.d(CalendarProvider2.TAG, "Scheduling check of next Alarm");
}
Expand Down

0 comments on commit 49b7d3c

Please sign in to comment.