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

Commit 0a7416d2 authored by Fan Zhang's avatar Fan Zhang
Browse files

Schedule timer to fire when device is in idle mode.

Bug: 21602742
Change-Id: I6a77f44552fee0760784b212e4582167075f19b6
parent d90b41b4
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -336,8 +336,16 @@ public class TimerReceiver extends BroadcastReceiver {
        final PendingIntent p = PendingIntent.getBroadcast(context,
                0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
        if (t != null) {
            if (Utils.isMOrLater()) {
                // Make sure we fire the timer even when device is in doze mode.
                // The timer is not guaranteed to fire at the exact time. It can have up to 15
                // minutes delay.
                am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p);
                LogUtils.d(TAG, "Setting times up to (approximately) " + nextTimesup);
            } else {
                am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p);
            LogUtils.d(TAG, "Setting times up to " + nextTimesup);
                LogUtils.d(TAG, "Setting times up to (exactly) " + nextTimesup);
            }
        } else {
            // if no timer is found Pending Intents should be canceled
            // to keep the internal state consistent with the UI