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

Commit 39c97dae authored by Chris Tate's avatar Chris Tate Committed by android-build-merger
Browse files

Merge "Properly reset doze transition alarms with force-stop" into qt-dev

am: 0dc23d78

Change-Id: I0cb52872be38af07e65fd1c8952f06e87f304727
parents 6d9c83fd 0dc23d78
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import android.util.ArraySet;
import android.util.KeyValueListParser;
import android.util.Log;
import android.util.LongArrayQueue;
import android.util.MutableBoolean;
import android.util.NtpTrustedTime;
import android.util.Pair;
import android.util.Slog;
@@ -3187,6 +3188,16 @@ class AlarmManagerService extends SystemService {
                mPendingBackgroundAlarms.removeAt(i);
            }
        }
        // If we're currently keying off of this app's alarms for doze transitions,
        // make sure to reset to other triggers.
        if (mNextWakeFromIdle != null && mNextWakeFromIdle.uid == uid) {
            mNextWakeFromIdle = null;
        }
        if (mPendingIdleUntil != null && mPendingIdleUntil.uid == uid) {
            // Should never happen - only the system uid is allowed to set idle-until alarms
            Slog.wtf(TAG, "Removed app uid " + uid + " set idle-until alarm!");
            mPendingIdleUntil = null;
        }
        if (didRemove) {
            if (DEBUG_BATCH) {
                Slog.v(TAG, "remove(uid) changed bounds; rebatching");
@@ -3207,7 +3218,14 @@ class AlarmManagerService extends SystemService {
        }

        boolean didRemove = false;
        final Predicate<Alarm> whichAlarms = (Alarm a) -> a.matches(packageName);
        final MutableBoolean removedNextWakeFromIdle = new MutableBoolean(false);
        final Predicate<Alarm> whichAlarms = (Alarm a) -> {
            final boolean didMatch = a.matches(packageName);
            if (didMatch && a == mNextWakeFromIdle) {
                removedNextWakeFromIdle.value = true;
            }
            return didMatch;
        };
        final boolean oldHasTick = haveBatchesTimeTickAlarm(mAlarmBatches);
        for (int i = mAlarmBatches.size() - 1; i >= 0; i--) {
            Batch b = mAlarmBatches.get(i);
@@ -3242,6 +3260,11 @@ class AlarmManagerService extends SystemService {
                mPendingBackgroundAlarms.removeAt(i);
            }
        }
        // If we're currently keying off of this app's alarms for doze transitions,
        // make sure to reset to other triggers.
        if (removedNextWakeFromIdle.value) {
            mNextWakeFromIdle = null;
        }
        if (didRemove) {
            if (DEBUG_BATCH) {
                Slog.v(TAG, "remove(package) changed bounds; rebatching");