Merge "Condense NotifSection + index into a wrapper class"
This commit is contained in:
@@ -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]
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -70,7 +68,6 @@ data class ListAttachState private constructor(
|
||||
fun reset() {
|
||||
parent = null
|
||||
section = null
|
||||
sectionIndex = -1
|
||||
excludingFilter = null
|
||||
promoter = null
|
||||
suppressedChanges.reset()
|
||||
@@ -82,7 +79,6 @@ data class ListAttachState private constructor(
|
||||
return ListAttachState(
|
||||
null,
|
||||
null,
|
||||
-1,
|
||||
null,
|
||||
null,
|
||||
SuppressedAttachState.create())
|
||||
|
||||
@@ -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) {
|
||||
@@ -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(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -119,6 +121,8 @@ public class ShadeListBuilder implements Dumpable {
|
||||
mLogger = logger;
|
||||
mInteractionTracker = interactionTracker;
|
||||
dumpManager.registerDumpable(TAG, this);
|
||||
|
||||
setSectioners(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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) {
|
||||
@@ -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());
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
@@ -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++) {
|
||||
@@ -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) {
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.systemui.statusbar.notification.collection
|
||||
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
|
||||
|
||||
/**
|
||||
* Stores the suppressed state that [ShadeListBuilder] assigned to this [ListEntry] before the
|
||||
@@ -33,22 +33,19 @@ data class SuppressedAttachState private constructor(
|
||||
* The assigned section for this ListEntry. If the child of the group, this will be the
|
||||
* parent's section. Null if not attached to the list.
|
||||
*/
|
||||
var section: NotifSection?,
|
||||
var sectionIndex: Int
|
||||
var section: NotifSection?
|
||||
) {
|
||||
|
||||
/** Copies the state of another instance. */
|
||||
fun clone(other: SuppressedAttachState) {
|
||||
parent = other.parent
|
||||
section = other.section
|
||||
sectionIndex = other.sectionIndex
|
||||
}
|
||||
|
||||
/** Resets back to a "clean" state (the same as created by the factory method) */
|
||||
fun reset() {
|
||||
parent = null
|
||||
section = null
|
||||
sectionIndex = -1
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -56,8 +53,7 @@ data class SuppressedAttachState private constructor(
|
||||
fun create(): SuppressedAttachState {
|
||||
return SuppressedAttachState(
|
||||
null,
|
||||
null,
|
||||
-1)
|
||||
null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.android.systemui.statusbar.notification.collection.ListEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
|
||||
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.notifcollection.NotifLifetimeExtender;
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor;
|
||||
|
||||
@@ -83,8 +83,8 @@ public class AppOpsCoordinator implements Coordinator {
|
||||
|
||||
}
|
||||
|
||||
public NotifSection getSection() {
|
||||
return mNotifSection;
|
||||
public NotifSectioner getSectioner() {
|
||||
return mNotifSectioner;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +179,7 @@ public class AppOpsCoordinator implements Coordinator {
|
||||
/**
|
||||
* Puts foreground service notifications into its own section.
|
||||
*/
|
||||
private final NotifSection mNotifSection = new NotifSection("ForegroundService") {
|
||||
private final NotifSectioner mNotifSectioner = new NotifSectioner("ForegroundService") {
|
||||
@Override
|
||||
public boolean isInSection(ListEntry entry) {
|
||||
NotificationEntry notificationEntry = entry.getRepresentativeEntry();
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.android.systemui.statusbar.notification.collection.ListEntry
|
||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry
|
||||
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.people.PeopleNotificationIdentifier
|
||||
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_NON_PERSON
|
||||
import javax.inject.Inject
|
||||
@@ -42,7 +42,7 @@ class ConversationCoordinator @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private val mNotifSection: NotifSection = object : NotifSection("People") {
|
||||
val sectioner = object : NotifSectioner("People") {
|
||||
override fun isInSection(entry: ListEntry): Boolean {
|
||||
return isConversation(entry.representativeEntry!!)
|
||||
}
|
||||
@@ -52,10 +52,6 @@ class ConversationCoordinator @Inject constructor(
|
||||
pipeline.addPromoter(notificationPromoter)
|
||||
}
|
||||
|
||||
fun getSection(): NotifSection {
|
||||
return mNotifSection
|
||||
}
|
||||
|
||||
private fun isConversation(entry: NotificationEntry): Boolean =
|
||||
peopleNotificationIdentifier.getPeopleNotificationType(entry.sbn, entry.ranking) !=
|
||||
TYPE_NON_PERSON
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.android.systemui.statusbar.notification.collection.ListEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
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.notifcollection.NotifCollectionListener;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
|
||||
import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinder;
|
||||
@@ -88,8 +88,8 @@ public class HeadsUpCoordinator implements Coordinator {
|
||||
pipeline.addNotificationLifetimeExtender(mLifetimeExtender);
|
||||
}
|
||||
|
||||
public NotifSection getSection() {
|
||||
return mNotifSection;
|
||||
public NotifSectioner getSectioner() {
|
||||
return mNotifSectioner;
|
||||
}
|
||||
|
||||
private void onHeadsUpViewBound(NotificationEntry entry) {
|
||||
@@ -191,7 +191,7 @@ public class HeadsUpCoordinator implements Coordinator {
|
||||
}
|
||||
};
|
||||
|
||||
private final NotifSection mNotifSection = new NotifSection("HeadsUp") {
|
||||
private final NotifSectioner mNotifSectioner = new NotifSectioner("HeadsUp") {
|
||||
@Override
|
||||
public boolean isInSection(ListEntry entry) {
|
||||
return isCurrentlyShowingHun(entry);
|
||||
@@ -207,7 +207,7 @@ public class HeadsUpCoordinator implements Coordinator {
|
||||
endNotifLifetimeExtension();
|
||||
mCurrentHun = newHUN;
|
||||
mNotifPromoter.invalidateList();
|
||||
mNotifSection.invalidateList();
|
||||
mNotifSectioner.invalidateList();
|
||||
}
|
||||
if (!isHeadsUp) {
|
||||
mHeadsUpViewBinder.unbindHeadsUpView(entry);
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
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.Pluggable;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
|
||||
@@ -41,7 +41,7 @@ import javax.inject.Inject;
|
||||
public class NotifCoordinators implements Dumpable {
|
||||
private static final String TAG = "NotifCoordinators";
|
||||
private final List<Coordinator> mCoordinators = new ArrayList<>();
|
||||
private final List<NotifSection> mOrderedSections = new ArrayList<>();
|
||||
private final List<NotifSectioner> mOrderedSections = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates all the coordinators.
|
||||
@@ -81,12 +81,12 @@ public class NotifCoordinators implements Dumpable {
|
||||
// Manually add Ordered Sections
|
||||
// HeadsUp > FGS > People > Alerting > Silent > Unknown/Default
|
||||
if (featureFlags.isNewNotifPipelineRenderingEnabled()) {
|
||||
mOrderedSections.add(headsUpCoordinator.getSection()); // HeadsUp
|
||||
mOrderedSections.add(headsUpCoordinator.getSectioner()); // HeadsUp
|
||||
}
|
||||
mOrderedSections.add(appOpsCoordinator.getSection()); // ForegroundService
|
||||
mOrderedSections.add(conversationCoordinator.getSection()); // People
|
||||
mOrderedSections.add(rankingCoordinator.getAlertingSection()); // Alerting
|
||||
mOrderedSections.add(rankingCoordinator.getSilentSection()); // Silent
|
||||
mOrderedSections.add(appOpsCoordinator.getSectioner()); // ForegroundService
|
||||
mOrderedSections.add(conversationCoordinator.getSectioner()); // People
|
||||
mOrderedSections.add(rankingCoordinator.getAlertingSectioner()); // Alerting
|
||||
mOrderedSections.add(rankingCoordinator.getSilentSectioner()); // Silent
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public class NotifCoordinators implements Dumpable {
|
||||
pw.println("\t" + c.getClass());
|
||||
}
|
||||
|
||||
for (NotifSection s : mOrderedSections) {
|
||||
for (NotifSectioner s : mOrderedSections) {
|
||||
pw.println("\t" + s.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.android.systemui.statusbar.notification.collection.ListEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
|
||||
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.provider.HighPriorityProvider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -57,22 +57,22 @@ public class RankingCoordinator implements Coordinator {
|
||||
pipeline.addPreGroupFilter(mDozingFilter);
|
||||
}
|
||||
|
||||
public NotifSection getAlertingSection() {
|
||||
return mAlertingNotifSection;
|
||||
public NotifSectioner getAlertingSectioner() {
|
||||
return mAlertingNotifSectioner;
|
||||
}
|
||||
|
||||
public NotifSection getSilentSection() {
|
||||
return mSilentNotifSection;
|
||||
public NotifSectioner getSilentSectioner() {
|
||||
return mSilentNotifSectioner;
|
||||
}
|
||||
|
||||
private final NotifSection mAlertingNotifSection = new NotifSection("Alerting") {
|
||||
private final NotifSectioner mAlertingNotifSectioner = new NotifSectioner("Alerting") {
|
||||
@Override
|
||||
public boolean isInSection(ListEntry entry) {
|
||||
return mHighPriorityProvider.isHighPriority(entry);
|
||||
}
|
||||
};
|
||||
|
||||
private final NotifSection mSilentNotifSection = new NotifSection("Silent") {
|
||||
private final NotifSectioner mSilentNotifSectioner = new NotifSectioner("Silent") {
|
||||
@Override
|
||||
public boolean isInSection(ListEntry entry) {
|
||||
return !mHighPriorityProvider.isHighPriority(entry);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.notification.collection.listbuilder
|
||||
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
|
||||
|
||||
data class NotifSection(
|
||||
val sectioner: NotifSectioner,
|
||||
val index: Int
|
||||
) {
|
||||
val label: String
|
||||
get() = "Section($index, \"${sectioner.name}\")"
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import com.android.systemui.statusbar.notification.collection.GroupEntry
|
||||
import com.android.systemui.statusbar.notification.collection.ListEntry
|
||||
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 javax.inject.Inject
|
||||
|
||||
class ShadeListBuilderLogger @Inject constructor(
|
||||
@@ -211,21 +210,17 @@ class ShadeListBuilderLogger @Inject constructor(
|
||||
fun logSectionChanged(
|
||||
buildId: Int,
|
||||
prevSection: NotifSection?,
|
||||
prevIndex: Int,
|
||||
newSection: NotifSection?,
|
||||
newIndex: Int
|
||||
newSection: NotifSection?
|
||||
) {
|
||||
buffer.log(TAG, INFO, {
|
||||
long1 = buildId.toLong()
|
||||
str1 = prevSection?.name
|
||||
int1 = prevIndex
|
||||
str2 = newSection?.name
|
||||
int2 = newIndex
|
||||
str1 = prevSection?.label
|
||||
str2 = newSection?.label
|
||||
}, {
|
||||
if (str1 == null) {
|
||||
"(Build $long1) Section assigned: '$str2' (#$int2)"
|
||||
"(Build $long1) Section assigned: $str2"
|
||||
} else {
|
||||
"(Build $long1) Section changed: '$str1' (#$int1) -> '$str2' (#$int2)"
|
||||
"(Build $long1) Section changed: $str1 -> $str2"
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -233,17 +228,14 @@ class ShadeListBuilderLogger @Inject constructor(
|
||||
fun logSectionChangeSuppressed(
|
||||
buildId: Int,
|
||||
suppressedSection: NotifSection?,
|
||||
suppressedSectionIndex: Int,
|
||||
assignedSection: NotifSection?
|
||||
) {
|
||||
buffer.log(TAG, INFO, {
|
||||
long1 = buildId.toLong()
|
||||
str1 = suppressedSection?.name
|
||||
int1 = suppressedSectionIndex
|
||||
str2 = assignedSection?.name
|
||||
str1 = suppressedSection?.label
|
||||
str2 = assignedSection?.label
|
||||
}, {
|
||||
"(Build $long1) Section change suppressed: '$str1' (#$int1). " +
|
||||
"Keeping section: '$str2'"
|
||||
"(Build $long1) Suppressing section change to $str1 (staying at $str2)"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder;
|
||||
/**
|
||||
* Pluggable for participating in notif sectioning. See {@link ShadeListBuilder#setSections}.
|
||||
*/
|
||||
public abstract class NotifSection extends Pluggable<NotifSection> {
|
||||
protected NotifSection(String name) {
|
||||
public abstract class NotifSectioner extends Pluggable<NotifSectioner> {
|
||||
protected NotifSectioner(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class NotificationEntryBuilder {
|
||||
|
||||
/* ListEntry properties */
|
||||
private GroupEntry mParent;
|
||||
private int mSection = -1;
|
||||
|
||||
/* If set, use this creation time instead of mClock.uptimeMillis */
|
||||
private long mCreationTime = -1;
|
||||
@@ -68,7 +67,6 @@ public class NotificationEntryBuilder {
|
||||
mRankingBuilder = new RankingBuilder(source.getRanking());
|
||||
|
||||
mParent = source.getParent();
|
||||
mSection = source.getSection();
|
||||
mCreationTime = source.getCreationTime();
|
||||
}
|
||||
|
||||
@@ -104,7 +102,6 @@ public class NotificationEntryBuilder {
|
||||
|
||||
/* ListEntry properties */
|
||||
entry.setParent(mParent);
|
||||
entry.getAttachState().setSectionIndex(mSection);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -116,14 +113,6 @@ public class NotificationEntryBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the section.
|
||||
*/
|
||||
public NotificationEntryBuilder setSection(int section) {
|
||||
mSection = section;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SBN directly. If set, causes all calls to delegated SbnBuilder methods to be
|
||||
* ignored.
|
||||
|
||||
@@ -35,6 +35,8 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
@@ -46,6 +48,7 @@ import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.statusbar.NotificationInteractionTracker;
|
||||
import com.android.systemui.statusbar.notification.collection.ShadeListBuilder.OnRenderListListener;
|
||||
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;
|
||||
@@ -54,7 +57,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.notifcollection.CollectionReadyForBuildListener;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
@@ -71,7 +74,6 @@ import org.mockito.Spy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -496,7 +498,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
assertTrue(entry.hasFinishedInitialization());
|
||||
|
||||
// WHEN the pipeline is kicked off
|
||||
mReadyForBuildListener.onBuildList(Arrays.asList(entry));
|
||||
mReadyForBuildListener.onBuildList(singletonList(entry));
|
||||
|
||||
// THEN the entry's initialization time is reset
|
||||
assertFalse(entry.hasFinishedInitialization());
|
||||
@@ -609,13 +611,18 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
// GIVEN a filter that removes all PACKAGE_4 notifs and sections that divide
|
||||
// notifs based on package name
|
||||
mListBuilder.addPreGroupFilter(new PackageFilter(PACKAGE_4));
|
||||
final NotifSection pkg1Section = spy(new PackageSection(PACKAGE_1));
|
||||
final NotifSection pkg2Section = spy(new PackageSection(PACKAGE_2));
|
||||
final NotifSectioner pkg1Sectioner = spy(new PackageSectioner(PACKAGE_1));
|
||||
final NotifSectioner pkg2Sectioner = spy(new PackageSectioner(PACKAGE_2));
|
||||
// NOTE: no package 3 section explicitly added, so notifs with package 3 will get set by
|
||||
// ShadeListBuilder's sDefaultSection which will demote it to the last section
|
||||
final NotifSection pkg4Section = spy(new PackageSection(PACKAGE_4));
|
||||
final NotifSection pkg5Section = spy(new PackageSection(PACKAGE_5));
|
||||
mListBuilder.setSections(Arrays.asList(pkg1Section, pkg2Section, pkg4Section, pkg5Section));
|
||||
final NotifSectioner pkg4Sectioner = spy(new PackageSectioner(PACKAGE_4));
|
||||
final NotifSectioner pkg5Sectioner = spy(new PackageSectioner(PACKAGE_5));
|
||||
mListBuilder.setSectioners(
|
||||
Arrays.asList(pkg1Sectioner, pkg2Sectioner, pkg4Sectioner, pkg5Sectioner));
|
||||
|
||||
final NotifSection pkg1Section = new NotifSection(pkg1Sectioner, 0);
|
||||
final NotifSection pkg2Section = new NotifSection(pkg2Sectioner, 1);
|
||||
final NotifSection pkg5Section = new NotifSection(pkg5Sectioner, 3);
|
||||
|
||||
// WHEN we build a list with different packages
|
||||
addNotif(0, PACKAGE_4);
|
||||
@@ -648,72 +655,61 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
|
||||
// THEN the first section (pkg1Section) is called on all top level elements (but
|
||||
// no children and no entries that were filtered out)
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(1));
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(2));
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(3));
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(7));
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(8));
|
||||
verify(pkg1Section).isInSection(mEntrySet.get(9));
|
||||
verify(pkg1Section).isInSection(mBuiltList.get(3));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(1));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(2));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(3));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(7));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(8));
|
||||
verify(pkg1Sectioner).isInSection(mEntrySet.get(9));
|
||||
verify(pkg1Sectioner).isInSection(mBuiltList.get(3));
|
||||
|
||||
verify(pkg1Section, never()).isInSection(mEntrySet.get(0));
|
||||
verify(pkg1Section, never()).isInSection(mEntrySet.get(4));
|
||||
verify(pkg1Section, never()).isInSection(mEntrySet.get(5));
|
||||
verify(pkg1Section, never()).isInSection(mEntrySet.get(6));
|
||||
verify(pkg1Section, never()).isInSection(mEntrySet.get(10));
|
||||
verify(pkg1Sectioner, never()).isInSection(mEntrySet.get(0));
|
||||
verify(pkg1Sectioner, never()).isInSection(mEntrySet.get(4));
|
||||
verify(pkg1Sectioner, never()).isInSection(mEntrySet.get(5));
|
||||
verify(pkg1Sectioner, never()).isInSection(mEntrySet.get(6));
|
||||
verify(pkg1Sectioner, never()).isInSection(mEntrySet.get(10));
|
||||
|
||||
// THEN the last section (pkg5Section) is not called on any of the entries that were
|
||||
// filtered or already in a section
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(0));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(1));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(2));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(4));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(5));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(6));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(7));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(8));
|
||||
verify(pkg5Section, never()).isInSection(mEntrySet.get(10));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(0));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(1));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(2));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(4));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(5));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(6));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(7));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(8));
|
||||
verify(pkg5Sectioner, never()).isInSection(mEntrySet.get(10));
|
||||
|
||||
verify(pkg5Section).isInSection(mEntrySet.get(3));
|
||||
verify(pkg5Section).isInSection(mEntrySet.get(9));
|
||||
verify(pkg5Sectioner).isInSection(mEntrySet.get(3));
|
||||
verify(pkg5Sectioner).isInSection(mEntrySet.get(9));
|
||||
|
||||
// THEN the correct section is assigned for entries in pkg1Section
|
||||
assertEquals(pkg1Section, mEntrySet.get(2).getNotifSection());
|
||||
assertEquals(0, mEntrySet.get(2).getSection());
|
||||
assertEquals(pkg1Section, mEntrySet.get(7).getNotifSection());
|
||||
assertEquals(0, mEntrySet.get(7).getSection());
|
||||
assertEquals(pkg1Section, mEntrySet.get(2).getSection());
|
||||
assertEquals(pkg1Section, mEntrySet.get(7).getSection());
|
||||
|
||||
// THEN the correct section is assigned for entries in pkg2Section
|
||||
assertEquals(pkg2Section, mEntrySet.get(1).getNotifSection());
|
||||
assertEquals(1, mEntrySet.get(1).getSection());
|
||||
assertEquals(pkg2Section, mEntrySet.get(8).getNotifSection());
|
||||
assertEquals(1, mEntrySet.get(8).getSection());
|
||||
assertEquals(pkg2Section, mBuiltList.get(3).getNotifSection());
|
||||
assertEquals(1, mBuiltList.get(3).getSection());
|
||||
assertEquals(pkg2Section, mEntrySet.get(1).getSection());
|
||||
assertEquals(pkg2Section, mEntrySet.get(8).getSection());
|
||||
assertEquals(pkg2Section, mBuiltList.get(3).getSection());
|
||||
|
||||
// THEN no section was assigned to entries in pkg4Section (since they were filtered)
|
||||
assertEquals(null, mEntrySet.get(0).getNotifSection());
|
||||
assertEquals(-1, mEntrySet.get(0).getSection());
|
||||
assertEquals(null, mEntrySet.get(10).getNotifSection());
|
||||
assertEquals(-1, mEntrySet.get(10).getSection());
|
||||
|
||||
assertNull(mEntrySet.get(0).getSection());
|
||||
assertNull(mEntrySet.get(10).getSection());
|
||||
|
||||
// THEN the correct section is assigned for entries in pkg5Section
|
||||
assertEquals(pkg5Section, mEntrySet.get(9).getNotifSection());
|
||||
assertEquals(3, mEntrySet.get(9).getSection());
|
||||
assertEquals(pkg5Section, mEntrySet.get(9).getSection());
|
||||
|
||||
// THEN the children entries are assigned the same section as its parent
|
||||
assertEquals(mBuiltList.get(3).getNotifSection(), child(5).entry.getNotifSection());
|
||||
assertEquals(mBuiltList.get(3).getSection(), child(5).entry.getSection());
|
||||
assertEquals(mBuiltList.get(3).getNotifSection(), child(6).entry.getNotifSection());
|
||||
assertEquals(mBuiltList.get(3).getSection(), child(6).entry.getSection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotifUsesDefaultSection() {
|
||||
// GIVEN a Section for Package2
|
||||
final NotifSection pkg2Section = spy(new PackageSection(PACKAGE_2));
|
||||
mListBuilder.setSections(Arrays.asList(pkg2Section));
|
||||
final NotifSectioner pkg2Section = spy(new PackageSectioner(PACKAGE_2));
|
||||
mListBuilder.setSectioners(singletonList(pkg2Section));
|
||||
|
||||
// WHEN we build a list with pkg1 and pkg2 packages
|
||||
addNotif(0, PACKAGE_1);
|
||||
@@ -727,8 +723,8 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
);
|
||||
|
||||
// THEN the entry that didn't have an explicit section gets assigned the DefaultSection
|
||||
assertEquals(1, notif(0).entry.getSection());
|
||||
assertNotNull(notif(0).entry.getNotifSection());
|
||||
assertNotNull(notif(0).entry.getSection());
|
||||
assertEquals(1, notif(0).entry.getSectionIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -763,15 +759,15 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
// GIVEN a bunch of registered listeners and pluggables
|
||||
NotifFilter preGroupFilter = spy(new PackageFilter(PACKAGE_1));
|
||||
NotifPromoter promoter = spy(new IdPromoter(3));
|
||||
NotifSection section = spy(new PackageSection(PACKAGE_1));
|
||||
NotifSectioner section = spy(new PackageSectioner(PACKAGE_1));
|
||||
NotifComparator comparator = spy(new HypeComparator(PACKAGE_4));
|
||||
NotifFilter preRenderFilter = spy(new PackageFilter(PACKAGE_5));
|
||||
mListBuilder.addPreGroupFilter(preGroupFilter);
|
||||
mListBuilder.addOnBeforeTransformGroupsListener(mOnBeforeTransformGroupsListener);
|
||||
mListBuilder.addPromoter(promoter);
|
||||
mListBuilder.addOnBeforeSortListener(mOnBeforeSortListener);
|
||||
mListBuilder.setComparators(Collections.singletonList(comparator));
|
||||
mListBuilder.setSections(Arrays.asList(section));
|
||||
mListBuilder.setComparators(singletonList(comparator));
|
||||
mListBuilder.setSectioners(singletonList(section));
|
||||
mListBuilder.addOnBeforeFinalizeFilterListener(mOnBeforeFinalizeFilterListener);
|
||||
mListBuilder.addFinalizeFilter(preRenderFilter);
|
||||
mListBuilder.addOnBeforeRenderListListener(mOnBeforeRenderListListener);
|
||||
@@ -821,13 +817,13 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
// GIVEN a variety of pluggables
|
||||
NotifFilter packageFilter = new PackageFilter(PACKAGE_1);
|
||||
NotifPromoter idPromoter = new IdPromoter(4);
|
||||
NotifSection section = new PackageSection(PACKAGE_1);
|
||||
NotifSectioner section = new PackageSectioner(PACKAGE_1);
|
||||
NotifComparator hypeComparator = new HypeComparator(PACKAGE_2);
|
||||
|
||||
mListBuilder.addPreGroupFilter(packageFilter);
|
||||
mListBuilder.addPromoter(idPromoter);
|
||||
mListBuilder.setSections(Arrays.asList(section));
|
||||
mListBuilder.setComparators(Collections.singletonList(hypeComparator));
|
||||
mListBuilder.setSectioners(singletonList(section));
|
||||
mListBuilder.setComparators(singletonList(hypeComparator));
|
||||
|
||||
// GIVEN a set of random notifs
|
||||
addNotif(0, PACKAGE_1);
|
||||
@@ -973,7 +969,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
RecordingOnBeforeSortListener listener =
|
||||
new RecordingOnBeforeSortListener();
|
||||
mListBuilder.addOnBeforeSortListener(listener);
|
||||
mListBuilder.setComparators(Arrays.asList(new HypeComparator(PACKAGE_3)));
|
||||
mListBuilder.setComparators(singletonList(new HypeComparator(PACKAGE_3)));
|
||||
|
||||
// GIVEN some new notifs out of order
|
||||
addNotif(0, PACKAGE_1);
|
||||
@@ -1093,7 +1089,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
NotifComparator comparator = new HypeComparator(PACKAGE_5);
|
||||
OnBeforeRenderListListener listener =
|
||||
(list) -> comparator.invalidateList();
|
||||
mListBuilder.setComparators(Collections.singletonList(comparator));
|
||||
mListBuilder.setComparators(singletonList(comparator));
|
||||
mListBuilder.addOnBeforeRenderListListener(listener);
|
||||
|
||||
// WHEN we try to run the pipeline and the comparator is invalidated
|
||||
@@ -1420,10 +1416,10 @@ public class ShadeListBuilderTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
/** Represents a section for the passed pkg */
|
||||
private static class PackageSection extends NotifSection {
|
||||
private static class PackageSectioner extends NotifSectioner {
|
||||
private final String mPackage;
|
||||
|
||||
PackageSection(String pkg) {
|
||||
PackageSectioner(String pkg) {
|
||||
super("PackageSection_" + pkg);
|
||||
mPackage = pkg;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -37,7 +35,6 @@ import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -48,8 +45,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
@@ -61,8 +57,6 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
@@ -78,7 +72,7 @@ public class AppOpsCoordinatorTest extends SysuiTestCase {
|
||||
private AppOpsCoordinator mAppOpsCoordinator;
|
||||
private NotifFilter mForegroundFilter;
|
||||
private NotifLifetimeExtender mForegroundNotifLifetimeExtender;
|
||||
private NotifSection mFgsSection;
|
||||
private NotifSectioner mFgsSection;
|
||||
|
||||
private FakeSystemClock mClock = new FakeSystemClock();
|
||||
private FakeExecutor mExecutor = new FakeExecutor(mClock);
|
||||
@@ -111,7 +105,7 @@ public class AppOpsCoordinatorTest extends SysuiTestCase {
|
||||
lifetimeExtenderCaptor.capture());
|
||||
mForegroundNotifLifetimeExtender = lifetimeExtenderCaptor.getValue();
|
||||
|
||||
mFgsSection = mAppOpsCoordinator.getSection();
|
||||
mFgsSection = mAppOpsCoordinator.getSectioner();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
|
||||
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.people.PeopleNotificationIdentifier
|
||||
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_PERSON
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -45,7 +45,7 @@ import org.mockito.Mockito.`when` as whenever
|
||||
class ConversationCoordinatorTest : SysuiTestCase() {
|
||||
// captured listeners and pluggables:
|
||||
private lateinit var promoter: NotifPromoter
|
||||
private lateinit var peopleSection: NotifSection
|
||||
private lateinit var peopleSectioner: NotifSectioner
|
||||
|
||||
@Mock
|
||||
private lateinit var pipeline: NotifPipeline
|
||||
@@ -70,7 +70,7 @@ class ConversationCoordinatorTest : SysuiTestCase() {
|
||||
verify(pipeline).addPromoter(notifPromoterCaptor.capture())
|
||||
promoter = notifPromoterCaptor.value
|
||||
|
||||
peopleSection = coordinator.getSection()
|
||||
peopleSectioner = coordinator.sectioner
|
||||
|
||||
entry = NotificationEntryBuilder().setChannel(channel).build()
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class ConversationCoordinatorTest : SysuiTestCase() {
|
||||
entry.sbn, entry.ranking)).thenReturn(TYPE_PERSON)
|
||||
|
||||
// only put people notifications in this section
|
||||
assertTrue(peopleSection.isInSection(entry))
|
||||
assertFalse(peopleSection.isInSection(NotificationEntryBuilder().build()))
|
||||
assertTrue(peopleSectioner.isInSection(entry))
|
||||
assertFalse(peopleSectioner.isInSection(NotificationEntryBuilder().build()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
|
||||
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.notifcollection.NotifCollectionListener;
|
||||
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
|
||||
import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinder;
|
||||
@@ -64,7 +64,7 @@ public class HeadsUpCoordinatorTest extends SysuiTestCase {
|
||||
private NotifPromoter mNotifPromoter;
|
||||
private NotifLifetimeExtender mNotifLifetimeExtender;
|
||||
private OnHeadsUpChangedListener mOnHeadsUpChangedListener;
|
||||
private NotifSection mNotifSection;
|
||||
private NotifSectioner mNotifSectioner;
|
||||
|
||||
@Mock private NotifPipeline mNotifPipeline;
|
||||
@Mock private HeadsUpManager mHeadsUpManager;
|
||||
@@ -111,7 +111,7 @@ public class HeadsUpCoordinatorTest extends SysuiTestCase {
|
||||
mNotifLifetimeExtender = notifLifetimeExtenderCaptor.getValue();
|
||||
mOnHeadsUpChangedListener = headsUpChangedListenerCaptor.getValue();
|
||||
|
||||
mNotifSection = mCoordinator.getSection();
|
||||
mNotifSectioner = mCoordinator.getSectioner();
|
||||
mNotifLifetimeExtender.setCallback(mEndLifetimeExtension);
|
||||
mEntry = new NotificationEntryBuilder().build();
|
||||
}
|
||||
@@ -132,8 +132,8 @@ public class HeadsUpCoordinatorTest extends SysuiTestCase {
|
||||
setCurrentHUN(mEntry);
|
||||
|
||||
// THEN only section the current HUN, mEntry
|
||||
assertTrue(mNotifSection.isInSection(mEntry));
|
||||
assertFalse(mNotifSection.isInSection(new NotificationEntryBuilder().build()));
|
||||
assertTrue(mNotifSectioner.isInSection(mEntry));
|
||||
assertFalse(mNotifSectioner.isInSection(new NotificationEntryBuilder().build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
|
||||
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
|
||||
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.provider.HighPriorityProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -61,8 +61,8 @@ public class RankingCoordinatorTest extends SysuiTestCase {
|
||||
private NotifFilter mCapturedSuspendedFilter;
|
||||
private NotifFilter mCapturedDozingFilter;
|
||||
|
||||
private NotifSection mAlertingSection;
|
||||
private NotifSection mSilentSection;
|
||||
private NotifSectioner mAlertingSectioner;
|
||||
private NotifSectioner mSilentSectioner;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -76,8 +76,8 @@ public class RankingCoordinatorTest extends SysuiTestCase {
|
||||
mCapturedSuspendedFilter = mNotifFilterCaptor.getAllValues().get(0);
|
||||
mCapturedDozingFilter = mNotifFilterCaptor.getAllValues().get(1);
|
||||
|
||||
mAlertingSection = rankingCoordinator.getAlertingSection();
|
||||
mSilentSection = rankingCoordinator.getSilentSection();
|
||||
mAlertingSectioner = rankingCoordinator.getAlertingSectioner();
|
||||
mSilentSectioner = rankingCoordinator.getSilentSectioner();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,8 +146,8 @@ public class RankingCoordinatorTest extends SysuiTestCase {
|
||||
when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(true);
|
||||
|
||||
// THEN entry is in the alerting section
|
||||
assertTrue(mAlertingSection.isInSection(mEntry));
|
||||
assertFalse(mSilentSection.isInSection(mEntry));
|
||||
assertTrue(mAlertingSectioner.isInSection(mEntry));
|
||||
assertFalse(mSilentSectioner.isInSection(mEntry));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -156,8 +156,8 @@ public class RankingCoordinatorTest extends SysuiTestCase {
|
||||
when(mHighPriorityProvider.isHighPriority(mEntry)).thenReturn(false);
|
||||
|
||||
// THEN entry is in the silent section
|
||||
assertFalse(mAlertingSection.isInSection(mEntry));
|
||||
assertTrue(mSilentSection.isInSection(mEntry));
|
||||
assertFalse(mAlertingSectioner.isInSection(mEntry));
|
||||
assertTrue(mSilentSectioner.isInSection(mEntry));
|
||||
}
|
||||
|
||||
private RankingBuilder getRankingForUnfilteredNotif() {
|
||||
|
||||
Reference in New Issue
Block a user