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

Commit ef94fc2f authored by Julia Tuttle's avatar Julia Tuttle
Browse files

New Pipeline: log structure in dumpsys

For debugging reference purposes, log the full structure of the pipeline
as constructed in dumpsys.

Test: manual
Change-Id: I774c444deae8a215921a80946d1d82cf2ad128bf
parent da8058d2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.dagger.CentralSurfacesModule;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.PipelineDumpable;
import com.android.systemui.statusbar.notification.collection.PipelineDumper;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins;
import com.android.systemui.util.time.SystemClock;
@@ -52,7 +54,8 @@ import javax.inject.Inject;
 */
@SysUISingleton
@SuppressLint("OverrideAbstract")
public class NotificationListener extends NotificationListenerWithPlugins {
public class NotificationListener extends NotificationListenerWithPlugins implements
        PipelineDumpable {
    private static final String TAG = "NotificationListener";
    private static final boolean DEBUG = CentralSurfaces.DEBUG;
    private static final long MAX_RANKING_DELAY_MILLIS = 500L;
@@ -255,6 +258,11 @@ public class NotificationListener extends NotificationListenerWithPlugins {
        }
    }

    @Override
    public void dumpPipeline(@NonNull PipelineDumper d) {
        d.dump("notificationHandlers", mNotificationHandlers);
    }

    private static Ranking getRankingOrTemporaryStandIn(RankingMap rankingMap, String key) {
        Ranking ranking = new Ranking();
        if (!rankingMap.getRanking(key, ranking)) {
+9 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ import javax.inject.Inject;
 */
@MainThread
@SysUISingleton
public class NotifCollection implements Dumpable {
public class NotifCollection implements Dumpable, PipelineDumpable {
    private final IStatusBarService mStatusBarService;
    private final SystemClock mClock;
    private final NotifPipelineFlags mNotifPipelineFlags;
@@ -841,6 +841,14 @@ public class NotifCollection implements Dumpable {
                        "\t\t"));
    }

    @Override
    public void dumpPipeline(@NonNull PipelineDumper d) {
        d.dump("notifCollectionListeners", mNotifCollectionListeners);
        d.dump("lifetimeExtenders", mLifetimeExtenders);
        d.dump("dismissInterceptors", mDismissInterceptors);
        d.dump("buildListener", mBuildListener);
    }

    private final BatchableNotificationHandler mNotifHandler = new BatchableNotificationHandler() {
        @Override
        public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
+21 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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

interface PipelineDumpable {
    fun dumpPipeline(d: PipelineDumper)
}
+51 −0
Original line number Diff line number Diff line
package com.android.systemui.statusbar.notification.collection

import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender
import com.android.systemui.util.asIndenting
import com.android.systemui.util.withIncreasedIndent
import java.io.PrintWriter

class PipelineDumper(pw: PrintWriter) {
    private val ipw = pw.asIndenting()

    fun println(a: Any?) = ipw.println(a)

    fun dump(label: String, value: Any?) {
        ipw.print("$label: ")
        dump(value)
    }

    private fun dump(value: Any?) = when (value) {
        null, is String, is Int -> ipw.println(value)
        is Collection<*> -> dumpCollection(value)
        else -> {
            ipw.println(value.fullPipelineName)
            (value as? PipelineDumpable)?.let {
                ipw.withIncreasedIndent { it.dumpPipeline(this) }
            }
        }
    }

    private fun dumpCollection(values: Collection<Any?>) {
        ipw.println(values.size)
        ipw.withIncreasedIndent { values.forEach { dump(it) } }
    }
}

private val Any.bareClassName: String get() {
    val className = javaClass.name
    val packagePrefixLength = javaClass.`package`?.name?.length?.plus(1) ?: 0
    return className.substring(packagePrefixLength)
}

private val Any.barePipelineName: String? get() = when (this) {
    is NotifLifetimeExtender -> name
    is NotifDismissInterceptor -> name
    is Pluggable<*> -> name
    else -> null
}

private val Any.fullPipelineName: String get() =
    barePipelineName?.let { "\"$it\" ($bareClassName)" } ?: bareClassName
+16 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ import javax.inject.Inject;
 */
@MainThread
@SysUISingleton
public class ShadeListBuilder implements Dumpable {
public class ShadeListBuilder implements Dumpable, PipelineDumpable {
    private final SystemClock mSystemClock;
    private final ShadeListBuilderLogger mLogger;
    private final NotificationInteractionTracker mInteractionTracker;
@@ -1397,6 +1397,21 @@ public class ShadeListBuilder implements Dumpable {
                "\t\t"));
    }

    @Override
    public void dumpPipeline(@NonNull PipelineDumper d) {
        d.dump("choreographer", mChoreographer);
        d.dump("notifPreGroupFilters", mNotifPreGroupFilters);
        d.dump("onBeforeTransformGroupsListeners", mOnBeforeTransformGroupsListeners);
        d.dump("notifPromoters", mNotifPromoters);
        d.dump("onBeforeSortListeners", mOnBeforeSortListeners);
        d.dump("notifSections", mNotifSections);
        d.dump("notifComparators", mNotifComparators);
        d.dump("onBeforeFinalizeFilterListeners", mOnBeforeFinalizeFilterListeners);
        d.dump("notifFinalizeFilters", mNotifFinalizeFilters);
        d.dump("onBeforeRenderListListeners", mOnBeforeRenderListListeners);
        d.dump("onRenderListListener", mOnRenderListListener);
    }

    /** See {@link #setOnRenderListListener(OnRenderListListener)} */
    public interface OnRenderListListener {
        /**
Loading