diff options
author | Sara Ting <sarating@google.com> | 2012-10-12 13:52:55 -0700 |
---|---|---|
committer | Sara Ting <sarating@google.com> | 2012-10-16 10:16:10 -0700 |
commit | 49b7d3c4222a6b9e8e4639ba6d5128df5eac7e73 (patch) | |
tree | 2e0d13bf45d6603dbc779604d1c6e996a0282e8e | |
parent | 65dd538630d0961b7d732a27da02817186eb7d26 (diff) | |
download | CalendarProvider-jb-mr1-dev.tar.gz |
Fix race condition for missing alerts after boot up.android-sdk-support_r11android-cts-4.2_r2android-cts-4.2_r1android-4.2_r1android-4.2.2_r1.2android-4.2.2_r1.1android-4.2.2_r1android-4.2.1_r1.2android-4.2.1_r1.1android-4.2.1_r1tools_r22jb-mr1.1-releasejb-mr1.1-dev-plus-aospjb-mr1.1-devjb-mr1-releasejb-mr1-dev-plus-aospjb-mr1-dev
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
-rw-r--r-- | src/com/android/providers/calendar/CalendarAlarmManager.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/com/android/providers/calendar/CalendarAlarmManager.java b/src/com/android/providers/calendar/CalendarAlarmManager.java index f25d3de..5f8c00c 100644 --- a/src/com/android/providers/calendar/CalendarAlarmManager.java +++ b/src/com/android/providers/calendar/CalendarAlarmManager.java @@ -137,7 +137,13 @@ public class CalendarAlarmManager { } 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"); } |