summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-12-14 08:38:45 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-12-14 08:38:45 +0000
commite8cbaa73a052d07d0c997dab6a0a9e1175063dc7 (patch)
tree97dd796875e202aa9134a4f757207941bfb8f1f1
parentb4d8bd3f1e753627b4017faf0d7055463463e1e1 (diff)
parent6e0b7f5b455c4ccee9e06db71c785c0bec5fe68c (diff)
downloadandroid_packages_providers_CalendarProvider-e8cbaa73a052d07d0c997dab6a0a9e1175063dc7.tar.gz
android_packages_providers_CalendarProvider-e8cbaa73a052d07d0c997dab6a0a9e1175063dc7.tar.bz2
android_packages_providers_CalendarProvider-e8cbaa73a052d07d0c997dab6a0a9e1175063dc7.zip
Snap for 4502278 from 6e0b7f5b455c4ccee9e06db71c785c0bec5fe68c to pi-release
Change-Id: I7d11381acd2d02a7a94db64bad035caaba807274
-rw-r--r--OWNERS4
-rw-r--r--src/com/android/providers/calendar/CalendarAlarmManager.java35
2 files changed, 21 insertions, 18 deletions
diff --git a/OWNERS b/OWNERS
index 5643d33..3ca2b75 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1 +1,3 @@
-rickywai@google.com
+omakoto@google.com
+yamasani@google.com
+fkupolov@google.com
diff --git a/src/com/android/providers/calendar/CalendarAlarmManager.java b/src/com/android/providers/calendar/CalendarAlarmManager.java
index c77b654..8586e6b 100644
--- a/src/com/android/providers/calendar/CalendarAlarmManager.java
+++ b/src/com/android/providers/calendar/CalendarAlarmManager.java
@@ -63,16 +63,6 @@ public class CalendarAlarmManager {
/* package */static final Uri SCHEDULE_ALARM_URI = Uri.withAppendedPath(
CalendarContract.CONTENT_URI, SCHEDULE_ALARM_PATH);
- /**
- * If no alarms are scheduled in the next 24h, check for future alarms again after this period
- * has passed. Scheduling the check 15 minutes earlier than 24h to prevent the scheduler alarm
- * from using up the alarms quota for reminders during dozing.
- *
- * @see AlarmManager#setExactAndAllowWhileIdle
- */
- private static final long ALARM_CHECK_WHEN_NO_ALARM_IS_SCHEDULED_INTERVAL_MILLIS =
- DateUtils.DAY_IN_MILLIS - (15 * DateUtils.MINUTE_IN_MILLIS);
-
static final String INVALID_CALENDARALERTS_SELECTOR =
"_id IN (SELECT ca." + CalendarAlerts._ID + " FROM "
+ Tables.CALENDAR_ALERTS + " AS ca"
@@ -278,7 +268,10 @@ public class CalendarAlarmManager {
final long currentMillis = System.currentTimeMillis();
final long start = currentMillis - SCHEDULE_ALARM_SLACK;
- final long end = start + (24 * 60 * 60 * 1000);
+ final long end = currentMillis + DateUtils.DAY_IN_MILLIS;
+
+ boolean alarmScheduled = false;
+
if (Log.isLoggable(CalendarProvider2.TAG, Log.DEBUG)) {
time.set(start);
String startTimeStr = time.format(" %a, %b %d, %Y %I:%M%P");
@@ -459,6 +452,7 @@ public class CalendarAlarmManager {
}
scheduleAlarm(alarmTime);
+ alarmScheduled = true;
}
} finally {
if (cursor != null) {
@@ -469,14 +463,17 @@ public class CalendarAlarmManager {
// Refresh notification bar
if (rowsDeleted > 0) {
scheduleAlarm(currentMillis);
+ alarmScheduled = true;
}
- // No event alarm is scheduled, check again in 24 hours. If a new
- // event is inserted before the next alarm check, then this method
- // will be run again when the new event is inserted.
- if (nextAlarmTime == Long.MAX_VALUE) {
- scheduleNextAlarmCheck(
- currentMillis + ALARM_CHECK_WHEN_NO_ALARM_IS_SCHEDULED_INTERVAL_MILLIS);
+ // No event alarm is scheduled, check again in 24 hours - 15
+ // minutes. Scheduling the check 15 minutes earlier than 24
+ // hours to prevent the scheduler alarm from using up the
+ // alarms quota for reminders during dozing. If a new event is
+ // inserted before the next alarm check, then this method will
+ // be run again when the new event is inserted.
+ if (!alarmScheduled) {
+ scheduleNextAlarmCheck(end - (15 * DateUtils.MINUTE_IN_MILLIS));
}
}
@@ -516,6 +513,10 @@ public class CalendarAlarmManager {
mAlarmManager.cancel(operation);
}
+ /**
+ * Only run inside scheduleNextAlarmLocked, please!
+ * mAlarmScheduled is specific to that method, currently.
+ */
public void scheduleAlarm(long alarmTime) {
// Debug log for investigating dozing related bugs, remove it once we confirm it is stable.
if (Build.IS_DEBUGGABLE) {