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

Commit 87c0d2de authored by Paul Sliwowski's avatar Paul Sliwowski
Browse files

Fix scheduling bug when changing between months.

Bug: 10817487,10967071,10967052
Change-Id: Ia97dc769d8345748d76ae0963faf4f4888450936
parent ac7857ff
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -150,7 +150,14 @@ public final class AlarmStateManager extends BroadcastReceiver {
                Alarm.updateAlarm(cr, alarm);
            }
        } else {
            AlarmInstance nextRepeatedInstance = alarm.createInstanceAfter(instance.getAlarmTime());
            // This is a optimization for really old alarm instances. This prevent us
            // from scheduling and dismissing alarms up to current time.
            Calendar currentTime = Calendar.getInstance();
            Calendar alarmTime = instance.getAlarmTime();
            if (currentTime.after(alarmTime)) {
                alarmTime = currentTime;
            }
            AlarmInstance nextRepeatedInstance = alarm.createInstanceAfter(alarmTime);
            Log.i("Creating new instance for repeating alarm " + alarm.id + " at "  +
                    AlarmUtils.getFormattedTime(context, nextRepeatedInstance.getAlarmTime()));
            AlarmInstance.addInstance(cr, nextRepeatedInstance);
+1 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
    public Calendar getAlarmTime() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, mYear);
        calendar.set(Calendar.MONTH, mMonth);
        calendar.set(Calendar.DAY_OF_MONTH, mDay);
        calendar.set(Calendar.HOUR_OF_DAY, mHour);
        calendar.set(Calendar.MINUTE, mMinute);