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

Commit 7ee64677 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Override old alarms in zen schedule

Change-Id: I371a586d470e3e341a42fb5ae3b8f32929214c18
Merged-in: I371a586d470e3e341a42fb5ae3b8f32929214c18
Fixes: 112493468
Test: ScheduleCalendarTest
(cherry picked from commit 4e76191a)
parent 06cfb175
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -70,10 +70,10 @@ public class ScheduleCalendar {
            }
            // only allow alarms in the future
            if (nextAlarm > now) {
                // store earliest alarm
                if (mSchedule.nextAlarm == 0) {
                if (mSchedule.nextAlarm == 0 || mSchedule.nextAlarm < now) {
                    mSchedule.nextAlarm = nextAlarm;
                } else {
                    // store earliest alarm
                    mSchedule.nextAlarm = Math.min(mSchedule.nextAlarm, nextAlarm);
                }
            } else if (mSchedule.nextAlarm < now) {
+11 −0
Original line number Diff line number Diff line
@@ -332,6 +332,17 @@ public class ScheduleCalendarTest extends UiServiceTestCase {
        assertEquals(0, mScheduleInfo.nextAlarm);
    }

    @Test
    public void testMaybeSetNextAlarm_expiredOldAlarm() {
        mScheduleInfo.exitAtAlarm = true;
        mScheduleInfo.nextAlarm = 998;
        mScheduleCalendar.setSchedule(mScheduleInfo);

        mScheduleCalendar.maybeSetNextAlarm(1000, 1001);

        assertEquals(1001, mScheduleInfo.nextAlarm);
    }

    @Test
    @FlakyTest
    public void testIsInSchedule_inScheduleOvernight() {