OSDN Git Service

Zen: Fix downtime calculation for Sunday mornings.
authorJohn Spurlock <jspurlock@google.com>
Mon, 29 Sep 2014 19:39:04 +0000 (15:39 -0400)
committerJohn Spurlock <jspurlock@google.com>
Mon, 29 Sep 2014 19:39:04 +0000 (15:39 -0400)
Previous calculation would always exit downtime on Sunday mornings,
due to the target day ending up at zero (an invalid day).

Bug:17682999
Change-Id: Icc5f01a42c3c644170eea9e60442cf77ce15a06c

services/core/java/com/android/server/notification/DowntimeConditionProvider.java

index b71bad8..efe47c3 100644 (file)
@@ -193,7 +193,8 @@ public class DowntimeConditionProvider extends ConditionProviderService {
     }
 
     private boolean isInDowntime(int daysOffset, long time, long start, long end) {
-        final int day = ((getDayOfWeek(time) + daysOffset - 1) % Calendar.SATURDAY) + 1;
+        final int n = Calendar.SATURDAY;
+        final int day = ((getDayOfWeek(time) - 1) + (daysOffset % n) + n) % n + 1;
         start = addDays(start, daysOffset);
         end = addDays(end, daysOffset);
         return mDays.contains(day) && time >= start && time < end;