diff options
7 files changed, 187 insertions, 86 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 02b1210a2881..ccd4843e9ac6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -107,6 +107,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.InflatedSmartReplyState; +import com.android.systemui.util.DumpUtilsKt; import com.android.systemui.wmshell.BubblesManager; import java.io.FileDescriptor; @@ -3305,40 +3306,45 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - super.dump(fd, pw, args); - pw.println(" Notification: " + mEntry.getKey()); - pw.print(" visibility: " + getVisibility()); - pw.print(", alpha: " + getAlpha()); - pw.print(", translation: " + getTranslation()); - pw.print(", removed: " + isRemoved()); - pw.print(", expandAnimationRunning: " + mExpandAnimationRunning); - NotificationContentView showingLayout = getShowingLayout(); - pw.print(", privateShowing: " + (showingLayout == mPrivateLayout)); - pw.println(); - showingLayout.dump(fd, pw, args); - pw.print(" "); - if (getViewState() != null) { - getViewState().dump(fd, pw, args); - } else { - pw.print("no viewState!!!"); - } - pw.println(); - pw.println(); - if (mIsSummaryWithChildren) { - pw.print(" ChildrenContainer"); - pw.print(" visibility: " + mChildrenContainer.getVisibility()); - pw.print(", alpha: " + mChildrenContainer.getAlpha()); - pw.print(", translationY: " + mChildrenContainer.getTranslationY()); - pw.println(); - List<ExpandableNotificationRow> notificationChildren = getAttachedChildren(); - pw.println(" Children: " + notificationChildren.size()); - pw.println(" {"); - for(ExpandableNotificationRow child : notificationChildren) { - child.dump(fd, pw, args); - } - pw.println(" }"); - pw.println(); - } + // Skip super call; dump viewState ourselves + pw.println("Notification: " + mEntry.getKey()); + DumpUtilsKt.withIndenting(pw, ipw -> { + ipw.print("visibility: " + getVisibility()); + ipw.print(", alpha: " + getAlpha()); + ipw.print(", translation: " + getTranslation()); + ipw.print(", removed: " + isRemoved()); + ipw.print(", expandAnimationRunning: " + mExpandAnimationRunning); + NotificationContentView showingLayout = getShowingLayout(); + ipw.print(", privateShowing: " + (showingLayout == mPrivateLayout)); + ipw.println(); + showingLayout.dump(fd, ipw, args); + + if (getViewState() != null) { + getViewState().dump(fd, ipw, args); + ipw.println(); + } else { + ipw.println("no viewState!!!"); + } + + if (mIsSummaryWithChildren) { + ipw.println(); + ipw.print("ChildrenContainer"); + ipw.print(" visibility: " + mChildrenContainer.getVisibility()); + ipw.print(", alpha: " + mChildrenContainer.getAlpha()); + ipw.print(", translationY: " + mChildrenContainer.getTranslationY()); + ipw.println(); + List<ExpandableNotificationRow> notificationChildren = getAttachedChildren(); + ipw.println("Children: " + notificationChildren.size()); + ipw.print("{"); + ipw.increaseIndent(); + for (ExpandableNotificationRow child : notificationChildren) { + ipw.println(); + child.dump(fd, ipw, args); + } + ipw.decreaseIndent(); + ipw.println("}"); + } + }); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java index 8b0764b1c313..fa2c1ee772cb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java @@ -34,6 +34,7 @@ import com.android.systemui.animation.Interpolators; import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.util.DumpUtilsKt; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -743,6 +744,16 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable { @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + pw.println(getClass().getSimpleName()); + DumpUtilsKt.withIndenting(pw, ipw -> { + ExpandableViewState viewState = getViewState(); + if (viewState == null) { + ipw.println("no viewState!!!"); + } else { + viewState.dump(fd, ipw, args); + ipw.println(); + } + }); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java index 9eb95c409009..b27a40a828f3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java @@ -25,6 +25,10 @@ import android.view.View; import com.android.systemui.R; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.ViewState; +import com.android.systemui.util.DumpUtilsKt; + +import java.io.FileDescriptor; +import java.io.PrintWriter; public class FooterView extends StackScrollerDecorView { private FooterViewButton mDismissButton; @@ -45,6 +49,19 @@ public class FooterView extends StackScrollerDecorView { } @Override + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + super.dump(fd, pw, args); + DumpUtilsKt.withIndenting(pw, ipw -> { + ipw.println("visibility: " + DumpUtilsKt.visibilityString(getVisibility())); + ipw.println("manageButton showHistory: " + mShowHistory); + ipw.println("manageButton visibility: " + + DumpUtilsKt.visibilityString(mDismissButton.getVisibility())); + ipw.println("dismissButton visibility: " + + DumpUtilsKt.visibilityString(mDismissButton.getVisibility())); + }); + } + + @Override protected void onFinishInflate() { super.onFinishInflate(); mDismissButton = (FooterViewButton) findSecondaryView(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 1be0a960087c..df484dd8ed77 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1938,7 +1938,6 @@ public class NotificationContentView extends FrameLayout { } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.print(" "); pw.print("contentView visibility: " + getVisibility()); pw.print(", alpha: " + getAlpha()); pw.print(", clipBounds: " + getClipBounds()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 6aa5f0709acc..6a127102b726 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -109,6 +109,7 @@ import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController import com.android.systemui.statusbar.policy.HeadsUpUtil; import com.android.systemui.statusbar.policy.ScrollAdapter; import com.android.systemui.util.Assert; +import com.android.systemui.util.DumpUtilsKt; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -4899,54 +4900,42 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println(String.format("[%s: pulsing=%s visibility=%s" - + " alpha=%f scrollY:%d maxTopPadding=%d showShelfOnly=%s" - + " qsExpandFraction=%f" - + " hideAmount=%f]", - this.getClass().getSimpleName(), - mPulsing ? "T" : "f", - getVisibility() == View.VISIBLE ? "visible" - : getVisibility() == View.GONE ? "gone" - : "invisible", - getAlpha(), - mAmbientState.getScrollY(), - mMaxTopPadding, - mShouldShowShelfOnly ? "T" : "f", - mQsExpansionFraction, - mAmbientState.getHideAmount())); - int childCount = getChildCount(); - pw.println(" Number of children: " + childCount); - pw.println(); + StringBuilder sb = new StringBuilder("[") + .append(this.getClass().getSimpleName()).append(":") + .append(" pulsing=").append(mPulsing ? "T" : "f") + .append(" visibility=").append(DumpUtilsKt.visibilityString(getVisibility())) + .append(" alpha=").append(getAlpha()) + .append(" scrollY=").append(mAmbientState.getScrollY()) + .append(" maxTopPadding=").append(mMaxTopPadding) + .append(" showShelfOnly=").append(mShouldShowShelfOnly ? "T" : "f") + .append(" qsExpandFraction=").append(mQsExpansionFraction) + .append(" isCurrentUserSetup=").append(mIsCurrentUserSetup) + .append(" hideAmount=").append(mAmbientState.getHideAmount()) + .append("]"); + pw.println(sb.toString()); + DumpUtilsKt.withIndenting(pw, ipw -> { + int childCount = getChildCount(); + ipw.println("Number of children: " + childCount); + ipw.println(); - for (int i = 0; i < childCount; i++) { - ExpandableView child = (ExpandableView) getChildAt(i); - child.dump(fd, pw, args); - if (!(child instanceof ExpandableNotificationRow)) { - pw.println(" " + child.getClass().getSimpleName()); - // Notifications dump it's viewstate as part of their dump to support children - ExpandableViewState viewState = child.getViewState(); - if (viewState == null) { - pw.println(" no viewState!!!"); - } else { - pw.print(" "); - viewState.dump(fd, pw, args); - pw.println(); - pw.println(); - } + for (int i = 0; i < childCount; i++) { + ExpandableView child = (ExpandableView) getChildAt(i); + child.dump(fd, ipw, args); + ipw.println(); + } + int transientViewCount = getTransientViewCount(); + pw.println("Transient Views: " + transientViewCount); + for (int i = 0; i < transientViewCount; i++) { + ExpandableView child = (ExpandableView) getTransientView(i); + child.dump(fd, pw, args); + } + View swipedView = mSwipeHelper.getSwipedView(); + pw.println("Swiped view: " + swipedView); + if (swipedView instanceof ExpandableView) { + ExpandableView expandableView = (ExpandableView) swipedView; + expandableView.dump(fd, pw, args); } - } - int transientViewCount = getTransientViewCount(); - pw.println(" Transient Views: " + transientViewCount); - for (int i = 0; i < transientViewCount; i++) { - ExpandableView child = (ExpandableView) getTransientView(i); - child.dump(fd, pw, args); - } - View swipedView = mSwipeHelper.getSwipedView(); - pw.println(" Swiped view: " + swipedView); - if (swipedView instanceof ExpandableView) { - ExpandableView expandableView = (ExpandableView) swipedView; - expandableView.dump(fd, pw, args); - } + }); } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 4ad2af44e202..711e9412df7e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -129,7 +129,6 @@ import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.ActivityIntentHelper; import com.android.systemui.AutoReinflateContainer; import com.android.systemui.DejankUtils; -import com.android.systemui.Dumpable; import com.android.systemui.EventLogTags; import com.android.systemui.InitController; import com.android.systemui.Prefs; @@ -235,6 +234,7 @@ import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; import com.android.systemui.unfold.UnfoldTransitionWallpaperController; import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.systemui.unfold.util.NaturalRotationUnfoldProgressProvider; +import com.android.systemui.util.DumpUtilsKt; import com.android.systemui.util.WallpaperController; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.MessageRouter; @@ -936,8 +936,6 @@ public class StatusBar extends SystemUI implements data -> mCommandQueueCallbacks.animateExpandSettingsPanel(data.mSubpanel)); mMessageRouter.subscribeTo(MSG_LAUNCH_TRANSITION_TIMEOUT, id -> onLaunchTransitionTimeout()); - - dumpManager.registerDumpable(this); } @Override @@ -2445,8 +2443,14 @@ public class StatusBar extends SystemUI implements } pw.println(" mStackScroller: "); if (mStackScroller != null) { - pw.print (" "); - ((Dumpable) mStackScroller).dump(fd, pw, args); + DumpUtilsKt.withIndenting(pw, ipw -> { + // Triple indent until we rewrite the rest of this dump() + ipw.increaseIndent(); + ipw.increaseIndent(); + mStackScroller.dump(fd, ipw, args); + ipw.decreaseIndent(); + ipw.decreaseIndent(); + }); } pw.println(" Theme:"); String nightMode = mUiModeManager == null ? "null" : mUiModeManager.getNightMode() + ""; diff --git a/packages/SystemUI/src/com/android/systemui/util/DumpUtils.kt b/packages/SystemUI/src/com/android/systemui/util/DumpUtils.kt new file mode 100644 index 000000000000..9f33c271881d --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/util/DumpUtils.kt @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 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.util + +import android.util.IndentingPrintWriter +import android.view.View +import java.io.PrintWriter +import java.util.function.Consumer + +/** + * Run some code that will print to an [IndentingPrintWriter] that wraps the given [PrintWriter]. + * + * If the given [PrintWriter] is an [IndentingPrintWriter], the block will be passed that same + * instance with [IndentingPrintWriter.increaseIndent] having been called, and calling + * [IndentingPrintWriter.decreaseIndent] after completion of the block, so the passed [PrintWriter] + * should not be used before the block completes. + */ +inline fun PrintWriter.withIndenting(block: (IndentingPrintWriter) -> Unit) { + if (this is IndentingPrintWriter) { + this.withIncreasedIndent { block(this) } + } else { + block(IndentingPrintWriter(this)) + } +} + +/** + * Run some code that will print to an [IndentingPrintWriter] that wraps the given [PrintWriter]. + * + * If the given [PrintWriter] is an [IndentingPrintWriter], the block will be passed that same + * instance with [IndentingPrintWriter.increaseIndent] having been called, and calling + * [IndentingPrintWriter.decreaseIndent] after completion of the block, so the passed [PrintWriter] + * should not be used before the block completes. + */ +fun PrintWriter.withIndenting(consumer: Consumer<IndentingPrintWriter>) { + if (this is IndentingPrintWriter) { + this.withIncreasedIndent { consumer.accept(this) } + } else { + consumer.accept(IndentingPrintWriter(this)) + } +} + +/** + * Run some code inside a block, with [IndentingPrintWriter.increaseIndent] having been called on + * the given argument, and calling [IndentingPrintWriter.decreaseIndent] after completion. + */ +inline fun IndentingPrintWriter.withIncreasedIndent(block: () -> Unit) { + this.increaseIndent() + try { + block() + } finally { + this.decreaseIndent() + } +} + +/** Return a readable string for the visibility */ +fun visibilityString(@View.Visibility visibility: Int): String = when (visibility) { + View.GONE -> "gone" + View.VISIBLE -> "visible" + View.INVISIBLE -> "invisible" + else -> "unknown:$visibility" +} |