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

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

Merge "New Pipeline: Add Trace calls to measure performance." into sc-v2-dev am: 8201c87a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16162917

Change-Id: I7ffb273467b9033b37cf2f7db95cd87fabc882f5
parents 9231b672 8201c87a
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.UserIdInt;
import android.app.Notification;
import android.app.Notification;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.NotificationListenerService.Ranking;
@@ -512,6 +513,7 @@ public class NotifCollection implements Dumpable {
    }
    }


    private void dispatchEventsAndRebuildList() {
    private void dispatchEventsAndRebuildList() {
        Trace.beginSection("NotifCollection.dispatchEventsAndRebuildList");
        mAmDispatchingToOtherCode = true;
        mAmDispatchingToOtherCode = true;
        while (!mEventQueue.isEmpty()) {
        while (!mEventQueue.isEmpty()) {
            mEventQueue.remove().dispatchTo(mNotifCollectionListeners);
            mEventQueue.remove().dispatchTo(mNotifCollectionListeners);
@@ -521,6 +523,7 @@ public class NotifCollection implements Dumpable {
        if (mBuildListener != null) {
        if (mBuildListener != null) {
            mBuildListener.onBuildList(mReadOnlyNotificationSet);
            mBuildListener.onBuildList(mReadOnlyNotificationSet);
        }
        }
        Trace.endSection();
    }
    }


    private void onEndLifetimeExtension(
    private void onEndLifetimeExtension(
+27 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.systemui.statusbar.notification.collection.listbuilder


import android.annotation.MainThread;
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.os.Trace;
import android.util.ArrayMap;
import android.util.ArrayMap;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
@@ -332,6 +333,7 @@ public class ShadeListBuilder implements Dumpable {
     * if we detect that behavior, we should crash instantly.
     * if we detect that behavior, we should crash instantly.
     */
     */
    private void buildList() {
    private void buildList() {
        Trace.beginSection("ShadeListBuilder.buildList");
        mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
        mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
        mPipelineState.setState(STATE_BUILD_STARTED);
        mPipelineState.setState(STATE_BUILD_STARTED);


@@ -385,9 +387,11 @@ public class ShadeListBuilder implements Dumpable {


        // Step 8: Dispatch the new list, first to any listeners and then to the view layer
        // Step 8: Dispatch the new list, first to any listeners and then to the view layer
        dispatchOnBeforeRenderList(mReadOnlyNotifList);
        dispatchOnBeforeRenderList(mReadOnlyNotifList);
        Trace.beginSection("ShadeListBuilder.onRenderList");
        if (mOnRenderListListener != null) {
        if (mOnRenderListListener != null) {
            mOnRenderListListener.onRenderList(mReadOnlyNotifList);
            mOnRenderListListener.onRenderList(mReadOnlyNotifList);
        }
        }
        Trace.endSection();


        // Step 9: We're done!
        // Step 9: We're done!
        mLogger.logEndBuildList(
        mLogger.logEndBuildList(
@@ -399,9 +403,11 @@ public class ShadeListBuilder implements Dumpable {
        }
        }
        mPipelineState.setState(STATE_IDLE);
        mPipelineState.setState(STATE_IDLE);
        mIterationCount++;
        mIterationCount++;
        Trace.endSection();
    }
    }


    private void notifySectionEntriesUpdated() {
    private void notifySectionEntriesUpdated() {
        Trace.beginSection("ShadeListBuilder.notifySectionEntriesUpdated");
        NotifSection currentSection = null;
        NotifSection currentSection = null;
        mTempSectionMembers.clear();
        mTempSectionMembers.clear();
        for (int i = 0; i < mNotifList.size(); i++) {
        for (int i = 0; i < mNotifList.size(); i++) {
@@ -415,6 +421,7 @@ public class ShadeListBuilder implements Dumpable {
            }
            }
            mTempSectionMembers.add(currentEntry);
            mTempSectionMembers.add(currentEntry);
        }
        }
        Trace.endSection();
    }
    }


    /**
    /**
@@ -456,6 +463,7 @@ public class ShadeListBuilder implements Dumpable {
            Collection<? extends ListEntry> entries,
            Collection<? extends ListEntry> entries,
            List<ListEntry> out,
            List<ListEntry> out,
            List<NotifFilter> filters) {
            List<NotifFilter> filters) {
        Trace.beginSection("ShadeListBuilder.filterNotifs");
        final long now = mSystemClock.uptimeMillis();
        final long now = mSystemClock.uptimeMillis();
        for (ListEntry entry : entries)  {
        for (ListEntry entry : entries)  {
            if (entry instanceof GroupEntry) {
            if (entry instanceof GroupEntry) {
@@ -487,9 +495,11 @@ public class ShadeListBuilder implements Dumpable {
                }
                }
            }
            }
        }
        }
        Trace.endSection();
    }
    }


    private void groupNotifs(List<ListEntry> entries, List<ListEntry> out) {
    private void groupNotifs(List<ListEntry> entries, List<ListEntry> out) {
        Trace.beginSection("ShadeListBuilder.groupNotifs");
        for (ListEntry listEntry : entries) {
        for (ListEntry listEntry : entries) {
            // since grouping hasn't happened yet, all notifs are NotificationEntries
            // since grouping hasn't happened yet, all notifs are NotificationEntries
            NotificationEntry entry = (NotificationEntry) listEntry;
            NotificationEntry entry = (NotificationEntry) listEntry;
@@ -545,12 +555,14 @@ public class ShadeListBuilder implements Dumpable {
                }
                }
            }
            }
        }
        }
        Trace.endSection();
    }
    }


    private void stabilizeGroupingNotifs(List<ListEntry> topLevelList) {
    private void stabilizeGroupingNotifs(List<ListEntry> topLevelList) {
        if (mNotifStabilityManager == null) {
        if (mNotifStabilityManager == null) {
            return;
            return;
        }
        }
        Trace.beginSection("ShadeListBuilder.stabilizeGroupingNotifs");


        for (int i = 0; i < topLevelList.size(); i++) {
        for (int i = 0; i < topLevelList.size(); i++) {
            final ListEntry tle = topLevelList.get(i);
            final ListEntry tle = topLevelList.get(i);
@@ -576,6 +588,7 @@ public class ShadeListBuilder implements Dumpable {
                }
                }
            }
            }
        }
        }
        Trace.endSection();
    }
    }


    /**
    /**
@@ -608,6 +621,7 @@ public class ShadeListBuilder implements Dumpable {
    }
    }


    private void promoteNotifs(List<ListEntry> list) {
    private void promoteNotifs(List<ListEntry> list) {
        Trace.beginSection("ShadeListBuilder.promoteNotifs");
        for (int i = 0; i < list.size(); i++) {
        for (int i = 0; i < list.size(); i++) {
            final ListEntry tle = list.get(i);
            final ListEntry tle = list.get(i);


@@ -626,9 +640,11 @@ public class ShadeListBuilder implements Dumpable {
                });
                });
            }
            }
        }
        }
        Trace.endSection();
    }
    }


    private void pruneIncompleteGroups(List<ListEntry> shadeList) {
    private void pruneIncompleteGroups(List<ListEntry> shadeList) {
        Trace.beginSection("ShadeListBuilder.pruneIncompleteGroups");
        for (int i = 0; i < shadeList.size(); i++) {
        for (int i = 0; i < shadeList.size(); i++) {
            final ListEntry tle = shadeList.get(i);
            final ListEntry tle = shadeList.get(i);


@@ -683,6 +699,7 @@ public class ShadeListBuilder implements Dumpable {
                }
                }
            }
            }
        }
        }
        Trace.endSection();
    }
    }


    /**
    /**
@@ -749,6 +766,7 @@ public class ShadeListBuilder implements Dumpable {
    }
    }


    private void sortListAndNotifySections() {
    private void sortListAndNotifySections() {
        Trace.beginSection("ShadeListBuilder.sortListAndNotifySections");
        // Assign sections to top-level elements and sort their children
        // Assign sections to top-level elements and sort their children
        for (ListEntry entry : mNotifList) {
        for (ListEntry entry : mNotifList) {
            NotifSection section = applySections(entry);
            NotifSection section = applySections(entry);
@@ -766,6 +784,7 @@ public class ShadeListBuilder implements Dumpable {


        // notify sections since the list is sorted now
        // notify sections since the list is sorted now
        notifySectionEntriesUpdated();
        notifySectionEntriesUpdated();
        Trace.endSection();
    }
    }


    private void freeEmptyGroups() {
    private void freeEmptyGroups() {
@@ -1016,27 +1035,35 @@ public class ShadeListBuilder implements Dumpable {
    }
    }


    private void dispatchOnBeforeTransformGroups(List<ListEntry> entries) {
    private void dispatchOnBeforeTransformGroups(List<ListEntry> entries) {
        Trace.beginSection("ShadeListBuilder.dispatchOnBeforeTransformGroups");
        for (int i = 0; i < mOnBeforeTransformGroupsListeners.size(); i++) {
        for (int i = 0; i < mOnBeforeTransformGroupsListeners.size(); i++) {
            mOnBeforeTransformGroupsListeners.get(i).onBeforeTransformGroups(entries);
            mOnBeforeTransformGroupsListeners.get(i).onBeforeTransformGroups(entries);
        }
        }
        Trace.endSection();
    }
    }


    private void dispatchOnBeforeSort(List<ListEntry> entries) {
    private void dispatchOnBeforeSort(List<ListEntry> entries) {
        Trace.beginSection("ShadeListBuilder.dispatchOnBeforeSort");
        for (int i = 0; i < mOnBeforeSortListeners.size(); i++) {
        for (int i = 0; i < mOnBeforeSortListeners.size(); i++) {
            mOnBeforeSortListeners.get(i).onBeforeSort(entries);
            mOnBeforeSortListeners.get(i).onBeforeSort(entries);
        }
        }
        Trace.endSection();
    }
    }


    private void dispatchOnBeforeFinalizeFilter(List<ListEntry> entries) {
    private void dispatchOnBeforeFinalizeFilter(List<ListEntry> entries) {
        Trace.beginSection("ShadeListBuilder.dispatchOnBeforeFinalizeFilter");
        for (int i = 0; i < mOnBeforeFinalizeFilterListeners.size(); i++) {
        for (int i = 0; i < mOnBeforeFinalizeFilterListeners.size(); i++) {
            mOnBeforeFinalizeFilterListeners.get(i).onBeforeFinalizeFilter(entries);
            mOnBeforeFinalizeFilterListeners.get(i).onBeforeFinalizeFilter(entries);
        }
        }
        Trace.endSection();
    }
    }


    private void dispatchOnBeforeRenderList(List<ListEntry> entries) {
    private void dispatchOnBeforeRenderList(List<ListEntry> entries) {
        Trace.beginSection("ShadeListBuilder.dispatchOnBeforeRenderList");
        for (int i = 0; i < mOnBeforeRenderListListeners.size(); i++) {
        for (int i = 0; i < mOnBeforeRenderListListeners.size(); i++) {
            mOnBeforeRenderListListeners.get(i).onBeforeRenderList(entries);
            mOnBeforeRenderListListeners.get(i).onBeforeRenderList(entries);
        }
        }
        Trace.endSection();
    }
    }


    @Override
    @Override
+3 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.collection.listbuilder.pluggable;
package com.android.systemui.statusbar.notification.collection.listbuilder.pluggable;


import android.annotation.Nullable;
import android.annotation.Nullable;
import android.os.Trace;


import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;


@@ -50,7 +51,9 @@ public abstract class Pluggable<This> {
     */
     */
    public final void invalidateList() {
    public final void invalidateList() {
        if (mListener != null) {
        if (mListener != null) {
            Trace.beginSection("Pluggable<" + mName + ">.invalidateList");
            mListener.onPluggableInvalidated((This) this);
            mListener.onPluggableInvalidated((This) this);
            Trace.endSection();
        }
        }
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.util.traceSection


/**
/**
 * Converts a notif list (the output of the ShadeListBuilder) into a NodeSpec, an abstract
 * Converts a notif list (the output of the ShadeListBuilder) into a NodeSpec, an abstract
@@ -36,7 +37,7 @@ class NodeSpecBuilder(
    fun buildNodeSpec(
    fun buildNodeSpec(
        rootController: NodeController,
        rootController: NodeController,
        notifList: List<ListEntry>
        notifList: List<ListEntry>
    ): NodeSpec {
    ): NodeSpec = traceSection("NodeSpecBuilder.buildNodeSpec") {
        val root = NodeSpecImpl(null, rootController)
        val root = NodeSpecImpl(null, rootController)
        var currentSection: NotifSection? = null
        var currentSection: NotifSection? = null
        val prevSections = mutableSetOf<NotifSection?>()
        val prevSections = mutableSetOf<NotifSection?>()
+2 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection.render
import android.annotation.MainThread
import android.annotation.MainThread
import android.view.View
import android.view.View
import com.android.systemui.util.kotlin.transform
import com.android.systemui.util.kotlin.transform
import com.android.systemui.util.traceSection


/**
/**
 * Given a "spec" that describes a "tree" of views, adds and removes views from the
 * Given a "spec" that describes a "tree" of views, adds and removes views from the
@@ -47,7 +48,7 @@ class ShadeViewDiffer(
     * provided [spec]. The root node of the spec must match the root controller passed to the
     * provided [spec]. The root node of the spec must match the root controller passed to the
     * differ's constructor.
     * differ's constructor.
     */
     */
    fun applySpec(spec: NodeSpec) {
    fun applySpec(spec: NodeSpec) = traceSection("ShadeViewDiffer.applySpec") {
        val specMap = treeToMap(spec)
        val specMap = treeToMap(spec)


        if (spec.controller != rootNode.controller) {
        if (spec.controller != rootNode.controller) {
Loading