Dont clear Notifs with FLAG_NO_CLEAR

Fixes: 206842750
Test: NotifCollectionTest
Change-Id: Ic43e605560e2d158e72dce070e92d1ffc08b0d96
This commit is contained in:
Jay Aliomer
2022-01-14 15:17:45 -05:00
parent ca5641d35a
commit c5f7cfe52d
2 changed files with 13 additions and 1 deletions

View File

@@ -56,7 +56,6 @@ import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.util.Pair;
import android.util.Slog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -756,6 +755,7 @@ public class NotifCollection implements Dumpable {
&& !entry.getSbn().getNotification().isGroupSummary()
&& !hasFlag(entry, Notification.FLAG_ONGOING_EVENT)
&& !hasFlag(entry, Notification.FLAG_BUBBLE)
&& !hasFlag(entry, Notification.FLAG_NO_CLEAR)
&& entry.getDismissState() != DISMISSED;
}

View File

@@ -1468,6 +1468,18 @@ public class NotifCollectionTest extends SysuiTestCase {
container, container.getSbn().getGroupKey()));
}
@Test
public void testCannotDismissNoClearNotifications() {
// GIVEN an no-clear notification
final NotificationEntry container = new NotificationEntryBuilder()
.setFlag(mContext, FLAG_NO_CLEAR, true)
.build();
// THEN its children are not dismissible
assertFalse(mCollection.shouldAutoDismissChildren(
container, container.getSbn().getGroupKey()));
}
@Test
public void testCanDismissFgsNotificationChildren() {
// GIVEN an FGS but not ongoing notification