Merge "Enforce contigious but unordered buckets" into tm-dev
This commit is contained in:
@@ -93,6 +93,7 @@ public class ShadeListBuilder implements Dumpable {
|
|||||||
private final NotificationInteractionTracker mInteractionTracker;
|
private final NotificationInteractionTracker mInteractionTracker;
|
||||||
private final DumpManager mDumpManager;
|
private final DumpManager mDumpManager;
|
||||||
// used exclusivly by ShadeListBuilder#notifySectionEntriesUpdated
|
// used exclusivly by ShadeListBuilder#notifySectionEntriesUpdated
|
||||||
|
// TODO replace temp with collection pool for readability
|
||||||
private final ArrayList<ListEntry> mTempSectionMembers = new ArrayList<>();
|
private final ArrayList<ListEntry> mTempSectionMembers = new ArrayList<>();
|
||||||
private final boolean mAlwaysLogList;
|
private final boolean mAlwaysLogList;
|
||||||
|
|
||||||
@@ -230,13 +231,7 @@ public class ShadeListBuilder implements Dumpable {
|
|||||||
mPipelineState.requireState(STATE_IDLE);
|
mPipelineState.requireState(STATE_IDLE);
|
||||||
|
|
||||||
mNotifSections.clear();
|
mNotifSections.clear();
|
||||||
NotifSectioner lastSection = null;
|
|
||||||
for (NotifSectioner sectioner : sectioners) {
|
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 NotifSection section = new NotifSection(sectioner, mNotifSections.size());
|
||||||
final NotifComparator sectionComparator = section.getComparator();
|
final NotifComparator sectionComparator = section.getComparator();
|
||||||
mNotifSections.add(section);
|
mNotifSections.add(section);
|
||||||
@@ -244,10 +239,23 @@ public class ShadeListBuilder implements Dumpable {
|
|||||||
if (sectionComparator != null) {
|
if (sectionComparator != null) {
|
||||||
sectionComparator.setInvalidationListener(this::onNotifComparatorInvalidated);
|
sectionComparator.setInvalidationListener(this::onNotifComparatorInvalidated);
|
||||||
}
|
}
|
||||||
lastSection = sectioner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mNotifSections.add(new NotifSection(DEFAULT_SECTIONER, mNotifSections.size()));
|
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) {
|
void setNotifStabilityManager(@NonNull NotifStabilityManager notifStabilityManager) {
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class NodeSpecBuilder(
|
|||||||
|
|
||||||
var currentSection: NotifSection? = null
|
var currentSection: NotifSection? = null
|
||||||
val prevSections = mutableSetOf<NotifSection?>()
|
val prevSections = mutableSetOf<NotifSection?>()
|
||||||
var lastSection: NotifSection? = null
|
|
||||||
val showHeaders = sectionHeaderVisibilityProvider.sectionHeadersVisible
|
val showHeaders = sectionHeaderVisibilityProvider.sectionHeadersVisible
|
||||||
val sectionOrder = mutableListOf<NotifSection?>()
|
val sectionOrder = mutableListOf<NotifSection?>()
|
||||||
val sectionHeaders = mutableMapOf<NotifSection?, NodeController?>()
|
val sectionHeaders = mutableMapOf<NotifSection?, NodeController?>()
|
||||||
@@ -65,15 +64,6 @@ class NodeSpecBuilder(
|
|||||||
|
|
||||||
for (entry in notifList) {
|
for (entry in notifList) {
|
||||||
val section = entry.section!!
|
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)) {
|
if (prevSections.contains(section)) {
|
||||||
throw java.lang.RuntimeException("Section ${section.label} has been duplicated")
|
throw java.lang.RuntimeException("Section ${section.label} has been duplicated")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
@Test
|
||||||
public void testStabilizeGroupsDelayedSummaryRendersAllNotifsTopLevel() {
|
public void testStabilizeGroupsDelayedSummaryRendersAllNotifsTopLevel() {
|
||||||
// GIVEN group children posted without a summary
|
// GIVEN group children posted without a summary
|
||||||
@@ -2189,7 +2217,11 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageSectioner(String pkg) {
|
PackageSectioner(String pkg) {
|
||||||
super("PackageSection_" + pkg, 0);
|
this(pkg, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageSectioner(String pkg, int bucket) {
|
||||||
|
super("PackageSection_" + pkg, bucket);
|
||||||
mPackages = List.of(pkg);
|
mPackages = List.of(pkg);
|
||||||
mComparator = null;
|
mComparator = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user