Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix race condition for missing alerts after boot up.

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...
commit 49b7d3c4222a6b9e8e4639ba6d5128df5eac7e73 1 parent 65dd538
Sara Ting authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/com/android/providers/calendar/CalendarAlarmManager.java
View
8 src/com/android/providers/calendar/CalendarAlarmManager.java
@@ -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");
}
Please sign in to comment.
Something went wrong with that request. Please try again.