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

Commit 050e37ec authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "New Pipeline: log structure in dumpsys" into tm-qpr-dev

parents dcd2bede 86c30b52
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
@@ -142,7 +142,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;
@@ -870,6 +870,14 @@ public class NotifCollection implements Dumpable {
        }
    }

    @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)
}
+68 −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

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 print(a: Any?) = ipw.print(a)
    fun println(a: Any?) = ipw.println(a)
    fun withIncreasedIndent(b: () -> Unit) = ipw.withIncreasedIndent(b)
    fun withIncreasedIndent(r: Runnable) = ipw.withIncreasedIndent(r)

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

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

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

private val Any.bareClassName: String get() {
    val className = javaClass.name
    val packageName = javaClass.`package`.name
    return className.substring(packageName.length + 1)
}

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;
@@ -1396,6 +1396,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