Don't exit dnd rule for old alarms
Bug: 77209521 Test: atest ScheduleCalendarTest Change-Id: I394a6a74872f76f90b75238593197bb6c50531ef
This commit is contained in:
@@ -144,7 +144,8 @@ public class ScheduleCalendar {
|
||||
}
|
||||
return mSchedule.exitAtAlarm
|
||||
&& mSchedule.nextAlarm != 0
|
||||
&& time >= mSchedule.nextAlarm;
|
||||
&& time >= mSchedule.nextAlarm
|
||||
&& isInSchedule(mSchedule.nextAlarm);
|
||||
}
|
||||
|
||||
private boolean isInSchedule(int daysOffset, long time, long start, long end) {
|
||||
|
||||
@@ -205,6 +205,31 @@ public class ScheduleCalendarTest extends UiServiceTestCase {
|
||||
assertTrue(mScheduleCalendar.shouldExitForAlarm(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldExitForAlarm_oldAlarm() {
|
||||
// Cal: today 2:15pm
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 14);
|
||||
cal.set(Calendar.MINUTE, 15);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
// ScheduleInfo: today 12:16pm - today 3:15pm
|
||||
mScheduleInfo.days = new int[] {getTodayDay()};
|
||||
mScheduleInfo.startHour = 12;
|
||||
mScheduleInfo.endHour = 3;
|
||||
mScheduleInfo.startMinute = 16;
|
||||
mScheduleInfo.endMinute = 15;
|
||||
mScheduleInfo.exitAtAlarm = true;
|
||||
mScheduleInfo.nextAlarm = 1000; // very old alarm
|
||||
|
||||
mScheduleCalendar.setSchedule(mScheduleInfo);
|
||||
assertTrue(mScheduleCalendar.isInSchedule(cal.getTimeInMillis()));
|
||||
|
||||
// don't exit for an alarm if it's an old alarm
|
||||
assertFalse(mScheduleCalendar.shouldExitForAlarm(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaybeSetNextAlarm_settingOff() {
|
||||
mScheduleInfo.exitAtAlarm = false;
|
||||
|
||||
Reference in New Issue
Block a user