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

Commit 0ae19860 authored by yingying's avatar yingying Committed by Gerrit - the friendly Code Review server
Browse files

AlarmManager: Reschedule the date changed event if time changed.

 - Receive the time changed action, and reschedule the date changed
   event if the time changed.
 - Changed to use HOUR_OF_DAY to set the beginning of one day.

CRs-fixed: 740009

Change-Id: I9ff23951a9997ebe5f9d37313147d0ba2461634a
parent b120e568
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2015,6 +2015,7 @@ class AlarmManagerService extends SystemService {
        public ClockReceiver() {
            IntentFilter filter = new IntentFilter();
            filter.addAction(Intent.ACTION_TIME_TICK);
            filter.addAction(Intent.ACTION_TIME_CHANGED);
            filter.addAction(Intent.ACTION_DATE_CHANGED);
            getContext().registerReceiver(this, filter);
        }
@@ -2026,6 +2027,11 @@ class AlarmManagerService extends SystemService {
                    Slog.v(TAG, "Received TIME_TICK alarm; rescheduling");
                }
                scheduleTimeTickEvent();
            } else if (intent.getAction().equals(Intent.ACTION_TIME_CHANGED)) {
                if (DEBUG_BATCH) {
                    Slog.v(TAG, "Received TIME_CHANGED alarm; reschedule date changed event.");
                }
                scheduleDateChangedEvent();
            } else if (intent.getAction().equals(Intent.ACTION_DATE_CHANGED)) {
                // Since the kernel does not keep track of DST, we need to
                // reset the TZ information at the beginning of each day
@@ -2054,7 +2060,7 @@ class AlarmManagerService extends SystemService {
        public void scheduleDateChangedEvent() {
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            calendar.set(Calendar.HOUR, 0);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);