From f02d74e6fca8f12299db3c9c69ece9b2f0088f64 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 28 Apr 2023 16:30:02 -0400 Subject: [PATCH] Logging improvements for notification views * Allows enabling verbose notification view dumping on debug builds without a rebuild * Includes showing all the pflags on the notification view and the background view, the latter of which was critical in detecting the intermediate cause of b/233281914 * Verbose background logging now includes tint and ripple colors Bug: 233281914 Test: dumpsysui NotificationStackScrollLayout Change-Id: Iddebb1c3859967d09369074bbdb1f321be6d6868 --- .../row/ActivatableNotificationView.java | 16 ++++++++++------ .../row/ExpandableNotificationRow.java | 2 ++ .../notification/row/ExpandableView.java | 4 +++- .../row/NotificationBackgroundView.java | 15 ++++++++++++++- .../src/com/android/systemui/util/ColorUtil.kt | 13 +++++++++++-- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 66d4c3a977732..285dd9766169e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -733,12 +733,16 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView super.dump(pw, args); if (DUMP_VERBOSE) { DumpUtilsKt.withIncreasedIndent(pw, () -> { - pw.println("mBackgroundNormal: " + mBackgroundNormal); - if (mBackgroundNormal != null) { - DumpUtilsKt.withIncreasedIndent(pw, () -> { - mBackgroundNormal.dump(pw, args); - }); - } + dumpBackgroundView(pw, args); + }); + } + } + + protected void dumpBackgroundView(IndentingPrintWriter pw, String[] args) { + pw.println("Background View: " + mBackgroundNormal); + if (DUMP_VERBOSE && mBackgroundNormal != null) { + DumpUtilsKt.withIncreasedIndent(pw, () -> { + mBackgroundNormal.dump(pw, args); }); } } 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 597813344d6ef..1dc58b59339d2 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 @@ -3593,6 +3593,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView // Skip super call; dump viewState ourselves pw.println("Notification: " + mEntry.getKey()); DumpUtilsKt.withIncreasedIndent(pw, () -> { + pw.println(this); pw.print("visibility: " + getVisibility()); pw.print(", alpha: " + getAlpha()); pw.print(", translation: " + getTranslation()); @@ -3612,6 +3613,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView pw.println("no viewState!!!"); } pw.println(getRoundableState().debugString()); + dumpBackgroundView(pw, args); int transientViewCount = mChildrenContainer == null ? 0 : mChildrenContainer.getTransientViewCount(); 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 5edff5f4e5d28..3e01dd3ab3305 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 @@ -40,6 +40,7 @@ import com.android.systemui.statusbar.notification.Roundable; import com.android.systemui.statusbar.notification.RoundableState; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.util.Compile; import com.android.systemui.util.DumpUtilsKt; import java.io.PrintWriter; @@ -52,7 +53,8 @@ import java.util.List; public abstract class ExpandableView extends FrameLayout implements Dumpable, Roundable { private static final String TAG = "ExpandableView"; /** whether the dump() for this class should include verbose details */ - protected static final boolean DUMP_VERBOSE = false; + protected static final boolean DUMP_VERBOSE = + Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE); private RoundableState mRoundableState = null; protected OnHeightChangedListener mOnHeightChangedListener; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java index da8d2d524456a..647505cea71bd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.row; +import static com.android.systemui.util.ColorUtilKt.hexColorString; + import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Canvas; @@ -27,6 +29,9 @@ import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.android.internal.util.ArrayUtils; import com.android.systemui.Dumpable; import com.android.systemui.R; @@ -44,6 +49,7 @@ public class NotificationBackgroundView extends View implements Dumpable { private int mClipTopAmount; private int mClipBottomAmount; private int mTintColor; + @Nullable private Integer mRippleColor; private final float[] mCornerRadii = new float[8]; private boolean mBottomIsRounded; private boolean mBottomAmountClips = true; @@ -127,6 +133,7 @@ public class NotificationBackgroundView extends View implements Dumpable { unscheduleDrawable(mBackground); } mBackground = background; + mRippleColor = null; mBackground.mutate(); if (mBackground != null) { mBackground.setCallback(this); @@ -215,6 +222,9 @@ public class NotificationBackgroundView extends View implements Dumpable { if (mBackground instanceof RippleDrawable) { RippleDrawable ripple = (RippleDrawable) mBackground; ripple.setColor(ColorStateList.valueOf(color)); + mRippleColor = color; + } else { + mRippleColor = null; } } @@ -290,7 +300,7 @@ public class NotificationBackgroundView extends View implements Dumpable { } @Override - public void dump(PrintWriter pw, String[] args) { + public void dump(PrintWriter pw, @NonNull String[] args) { pw.println("mDontModifyCorners: " + mDontModifyCorners); pw.println("mClipTopAmount: " + mClipTopAmount); pw.println("mClipBottomAmount: " + mClipBottomAmount); @@ -299,5 +309,8 @@ public class NotificationBackgroundView extends View implements Dumpable { pw.println("mBottomAmountClips: " + mBottomAmountClips); pw.println("mActualWidth: " + mActualWidth); pw.println("mActualHeight: " + mActualHeight); + pw.println("mTintColor: " + hexColorString(mTintColor)); + pw.println("mRippleColor: " + hexColorString(mRippleColor)); + pw.println("mBackground: " + mBackground); } } diff --git a/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt b/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt index 27a53bf2ceda7..41b3145ed36e6 100644 --- a/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt +++ b/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt @@ -19,6 +19,7 @@ package com.android.systemui.util import android.content.res.TypedArray import android.graphics.Color import android.view.ContextThemeWrapper +import androidx.annotation.ColorInt /** Returns an ARGB color version of [color] at the given [alpha]. */ fun getColorWithAlpha(color: Int, alpha: Float): Int = @@ -35,8 +36,11 @@ fun getColorWithAlpha(color: Int, alpha: Float): Int = * otherwise, returns the color from the private attribute {@param privAttrId}. */ fun getPrivateAttrColorIfUnset( - ctw: ContextThemeWrapper, attrArray: TypedArray, - attrIndex: Int, defColor: Int, privAttrId: Int + ctw: ContextThemeWrapper, + attrArray: TypedArray, + attrIndex: Int, + defColor: Int, + privAttrId: Int ): Int { // If the index is specified, use that value var a = attrArray @@ -51,3 +55,8 @@ fun getPrivateAttrColorIfUnset( a.recycle() return color } + +/** Returns the color as a HTML hex color (or null) */ +fun hexColorString(@ColorInt color: Int?): String = color + ?.let { String.format("#%08x", it) } + ?: "null"