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

Commit 44c695bb authored by Ned Burns's avatar Ned Burns
Browse files

Add onCleanup() method to Pluggables

onCleanup() is called on all pluggables at the end of each pipeline run.
This allows pluggables to clean up any temporary state they may have
created during the run.

We'll use this in a following CL to reset a cache in the
PreparationCoordinator's filter at the end of every run.

Test: atest SystemUITests
Change-Id: I9567aaf50b55aae4241811404856d4225872e972
parent 94edc7b6
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
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.Pluggable;
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.SystemClock;
@@ -321,6 +322,7 @@ public class ShadeListBuilder implements Dumpable {
        mPipelineState.incrementTo(STATE_FINALIZING);
        logChanges();
        freeEmptyGroups();
        cleanupPluggables();

        // Step 8: Dispatch the new list, first to any listeners and then to the view layer
        dispatchOnBeforeRenderList(mReadOnlyNotifList);
@@ -673,6 +675,20 @@ public class ShadeListBuilder implements Dumpable {
        }
    }

    private void cleanupPluggables() {
        callOnCleanup(mNotifPreGroupFilters);
        callOnCleanup(mNotifPromoters);
        callOnCleanup(mNotifFinalizeFilters);
        callOnCleanup(mNotifComparators);
        callOnCleanup(mNotifSections);
    }

    private void callOnCleanup(List<? extends Pluggable<?>> pluggables) {
        for (int i = 0; i < pluggables.size(); i++) {
            pluggables.get(i).onCleanup();
        }
    }

    private final Comparator<ListEntry> mTopLevelComparator = (o1, o2) -> {

        int cmp = Integer.compare(o1.getSection(), o2.getSection());
+7 −1
Original line number Diff line number Diff line
@@ -55,10 +55,16 @@ public abstract class Pluggable<This> {
    }

    /** Set a listener to be notified when a pluggable is invalidated. */
    public void setInvalidationListener(PluggableListener<This> listener) {
    public final void setInvalidationListener(PluggableListener<This> listener) {
        mListener = listener;
    }

    /**
     * Called on the pluggable once at the end of every pipeline run. Override this method to
     * perform any necessary cleanup.
     */
    public void onCleanup() { }

    /**
     * Listener interface for when pluggables are invalidated.
     *