summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Ting <sarating@google.com>2012-10-12 13:52:55 -0700
committerSara Ting <sarating@google.com>2012-10-16 10:16:10 -0700
commit49b7d3c4222a6b9e8e4639ba6d5128df5eac7e73 (patch)
tree2e0d13bf45d6603dbc779604d1c6e996a0282e8e
parent65dd538630d0961b7d732a27da02817186eb7d26 (diff)
downloadCalendarProvider-jb-mr1-dev.tar.gz
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.java8
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");
}