Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListAttachState.kt +1 −5 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ package com.android.systemui.statusbar.notification.collection import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection /** * Stores the state that [ShadeListBuilder] assigns to this [ListEntry] Loading @@ -35,7 +35,6 @@ data class ListAttachState private constructor( * parent's section. Null if not attached to the list. */ var section: NotifSection?, var sectionIndex: Int, /** * If a [NotifFilter] is excluding this entry from the list, then that filter. Always null for Loading @@ -60,7 +59,6 @@ data class ListAttachState private constructor( fun clone(other: ListAttachState) { parent = other.parent section = other.section sectionIndex = other.sectionIndex excludingFilter = other.excludingFilter promoter = other.promoter suppressedChanges.clone(other.suppressedChanges) Loading @@ -70,7 +68,6 @@ data class ListAttachState private constructor( fun reset() { parent = null section = null sectionIndex = -1 excludingFilter = null promoter = null suppressedChanges.reset() Loading @@ -82,7 +79,6 @@ data class ListAttachState private constructor( return ListAttachState( null, null, -1, null, null, SuppressedAttachState.create()) Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListDumper.java +5 −10 Original line number Diff line number Diff line Loading @@ -112,11 +112,9 @@ public class ListDumper { .append(")"); } if (entry.getNotifSection() != null) { sb.append(" sectionIndex=") .append(entry.getSection()) .append(" sectionName=") .append(entry.getNotifSection().getName()); if (entry.getSection() != null) { sb.append(" section=") .append(entry.getSection().getLabel()); } if (includeRecordKeeping) { Loading Loading @@ -175,12 +173,9 @@ public class ListDumper { } if (notifEntry.getAttachState().getSuppressedChanges().getSection() != null) { rksb.append("suppressedSectionIndex=") rksb.append("suppressedSection=") .append(notifEntry.getAttachState().getSuppressedChanges() .getSectionIndex()) .append(" sectionName=") .append(notifEntry.getAttachState().getSuppressedChanges() .getSection().getName()) .getSection()) .append(" "); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java +5 −6 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.annotation.UptimeMillisLong; import androidx.annotation.Nullable; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection; /** * Abstract superclass for top-level entries, i.e. things that can appear in the final notification Loading Loading @@ -78,13 +78,12 @@ public abstract class ListEntry { return mPreviousAttachState.getParent(); } /** The section this notification was assigned to (0 to N-1, where N is number of sections). */ public int getSection() { return mAttachState.getSectionIndex(); @Nullable public NotifSection getSection() { return mAttachState.getSection(); } @Nullable public NotifSection getNotifSection() { return mAttachState.getSection(); public int getSectionIndex() { return mAttachState.getSection() != null ? mAttachState.getSection().getIndex() : -1; } ListAttachState getAttachState() { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifPipeline.java +4 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.OnBefo import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; Loading Loading @@ -155,10 +155,10 @@ public class NotifPipeline implements CommonNotifCollection { * Sections that are used to sort top-level entries. If two entries have the same section, * NotifComparators are consulted. Sections from this list are called in order for each * notification passed through the pipeline. The first NotifSection to return true for * {@link NotifSection#isInSection(ListEntry)} sets the entry as part of its Section. * {@link NotifSectioner#isInSection(ListEntry)} sets the entry as part of its Section. */ public void setSections(List<NotifSection> sections) { mShadeListBuilder.setSections(sections); public void setSections(List<NotifSectioner> sections) { mShadeListBuilder.setSectioners(sections); } /** Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +45 −42 Original line number Diff line number Diff line Loading @@ -28,10 +28,11 @@ import static com.android.systemui.statusbar.notification.collection.listbuilder import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_SORTING; import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_TRANSFORMING; import static java.util.Objects.requireNonNull; import android.annotation.MainThread; import android.annotation.Nullable; import android.util.ArrayMap; import android.util.Pair; import androidx.annotation.NonNull; Loading @@ -39,6 +40,7 @@ import com.android.systemui.Dumpable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dump.DumpManager; import com.android.systemui.statusbar.NotificationInteractionTracker; import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeFinalizeFilterListener; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeSortListener; Loading @@ -48,7 +50,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.ShadeL import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable; import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener; Loading Loading @@ -119,6 +121,8 @@ public class ShadeListBuilder implements Dumpable { mLogger = logger; mInteractionTracker = interactionTracker; dumpManager.registerDumpable(TAG, this); setSectioners(Collections.emptyList()); } /** Loading Loading @@ -193,15 +197,17 @@ public class ShadeListBuilder implements Dumpable { promoter.setInvalidationListener(this::onPromoterInvalidated); } void setSections(List<NotifSection> sections) { void setSectioners(List<NotifSectioner> sectioners) { Assert.isMainThread(); mPipelineState.requireState(STATE_IDLE); mNotifSections.clear(); for (NotifSection section : sections) { mNotifSections.add(section); section.setInvalidationListener(this::onNotifSectionInvalidated); for (NotifSectioner sectioner : sectioners) { mNotifSections.add(new NotifSection(sectioner, mNotifSections.size())); sectioner.setInvalidationListener(this::onNotifSectionInvalidated); } mNotifSections.add(new NotifSection(DEFAULT_SECTIONER, mNotifSections.size())); } void setNotifStabilityManager(NotifStabilityManager notifStabilityManager) { Loading Loading @@ -275,7 +281,7 @@ public class ShadeListBuilder implements Dumpable { rebuildListIfBefore(STATE_TRANSFORMING); } private void onNotifSectionInvalidated(NotifSection section) { private void onNotifSectionInvalidated(NotifSectioner section) { Assert.isMainThread(); mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState()); Loading Loading @@ -652,7 +658,6 @@ public class ShadeListBuilder implements Dumpable { */ private void annulAddition(ListEntry entry) { entry.setParent(null); entry.getAttachState().setSectionIndex(-1); entry.getAttachState().setSection(null); entry.getAttachState().setPromoter(null); if (entry.mFirstAddedIteration == mIterationCount) { Loading @@ -663,12 +668,12 @@ public class ShadeListBuilder implements Dumpable { private void sortList() { // Assign sections to top-level elements and sort their children for (ListEntry entry : mNotifList) { Pair<NotifSection, Integer> sectionWithIndex = applySections(entry); NotifSection section = applySections(entry); if (entry instanceof GroupEntry) { GroupEntry parent = (GroupEntry) entry; for (NotificationEntry child : parent.getChildren()) { child.getAttachState().setSection(sectionWithIndex.first); child.getAttachState().setSectionIndex(sectionWithIndex.second); child.getAttachState().setSection(section); child.getAttachState().setSection(section); } parent.sortChildren(sChildComparator); } Loading Loading @@ -736,16 +741,13 @@ public class ShadeListBuilder implements Dumpable { mLogger.logSectionChanged( mIterationCount, prev.getSection(), prev.getSectionIndex(), curr.getSection(), curr.getSectionIndex()); curr.getSection()); } if (curr.getSuppressedChanges().getSection() != null) { mLogger.logSectionChangeSuppressed( mIterationCount, curr.getSuppressedChanges().getSection(), curr.getSuppressedChanges().getSectionIndex(), curr.getSection()); } } Loading @@ -762,7 +764,10 @@ public class ShadeListBuilder implements Dumpable { callOnCleanup(mNotifPromoters); callOnCleanup(mNotifFinalizeFilters); callOnCleanup(mNotifComparators); callOnCleanup(mNotifSections); for (int i = 0; i < mNotifSections.size(); i++) { mNotifSections.get(i).getSectioner().onCleanup(); } if (mNotifStabilityManager != null) { callOnCleanup(List.of(mNotifStabilityManager)); Loading @@ -777,7 +782,9 @@ public class ShadeListBuilder implements Dumpable { private final Comparator<ListEntry> mTopLevelComparator = (o1, o2) -> { int cmp = Integer.compare(o1.getSection(), o2.getSection()); int cmp = Integer.compare( requireNonNull(o1.getSection()).getIndex(), requireNonNull(o2.getSection()).getIndex()); if (cmp == 0) { for (int i = 0; i < mNotifComparators.size(); i++) { Loading Loading @@ -855,45 +862,41 @@ public class ShadeListBuilder implements Dumpable { return null; } private Pair<NotifSection, Integer> applySections(ListEntry entry) { Pair<NotifSection, Integer> sectionWithIndex = findSection(entry); private NotifSection applySections(ListEntry entry) { final NotifSection newSection = findSection(entry); final ListAttachState prevAttachState = entry.getPreviousAttachState(); NotifSection finalSection = newSection; // are we changing sections of this entry? if (mNotifStabilityManager != null && prevAttachState.getParent() != null && (sectionWithIndex.first != prevAttachState.getSection() || sectionWithIndex.second != prevAttachState.getSectionIndex())) { && newSection != prevAttachState.getSection()) { // are section changes allowed? if (!mNotifStabilityManager.isSectionChangeAllowed( entry.getRepresentativeEntry())) { entry.getAttachState().getSuppressedChanges().setSection( sectionWithIndex.first); entry.getAttachState().getSuppressedChanges().setSectionIndex( sectionWithIndex.second); if (!mNotifStabilityManager.isSectionChangeAllowed(entry.getRepresentativeEntry())) { // record the section that we wanted to change to entry.getAttachState().getSuppressedChanges().setSection(newSection); // keep the previous section sectionWithIndex = new Pair( prevAttachState.getSection(), prevAttachState.getSectionIndex()); finalSection = prevAttachState.getSection(); } } entry.getAttachState().setSection(sectionWithIndex.first); entry.getAttachState().setSectionIndex(sectionWithIndex.second); entry.getAttachState().setSection(finalSection); return sectionWithIndex; return finalSection; } private Pair<NotifSection, Integer> findSection(ListEntry entry) { @NonNull private NotifSection findSection(ListEntry entry) { for (int i = 0; i < mNotifSections.size(); i++) { NotifSection sectioner = mNotifSections.get(i); if (sectioner.isInSection(entry)) { return new Pair<>(sectioner, i); NotifSection section = mNotifSections.get(i); if (section.getSectioner().isInSection(entry)) { return section; } } return new Pair<>(sDefaultSection, mNotifSections.size()); throw new RuntimeException("Missing default sectioner!"); } private void rebuildListIfBefore(@PipelineState.StateName int state) { Loading Loading @@ -963,15 +966,15 @@ public class ShadeListBuilder implements Dumpable { void onRenderList(@NonNull List<ListEntry> entries); } private static final NotifSection sDefaultSection = new NotifSection("UnknownSection") { private static final NotifSectioner DEFAULT_SECTIONER = new NotifSectioner("UnknownSection") { @Override public boolean isInSection(ListEntry entry) { return true; } }; private static final String TAG = "ShadeListBuilder"; private static final int MIN_CHILDREN_FOR_GROUP = 2; private static final String TAG = "ShadeListBuilder"; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListAttachState.kt +1 −5 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ package com.android.systemui.statusbar.notification.collection import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection /** * Stores the state that [ShadeListBuilder] assigns to this [ListEntry] Loading @@ -35,7 +35,6 @@ data class ListAttachState private constructor( * parent's section. Null if not attached to the list. */ var section: NotifSection?, var sectionIndex: Int, /** * If a [NotifFilter] is excluding this entry from the list, then that filter. Always null for Loading @@ -60,7 +59,6 @@ data class ListAttachState private constructor( fun clone(other: ListAttachState) { parent = other.parent section = other.section sectionIndex = other.sectionIndex excludingFilter = other.excludingFilter promoter = other.promoter suppressedChanges.clone(other.suppressedChanges) Loading @@ -70,7 +68,6 @@ data class ListAttachState private constructor( fun reset() { parent = null section = null sectionIndex = -1 excludingFilter = null promoter = null suppressedChanges.reset() Loading @@ -82,7 +79,6 @@ data class ListAttachState private constructor( return ListAttachState( null, null, -1, null, null, SuppressedAttachState.create()) Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListDumper.java +5 −10 Original line number Diff line number Diff line Loading @@ -112,11 +112,9 @@ public class ListDumper { .append(")"); } if (entry.getNotifSection() != null) { sb.append(" sectionIndex=") .append(entry.getSection()) .append(" sectionName=") .append(entry.getNotifSection().getName()); if (entry.getSection() != null) { sb.append(" section=") .append(entry.getSection().getLabel()); } if (includeRecordKeeping) { Loading Loading @@ -175,12 +173,9 @@ public class ListDumper { } if (notifEntry.getAttachState().getSuppressedChanges().getSection() != null) { rksb.append("suppressedSectionIndex=") rksb.append("suppressedSection=") .append(notifEntry.getAttachState().getSuppressedChanges() .getSectionIndex()) .append(" sectionName=") .append(notifEntry.getAttachState().getSuppressedChanges() .getSection().getName()) .getSection()) .append(" "); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java +5 −6 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.annotation.UptimeMillisLong; import androidx.annotation.Nullable; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection; /** * Abstract superclass for top-level entries, i.e. things that can appear in the final notification Loading Loading @@ -78,13 +78,12 @@ public abstract class ListEntry { return mPreviousAttachState.getParent(); } /** The section this notification was assigned to (0 to N-1, where N is number of sections). */ public int getSection() { return mAttachState.getSectionIndex(); @Nullable public NotifSection getSection() { return mAttachState.getSection(); } @Nullable public NotifSection getNotifSection() { return mAttachState.getSection(); public int getSectionIndex() { return mAttachState.getSection() != null ? mAttachState.getSection().getIndex() : -1; } ListAttachState getAttachState() { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifPipeline.java +4 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.OnBefo import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; Loading Loading @@ -155,10 +155,10 @@ public class NotifPipeline implements CommonNotifCollection { * Sections that are used to sort top-level entries. If two entries have the same section, * NotifComparators are consulted. Sections from this list are called in order for each * notification passed through the pipeline. The first NotifSection to return true for * {@link NotifSection#isInSection(ListEntry)} sets the entry as part of its Section. * {@link NotifSectioner#isInSection(ListEntry)} sets the entry as part of its Section. */ public void setSections(List<NotifSection> sections) { mShadeListBuilder.setSections(sections); public void setSections(List<NotifSectioner> sections) { mShadeListBuilder.setSectioners(sections); } /** Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +45 −42 Original line number Diff line number Diff line Loading @@ -28,10 +28,11 @@ import static com.android.systemui.statusbar.notification.collection.listbuilder import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_SORTING; import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_TRANSFORMING; import static java.util.Objects.requireNonNull; import android.annotation.MainThread; import android.annotation.Nullable; import android.util.ArrayMap; import android.util.Pair; import androidx.annotation.NonNull; Loading @@ -39,6 +40,7 @@ import com.android.systemui.Dumpable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dump.DumpManager; import com.android.systemui.statusbar.NotificationInteractionTracker; import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeFinalizeFilterListener; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener; import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeSortListener; Loading @@ -48,7 +50,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.ShadeL import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable; import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener; Loading Loading @@ -119,6 +121,8 @@ public class ShadeListBuilder implements Dumpable { mLogger = logger; mInteractionTracker = interactionTracker; dumpManager.registerDumpable(TAG, this); setSectioners(Collections.emptyList()); } /** Loading Loading @@ -193,15 +197,17 @@ public class ShadeListBuilder implements Dumpable { promoter.setInvalidationListener(this::onPromoterInvalidated); } void setSections(List<NotifSection> sections) { void setSectioners(List<NotifSectioner> sectioners) { Assert.isMainThread(); mPipelineState.requireState(STATE_IDLE); mNotifSections.clear(); for (NotifSection section : sections) { mNotifSections.add(section); section.setInvalidationListener(this::onNotifSectionInvalidated); for (NotifSectioner sectioner : sectioners) { mNotifSections.add(new NotifSection(sectioner, mNotifSections.size())); sectioner.setInvalidationListener(this::onNotifSectionInvalidated); } mNotifSections.add(new NotifSection(DEFAULT_SECTIONER, mNotifSections.size())); } void setNotifStabilityManager(NotifStabilityManager notifStabilityManager) { Loading Loading @@ -275,7 +281,7 @@ public class ShadeListBuilder implements Dumpable { rebuildListIfBefore(STATE_TRANSFORMING); } private void onNotifSectionInvalidated(NotifSection section) { private void onNotifSectionInvalidated(NotifSectioner section) { Assert.isMainThread(); mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState()); Loading Loading @@ -652,7 +658,6 @@ public class ShadeListBuilder implements Dumpable { */ private void annulAddition(ListEntry entry) { entry.setParent(null); entry.getAttachState().setSectionIndex(-1); entry.getAttachState().setSection(null); entry.getAttachState().setPromoter(null); if (entry.mFirstAddedIteration == mIterationCount) { Loading @@ -663,12 +668,12 @@ public class ShadeListBuilder implements Dumpable { private void sortList() { // Assign sections to top-level elements and sort their children for (ListEntry entry : mNotifList) { Pair<NotifSection, Integer> sectionWithIndex = applySections(entry); NotifSection section = applySections(entry); if (entry instanceof GroupEntry) { GroupEntry parent = (GroupEntry) entry; for (NotificationEntry child : parent.getChildren()) { child.getAttachState().setSection(sectionWithIndex.first); child.getAttachState().setSectionIndex(sectionWithIndex.second); child.getAttachState().setSection(section); child.getAttachState().setSection(section); } parent.sortChildren(sChildComparator); } Loading Loading @@ -736,16 +741,13 @@ public class ShadeListBuilder implements Dumpable { mLogger.logSectionChanged( mIterationCount, prev.getSection(), prev.getSectionIndex(), curr.getSection(), curr.getSectionIndex()); curr.getSection()); } if (curr.getSuppressedChanges().getSection() != null) { mLogger.logSectionChangeSuppressed( mIterationCount, curr.getSuppressedChanges().getSection(), curr.getSuppressedChanges().getSectionIndex(), curr.getSection()); } } Loading @@ -762,7 +764,10 @@ public class ShadeListBuilder implements Dumpable { callOnCleanup(mNotifPromoters); callOnCleanup(mNotifFinalizeFilters); callOnCleanup(mNotifComparators); callOnCleanup(mNotifSections); for (int i = 0; i < mNotifSections.size(); i++) { mNotifSections.get(i).getSectioner().onCleanup(); } if (mNotifStabilityManager != null) { callOnCleanup(List.of(mNotifStabilityManager)); Loading @@ -777,7 +782,9 @@ public class ShadeListBuilder implements Dumpable { private final Comparator<ListEntry> mTopLevelComparator = (o1, o2) -> { int cmp = Integer.compare(o1.getSection(), o2.getSection()); int cmp = Integer.compare( requireNonNull(o1.getSection()).getIndex(), requireNonNull(o2.getSection()).getIndex()); if (cmp == 0) { for (int i = 0; i < mNotifComparators.size(); i++) { Loading Loading @@ -855,45 +862,41 @@ public class ShadeListBuilder implements Dumpable { return null; } private Pair<NotifSection, Integer> applySections(ListEntry entry) { Pair<NotifSection, Integer> sectionWithIndex = findSection(entry); private NotifSection applySections(ListEntry entry) { final NotifSection newSection = findSection(entry); final ListAttachState prevAttachState = entry.getPreviousAttachState(); NotifSection finalSection = newSection; // are we changing sections of this entry? if (mNotifStabilityManager != null && prevAttachState.getParent() != null && (sectionWithIndex.first != prevAttachState.getSection() || sectionWithIndex.second != prevAttachState.getSectionIndex())) { && newSection != prevAttachState.getSection()) { // are section changes allowed? if (!mNotifStabilityManager.isSectionChangeAllowed( entry.getRepresentativeEntry())) { entry.getAttachState().getSuppressedChanges().setSection( sectionWithIndex.first); entry.getAttachState().getSuppressedChanges().setSectionIndex( sectionWithIndex.second); if (!mNotifStabilityManager.isSectionChangeAllowed(entry.getRepresentativeEntry())) { // record the section that we wanted to change to entry.getAttachState().getSuppressedChanges().setSection(newSection); // keep the previous section sectionWithIndex = new Pair( prevAttachState.getSection(), prevAttachState.getSectionIndex()); finalSection = prevAttachState.getSection(); } } entry.getAttachState().setSection(sectionWithIndex.first); entry.getAttachState().setSectionIndex(sectionWithIndex.second); entry.getAttachState().setSection(finalSection); return sectionWithIndex; return finalSection; } private Pair<NotifSection, Integer> findSection(ListEntry entry) { @NonNull private NotifSection findSection(ListEntry entry) { for (int i = 0; i < mNotifSections.size(); i++) { NotifSection sectioner = mNotifSections.get(i); if (sectioner.isInSection(entry)) { return new Pair<>(sectioner, i); NotifSection section = mNotifSections.get(i); if (section.getSectioner().isInSection(entry)) { return section; } } return new Pair<>(sDefaultSection, mNotifSections.size()); throw new RuntimeException("Missing default sectioner!"); } private void rebuildListIfBefore(@PipelineState.StateName int state) { Loading Loading @@ -963,15 +966,15 @@ public class ShadeListBuilder implements Dumpable { void onRenderList(@NonNull List<ListEntry> entries); } private static final NotifSection sDefaultSection = new NotifSection("UnknownSection") { private static final NotifSectioner DEFAULT_SECTIONER = new NotifSectioner("UnknownSection") { @Override public boolean isInSection(ListEntry entry) { return true; } }; private static final String TAG = "ShadeListBuilder"; private static final int MIN_CHILDREN_FOR_GROUP = 2; private static final String TAG = "ShadeListBuilder"; }