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

Commit dbb1528f authored by Evan Laird's avatar Evan Laird Committed by Automerger Merge Worker
Browse files

Merge "Allow interrupting notifications to bypass lifetime extension" into...

Merge "Allow interrupting notifications to bypass lifetime extension" into rvc-dev am: a7e99b00 am: 3ee09ec9 am: 2e450b2c am: ea63ff6d

Change-Id: I9b972e91a3d8e03e4bf0b95669336e978a6a238a
parents 33cfab4b ea63ff6d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
+12 −0
Original line number Diff line number Diff line
@@ -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));
    }
}