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

Commit ba61dbdb authored by Alexander Roederer's avatar Alexander Roederer
Browse files

Post LifetimeExt updates silently

Posts lifetime extension updates silently, by setting
FLAG_ONLY_ALERT_ONCE and setPostSilently.
Note that these updates are sent to System UI whenever a
notification that has been lifetime extended needs to change its
appearance, like transitioning from sending to sent state);
We don't want to alert the user when they just finished sending a direct
reply from the notification, as presumably they'll be looking at the
notification when this happens.

Bug: 329961486
Test: atest NotificationManagerServiceTest.java, build and flash
Flag: ACONFIG android.app.lifetime_extension_refactor STAGING
Change-Id: Iba2c8ac5da826bf970ba6041f1e11b4c50189c4d
parent f8df2580
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -11924,6 +11924,9 @@ public class NotificationManagerService extends SystemService {
        if (record != null && (record.getSbn().getNotification().flags
                & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY) > 0) {
            boolean isAppForeground = pkg != null && packageImportance == IMPORTANCE_FOREGROUND;
            // Lifetime extended notifications don't need to alert on state change.
            record.setPostSilently(true);
            mHandler.post(new EnqueueNotificationRunnable(record.getUser().getIdentifier(),
                    record, isAppForeground,
                    mPostNotificationTrackerFactory.newTracker(null)));
+2 −0
Original line number Diff line number Diff line
@@ -5862,6 +5862,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertThat(captor.getValue().getNotification().flags
                & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY).isEqualTo(
                FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY);
        assertThat(captor.getValue().shouldPostSilently()).isTrue();
    }
    @Test
@@ -8603,6 +8604,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertThat(captor.getValue().getNotification().flags
                & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY).isEqualTo(
                FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY);
        assertThat(captor.getValue().shouldPostSilently()).isTrue();
    }
    @Test