diff options
| author | 2020-05-29 15:06:49 +0000 | |
|---|---|---|
| committer | 2020-05-29 15:06:49 +0000 | |
| commit | a7e99b00c07eadb0d923debae65c44ab8c34bdb5 (patch) | |
| tree | 420be677c4f006419e0ef8dd8bc5e79c4e39e44c | |
| parent | f35625face4e4e3e371651cb0ffb15a1ae658920 (diff) | |
| parent | 1d7db5b9eef729aff7606a87c19768bfcb2d86a5 (diff) | |
Merge "Allow interrupting notifications to bypass lifetime extension" into rvc-dev
2 files changed, 18 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java b/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java index 77abffc82d68..c0f8cae607ca 100644 --- a/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java +++ b/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java @@ -66,6 +66,12 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx return false; } + // Entry has triggered a HUN or some other interruption, therefore it has been seen and the + // interrupter might be retaining it anyway. + if (entry.hasInterrupted()) { + return false; + } + boolean hasInteracted = mInteractionTracker.hasUserInteractedWith(entry.getKey()); long aliveTime = mSystemClock.uptimeMillis() - entry.getCreationTime(); return aliveTime < MIN_FGS_TIME_MS && !hasInteracted; diff --git a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java index 050b5538773d..9a40421a353f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java @@ -95,4 +95,16 @@ public class ForegroundServiceNotificationListenerTest extends SysuiTestCase { mClock.advanceTime(MIN_FGS_TIME_MS + 1); assertFalse(mExtender.shouldExtendLifetime(mEntry)); } + + @Test + public void testShouldExtendLifetime_shouldNot_interruped() { + // GIVEN a notification that would trigger lifetime extension + mNotif.flags |= Notification.FLAG_FOREGROUND_SERVICE; + + // GIVEN the notification has alerted + mEntry.setInterruption(); + + // THEN the notification does not need to have its lifetime extended by this extender + assertFalse(mExtender.shouldExtendLifetime(mEntry)); + } } |