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

Commit 07f2006b authored by Jeff DeCew's avatar Jeff DeCew Committed by Automerger Merge Worker
Browse files

Merge "Enforce contigious but unordered buckets" into tm-dev am: ee3ca4bc

parents 15a2346e ee3ca4bc
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ public class ShadeListBuilder implements Dumpable {
    private final NotificationInteractionTracker mInteractionTracker;
    private final DumpManager mDumpManager;
    // used exclusivly by ShadeListBuilder#notifySectionEntriesUpdated
    // TODO replace temp with collection pool for readability
    private final ArrayList<ListEntry> mTempSectionMembers = new ArrayList<>();
    private final boolean mAlwaysLogList;

@@ -230,13 +231,7 @@ public class ShadeListBuilder implements Dumpable {
        mPipelineState.requireState(STATE_IDLE);

        mNotifSections.clear();
        NotifSectioner lastSection = null;
        for (NotifSectioner sectioner : sectioners) {
            if (lastSection != null && lastSection.getBucket() > sectioner.getBucket()) {
                throw new IllegalArgumentException("setSectioners with non contiguous sections "
                        + lastSection.getName() + " - " + lastSection.getBucket() + " & "
                        + sectioner.getName() + " - " + sectioner.getBucket());
            }
            final NotifSection section = new NotifSection(sectioner, mNotifSections.size());
            final NotifComparator sectionComparator = section.getComparator();
            mNotifSections.add(section);
@@ -244,10 +239,23 @@ public class ShadeListBuilder implements Dumpable {
            if (sectionComparator != null) {
                sectionComparator.setInvalidationListener(this::onNotifComparatorInvalidated);
            }
            lastSection = sectioner;
        }

        mNotifSections.add(new NotifSection(DEFAULT_SECTIONER, mNotifSections.size()));

        // validate sections
        final ArraySet<Integer> seenBuckets = new ArraySet<>();
        int lastBucket = mNotifSections.size() > 0
                ? mNotifSections.get(0).getBucket()
                : 0;
        for (NotifSection section : mNotifSections) {
            if (lastBucket != section.getBucket() && seenBuckets.contains(section.getBucket())) {
                throw new IllegalStateException("setSectioners with non contiguous sections "
                        + section.getLabel() + " has an already seen bucket");
            }
            lastBucket = section.getBucket();
            seenBuckets.add(lastBucket);
        }
    }

    void setNotifStabilityManager(@NonNull NotifStabilityManager notifStabilityManager) {
+0 −10
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ class NodeSpecBuilder(

        var currentSection: NotifSection? = null
        val prevSections = mutableSetOf<NotifSection?>()
        var lastSection: NotifSection? = null
        val showHeaders = sectionHeaderVisibilityProvider.sectionHeadersVisible
        val sectionOrder = mutableListOf<NotifSection?>()
        val sectionHeaders = mutableMapOf<NotifSection?, NodeController?>()
@@ -65,15 +64,6 @@ class NodeSpecBuilder(

        for (entry in notifList) {
            val section = entry.section!!

            lastSection?.let {
                if (it.bucket > section.bucket) {
                    throw IllegalStateException("buildNodeSpec with non contiguous section " +
                            "buckets ${it.sectioner.name} - ${it.bucket} & " +
                            "${it.sectioner.name} - ${it.bucket}")
                }
            }
            lastSection = section
            if (prevSections.contains(section)) {
                throw java.lang.RuntimeException("Section ${section.label} has been duplicated")
            }
+33 −1
Original line number Diff line number Diff line
@@ -1527,6 +1527,34 @@ public class ShadeListBuilderTest extends SysuiTestCase {
        );
    }

    @Test
    public void testContiguousSections() {
        mListBuilder.setSectioners(List.of(
                new PackageSectioner("pkg", 1),
                new PackageSectioner("pkg", 1),
                new PackageSectioner("pkg", 3),
                new PackageSectioner("pkg", 2)
        ));
    }

    @Test(expected = IllegalStateException.class)
    public void testNonContiguousSections() {
        mListBuilder.setSectioners(List.of(
                new PackageSectioner("pkg", 1),
                new PackageSectioner("pkg", 1),
                new PackageSectioner("pkg", 3),
                new PackageSectioner("pkg", 1)
        ));
    }

    @Test(expected = IllegalStateException.class)
    public void testBucketZeroNotAllowed() {
        mListBuilder.setSectioners(List.of(
                new PackageSectioner("pkg", 0),
                new PackageSectioner("pkg", 1)
        ));
    }

    @Test
    public void testStabilizeGroupsDelayedSummaryRendersAllNotifsTopLevel() {
        // GIVEN group children posted without a summary
@@ -2189,7 +2217,11 @@ public class ShadeListBuilderTest extends SysuiTestCase {
        }

        PackageSectioner(String pkg) {
            super("PackageSection_" + pkg, 0);
            this(pkg, 0);
        }

        PackageSectioner(String pkg, int bucket) {
            super("PackageSection_" + pkg, bucket);
            mPackages = List.of(pkg);
            mComparator = null;
        }