Loading packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; Loading packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -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)); } } Loading
packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceNotificationListenerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -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)); } }