Merge "Properly reset doze transition alarms with force-stop" into qt-dev
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user