Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +22 −0 Original line number Diff line number Diff line Loading @@ -1324,6 +1324,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { if (entry instanceof GroupEntry parent) { allSorted &= sortGroupChildren(parent.getRawChildren()); } else if (entry instanceof BundleEntry bundleEntry) { allSorted &= sortBundleChildren(bundleEntry.getRawChildren()); // Sort children of groups within bundles for (ListEntry le : bundleEntry.getChildren()) { if (le instanceof GroupEntry ge) { Loading Loading @@ -1360,6 +1361,15 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { } } private boolean sortBundleChildren(List<ListEntry> entries) { if (getStabilityManager().isEveryChangeAllowed()) { entries.sort(mBundleChildrenComparator); return true; } else { return mSemiStableSort.sort(entries, mStableOrder, mBundleChildrenComparator); } } /** Determine whether the items in the list are sorted according to the comparator */ @VisibleForTesting public static <T> boolean isSorted(List<T> items, Comparator<? super T> comparator) { Loading Loading @@ -1611,6 +1621,18 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { return cmp; }; private final Comparator<ListEntry> mBundleChildrenComparator = (o1, o2) -> { int cmp = Integer.compare( o1.getRepresentativeEntry().getRanking().getRank(), o2.getRepresentativeEntry().getRanking().getRank()); if (cmp != 0) return cmp; cmp = -1 * Long.compare( o1.getRepresentativeEntry().getSbn().getNotification().getWhen(), o2.getRepresentativeEntry().getSbn().getNotification().getWhen()); return cmp; }; @Nullable private Integer getStableOrderRank(PipelineEntry entry) { if (getStabilityManager().isEntryReorderingAllowed(entry)) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java +24 −1 Original line number Diff line number Diff line Loading @@ -1082,13 +1082,36 @@ public class ShadeListBuilderTest extends SysuiTestCase { verify(idPromoter, never()).shouldPromoteToTopLevel(eq(promotableChild)); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testBundle_bundleChildrenAreSorted() { mListBuilder.setBundler(TestBundler.INSTANCE); // GIVEN a simple pipeline // WHEN we three notifs in a bundle addNotif(0, PACKAGE_1, BUNDLE_1).setRank(3); addNotif(1, PACKAGE_1, BUNDLE_1).setRank(2); addNotif(2, PACKAGE_1, BUNDLE_1).setRank(1); dispatchBuild(); // THEN bundle children are sorted by rank verifyBuiltList( bundle( BUNDLE_1, notif(2), notif(1), notif(0) ) ); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testBundle_groupChildrenAreSorted() { mListBuilder.setBundler(TestBundler.INSTANCE); // GIVEN a simple pipeline // WHEN we add two groups // WHEN we a group with three children addGroupChild(0, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(3); addGroupChild(1, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(2); addGroupChild(2, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(1); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +22 −0 Original line number Diff line number Diff line Loading @@ -1324,6 +1324,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { if (entry instanceof GroupEntry parent) { allSorted &= sortGroupChildren(parent.getRawChildren()); } else if (entry instanceof BundleEntry bundleEntry) { allSorted &= sortBundleChildren(bundleEntry.getRawChildren()); // Sort children of groups within bundles for (ListEntry le : bundleEntry.getChildren()) { if (le instanceof GroupEntry ge) { Loading Loading @@ -1360,6 +1361,15 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { } } private boolean sortBundleChildren(List<ListEntry> entries) { if (getStabilityManager().isEveryChangeAllowed()) { entries.sort(mBundleChildrenComparator); return true; } else { return mSemiStableSort.sort(entries, mStableOrder, mBundleChildrenComparator); } } /** Determine whether the items in the list are sorted according to the comparator */ @VisibleForTesting public static <T> boolean isSorted(List<T> items, Comparator<? super T> comparator) { Loading Loading @@ -1611,6 +1621,18 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { return cmp; }; private final Comparator<ListEntry> mBundleChildrenComparator = (o1, o2) -> { int cmp = Integer.compare( o1.getRepresentativeEntry().getRanking().getRank(), o2.getRepresentativeEntry().getRanking().getRank()); if (cmp != 0) return cmp; cmp = -1 * Long.compare( o1.getRepresentativeEntry().getSbn().getNotification().getWhen(), o2.getRepresentativeEntry().getSbn().getNotification().getWhen()); return cmp; }; @Nullable private Integer getStableOrderRank(PipelineEntry entry) { if (getStabilityManager().isEntryReorderingAllowed(entry)) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java +24 −1 Original line number Diff line number Diff line Loading @@ -1082,13 +1082,36 @@ public class ShadeListBuilderTest extends SysuiTestCase { verify(idPromoter, never()).shouldPromoteToTopLevel(eq(promotableChild)); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testBundle_bundleChildrenAreSorted() { mListBuilder.setBundler(TestBundler.INSTANCE); // GIVEN a simple pipeline // WHEN we three notifs in a bundle addNotif(0, PACKAGE_1, BUNDLE_1).setRank(3); addNotif(1, PACKAGE_1, BUNDLE_1).setRank(2); addNotif(2, PACKAGE_1, BUNDLE_1).setRank(1); dispatchBuild(); // THEN bundle children are sorted by rank verifyBuiltList( bundle( BUNDLE_1, notif(2), notif(1), notif(0) ) ); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testBundle_groupChildrenAreSorted() { mListBuilder.setBundler(TestBundler.INSTANCE); // GIVEN a simple pipeline // WHEN we add two groups // WHEN we a group with three children addGroupChild(0, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(3); addGroupChild(1, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(2); addGroupChild(2, PACKAGE_1, GROUP_1, BUNDLE_1).setRank(1); Loading