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

Commit 158491e1 authored by Beverly's avatar Beverly Committed by Automerger Merge Worker
Browse files

Update ranking for uninflated updated notifs am: 9dc72101

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12852513

Change-Id: Idda1f9af2d30bc144fc595897fea2f1d0e039ecb
parents d1c4e9ae 9dc72101
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -574,6 +574,7 @@ public class NotificationEntryManager implements
        NotificationEntry entry = mPendingNotifications.get(key);
        if (entry != null) {
            entry.setSbn(notification);
            entry.setRanking(ranking);
        } else {
            entry = new NotificationEntry(
                    notification,
+4 −6
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import javax.inject.Singleton;
 */
@Singleton
public class RankingCoordinator implements Coordinator {
    private static final String TAG = "RankingNotificationCoordinator";

    private final StatusBarStateController mStatusBarStateController;

    @Inject
@@ -46,7 +44,7 @@ public class RankingCoordinator implements Coordinator {
        mStatusBarStateController.addCallback(mStatusBarStateCallback);

        pipeline.addPreGroupFilter(mSuspendedFilter);
        pipeline.addPreGroupFilter(mDozingFilter);
        pipeline.addPreGroupFilter(mDndVisualEffectsFilter);
    }

    /**
@@ -61,10 +59,10 @@ public class RankingCoordinator implements Coordinator {
        }
    };

    private final NotifFilter mDozingFilter = new NotifFilter("IsDozingFilter") {
    private final NotifFilter mDndVisualEffectsFilter = new NotifFilter(
            "DndSuppressingVisualEffects") {
        @Override
        public boolean shouldFilterOut(NotificationEntry entry, long now) {
            // Dozing + DND Settings from Ranking object
            if (mStatusBarStateController.isDozing() && entry.shouldSuppressAmbient()) {
                return true;
            }
@@ -77,7 +75,7 @@ public class RankingCoordinator implements Coordinator {
            new StatusBarStateController.StateListener() {
                @Override
                public void onDozingChanged(boolean isDozing) {
                    mDozingFilter.invalidateList();
                    mDndVisualEffectsFilter.invalidateList();
                }
            };
}
+1 −1
Original line number Diff line number Diff line
@@ -504,7 +504,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    /**
     * Returns whether this row is considered non-blockable (i.e. it's a non-blockable system notif
     * or is in a whitelist).
     * or is in an allowList).
     */
    public boolean getIsNonblockable() {
        boolean isNonblockable = Dependency.get(NotificationBlockingHelperManager.class)
+30 −0
Original line number Diff line number Diff line
@@ -381,6 +381,36 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
        assertEquals("action", mEntry.getSmartActions().get(0).title);
    }

    @Test
    public void testUpdatePendingNotification_rankingUpdated() {
        // GIVEN a notification with ranking is pending
        final Ranking originalRanking = mEntry.getRanking();
        mEntryManager.mPendingNotifications.put(mEntry.getKey(), mEntry);

        // WHEN the same notification has been updated with a new ranking
        final int newRank = 2345;
        doAnswer(invocationOnMock -> {
            Ranking ranking = (Ranking)
                    invocationOnMock.getArguments()[1];
            ranking.populate(
                    mEntry.getKey(),
                    newRank, /* this changed!! */
                    false,
                    0,
                    0,
                    IMPORTANCE_DEFAULT,
                    null, null,
                    null, null, null, true,
                    Ranking.USER_SENTIMENT_NEUTRAL, false, -1,
                    false, null, null, false, false, false, null, false);
            return true;
        }).when(mRankingMap).getRanking(eq(mEntry.getKey()), any(Ranking.class));
        mEntryManager.addNotification(mSbn, mRankingMap);

        // THEN ranking for the entry has been updated with new ranking
        assertEquals(newRank, mEntry.getRanking().getRank());
    }

    @Test
    public void testLifetimeExtenders_ifNotificationIsRetainedItIsntRemoved() {
        // GIVEN an entry manager with a notification