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

Commit 51608a53 authored by Paul Westbrook's avatar Paul Westbrook
Browse files

Use ELAPSE_REALTIME alarm for tick event

Change to use a real item alarm for scheduling ACTION_TIME_TICK
intents for the case where time goes backwards after the tick intent
is schedule, and where the time change is not noticed from the call
to waitForAlarm().

Bug: 5166877
Change-Id: I46b9a1c80146d27becedc341c4af977fcdf47352
parent 123adee3
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -764,12 +764,18 @@ class AlarmManagerService extends IAlarmManager.Stub {
        
        public void scheduleTimeTickEvent() {
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            final long currentTime = System.currentTimeMillis();
            calendar.setTimeInMillis(currentTime);
            calendar.add(Calendar.MINUTE, 1);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);

            set(AlarmManager.RTC, calendar.getTimeInMillis(), mTimeTickSender);
            // Schedule this event for the amount of time that it would take to get to
            // the top of the next minute.
            final long tickEventDelay = calendar.getTimeInMillis() - currentTime;

            set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay,
                    mTimeTickSender);
        }
	
        public void scheduleDateChangedEvent() {