Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77bd7d66 authored by Beverly's avatar Beverly Committed by android-build-merger
Browse files

Merge "Don't exit dnd rule for old alarms" into pi-dev

am: df3788dc

Change-Id: Id98f6a123ff7299f7706759e734978c60ac1229a
parents 2f960c0e df3788dc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+25 −0
Original line number Diff line number Diff line
@@ -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;