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

Commit 1cbef0b2 authored by Ned Burns's avatar Ned Burns
Browse files

Don't crash if we're given an incomplete ranking

Right now there's a race condition in NotificationListener that means
that we can (briefly) be exposed to rankings that don't contain all of
the notifications that we know about. The order is as follows:

(system server)
queue onListenerConnected
queue onNotificationPosted
queue onNotificationPosted
(sysui offthread)
see onListenerConnected
read list of current notifs (2 total)
post to main.onListenerConnected
see onNotificationPosted, post to main.onNotifPosted
see onNotificationPosted, post to main.onNotifPosted
(sysui main thread)
see main.onListenerConnected, add notifs #1 and #2
see main.onNotificationPosted, attempt to re-add notif#1 (counts as
update, fine), attempt to update ranking (ERROR, missing ranking for
notif#2, crash)

Filed b/148791039 to track the overall race condition.

Short-term fix is to just disable this check and be sad.

Fixes: 148291993
Test: atest
Change-Id: Id03dccfed3f2c061b7603b7e9e3b5210aeaaf962
parent bad7f3bf
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -308,7 +308,12 @@ public class NotifCollection implements Dumpable {
    private void applyRanking(@NonNull RankingMap rankingMap) {
        for (NotificationEntry entry : mNotificationSet.values()) {
            if (!isLifetimeExtended(entry)) {
                Ranking ranking = requireRanking(rankingMap, entry.getKey());

                // TODO: (b/148791039) We should crash if we are ever handed a ranking with
                //  incomplete entries. Right now, there's a race condition in NotificationListener
                //  that means this might occur when SystemUI is starting up.
                Ranking ranking = new Ranking();
                if (rankingMap.getRanking(entry.getKey(), ranking)) {
                    entry.setRanking(ranking);

                    // TODO: (b/145659174) update the sbn's overrideGroupKey in
@@ -324,6 +329,7 @@ public class NotifCollection implements Dumpable {
                }
            }
        }
    }

    private void rebuildList() {
        if (mBuildListener != null) {