summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff DeCew <jeffdq@google.com> 2021-11-17 17:33:53 +0000
committer Jeff DeCew <jeffdq@google.com> 2021-11-17 17:49:24 +0000
commitb8b2f899483bf359b1f44b84da1d397f40f66e56 (patch)
tree303e38f33452cc94ed431d021a30dc5f238d4e6b
parent2653e1800a759d39125737f75a79162838bd8dd3 (diff)
Add SmartReplyView internals to StatusBar dump
Bug: 205657774 Test: adb shell dumpsys activity service com.android.systemui/.SystemUIService StatusBarGoogle Merged-In: Ibeb432ec5cfd66ebde46d9d328a323f572b2337e Change-Id: Ibeb432ec5cfd66ebde46d9d328a323f572b2337e
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java83
3 files changed, 99 insertions, 3 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 1bbd45192bea..4479aa0468b7 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
@@ -3345,6 +3345,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
ipw.decreaseIndent();
ipw.println("}");
+ } else if (mPrivateLayout != null) {
+ mPrivateLayout.dumpSmartReplies(ipw);
}
});
}
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 df484dd8ed77..0ffca30ed409 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
@@ -27,6 +27,7 @@ import android.os.Build;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.AttributeSet;
+import android.util.IndentingPrintWriter;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
@@ -1955,6 +1956,22 @@ public class NotificationContentView extends FrameLayout {
pw.println();
}
+ /** Add any existing SmartReplyView to the dump */
+ public void dumpSmartReplies(IndentingPrintWriter pw) {
+ if (mHeadsUpSmartReplyView != null) {
+ pw.println("HeadsUp SmartReplyView:");
+ pw.increaseIndent();
+ mHeadsUpSmartReplyView.dump(pw);
+ pw.decreaseIndent();
+ }
+ if (mExpandedSmartReplyView != null) {
+ pw.println("Expanded SmartReplyView:");
+ pw.increaseIndent();
+ mExpandedSmartReplyView.dump(pw);
+ pw.decreaseIndent();
+ }
+ }
+
public RemoteInputView getExpandedRemoteInput() {
return mExpandedRemoteInput;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index 4e33529f3c36..85add6c21b72 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -1,7 +1,8 @@
package com.android.systemui.statusbar.policy;
+import static java.lang.Float.NaN;
+
import android.annotation.ColorInt;
-import android.annotation.NonNull;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.RemoteInput;
@@ -14,10 +15,12 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.RippleDrawable;
+import android.os.SystemClock;
import android.text.Layout;
import android.text.TextPaint;
import android.text.method.TransformationMethod;
import android.util.AttributeSet;
+import android.util.IndentingPrintWriter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -25,6 +28,8 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
@@ -89,6 +94,13 @@ public class SmartReplyView extends ViewGroup {
private int mMaxNumActions;
private int mMinNumSystemGeneratedReplies;
+ // DEBUG variables tracked for the dump()
+ private long mLastDrawChildTime;
+ private long mLastDispatchDrawTime;
+ private long mLastMeasureTime;
+ private int mTotalSqueezeRemeasureAttempts;
+ private boolean mDidHideSystemReplies;
+
public SmartReplyView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -217,6 +229,7 @@ public class SmartReplyView extends ViewGroup {
// Mark all buttons as hidden and un-squeezed.
resetButtonsLayoutParams();
+ mTotalSqueezeRemeasureAttempts = 0;
if (!mCandidateButtonQueueForSqueezing.isEmpty()) {
Log.wtf(TAG, "Single line button queue leaked between onMeasure calls");
@@ -329,6 +342,7 @@ public class SmartReplyView extends ViewGroup {
}
}
+ mDidHideSystemReplies = false;
if (mSmartRepliesGeneratedByAssistant) {
if (!gotEnoughSmartReplies(smartReplies)) {
// We don't have enough smart replies - hide all of them.
@@ -339,6 +353,7 @@ public class SmartReplyView extends ViewGroup {
// Reset our measures back to when we had only added actions (before adding
// replies).
accumulatedMeasures = actionsMeasures;
+ mDidHideSystemReplies = true;
}
}
@@ -356,6 +371,7 @@ public class SmartReplyView extends ViewGroup {
accumulatedMeasures.mMeasuredWidth),
widthMeasureSpec),
resolveSize(buttonHeight, heightMeasureSpec));
+ mLastMeasureTime = SystemClock.elapsedRealtime();
}
// TODO: this should be replaced, and instead, setMinSystemGenerated... should be invoked
@@ -371,6 +387,53 @@ public class SmartReplyView extends ViewGroup {
}
}
+ /** Dump internal state for debugging */
+ public void dump(IndentingPrintWriter pw) {
+ pw.println(this);
+ pw.increaseIndent();
+ pw.print("mMaxSqueezeRemeasureAttempts=");
+ pw.println(mMaxSqueezeRemeasureAttempts);
+ pw.print("mTotalSqueezeRemeasureAttempts=");
+ pw.println(mTotalSqueezeRemeasureAttempts);
+ pw.print("mMaxNumActions=");
+ pw.println(mMaxNumActions);
+ pw.print("mSmartRepliesGeneratedByAssistant=");
+ pw.println(mSmartRepliesGeneratedByAssistant);
+ pw.print("mMinNumSystemGeneratedReplies=");
+ pw.println(mMinNumSystemGeneratedReplies);
+ pw.print("mHeightUpperLimit=");
+ pw.println(mHeightUpperLimit);
+ pw.print("mDidHideSystemReplies=");
+ pw.println(mDidHideSystemReplies);
+ long now = SystemClock.elapsedRealtime();
+ pw.print("lastMeasureAge (s)=");
+ pw.println(mLastMeasureTime == 0 ? NaN : (now - mLastMeasureTime) / 1000.0f);
+ pw.print("lastDrawChildAge (s)=");
+ pw.println(mLastDrawChildTime == 0 ? NaN : (now - mLastDrawChildTime) / 1000.0f);
+ pw.print("lastDispatchDrawAge (s)=");
+ pw.println(mLastDispatchDrawTime == 0 ? NaN : (now - mLastDispatchDrawTime) / 1000.0f);
+ int numChildren = getChildCount();
+ pw.print("children: num=");
+ pw.println(numChildren);
+ pw.increaseIndent();
+ for (int i = 0; i < numChildren; i++) {
+ View child = getChildAt(i);
+ LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ pw.print("[");
+ pw.print(i);
+ pw.print("] type=");
+ pw.print(lp.mButtonType);
+ pw.print(" squeezeStatus=");
+ pw.print(lp.squeezeStatus);
+ pw.print(" show=");
+ pw.print(lp.show);
+ pw.print(" view=");
+ pw.println(child);
+ }
+ pw.decreaseIndent();
+ pw.decreaseIndent();
+ }
+
/**
* Fields we keep track of inside onMeasure() to correctly measure the SmartReplyView depending
* on which suggestions are added.
@@ -393,8 +456,11 @@ public class SmartReplyView extends ViewGroup {
* Returns whether our notification contains at least N smart replies (or 0) where N is
* determined by {@link SmartReplyConstants}.
*/
- // TODO: we probably sholdn't make this deliberation in the View
private boolean gotEnoughSmartReplies(List<View> smartReplies) {
+ if (mMinNumSystemGeneratedReplies <= 1) {
+ // Count is irrelevant, do not bother.
+ return true;
+ }
int numShownReplies = 0;
for (View smartReplyButton : smartReplies) {
final LayoutParams lp = (LayoutParams) smartReplyButton.getLayoutParams();
@@ -474,6 +540,7 @@ public class SmartReplyView extends ViewGroup {
final boolean moveLeft = initialLeftTextWidth > initialRightTextWidth;
final int maxSqueezeRemeasureAttempts = mMaxSqueezeRemeasureAttempts;
for (int i = 0; i < maxSqueezeRemeasureAttempts; i++) {
+ mTotalSqueezeRemeasureAttempts++;
final int newPosition =
moveLeft ? mBreakIterator.previous() : mBreakIterator.next();
if (newPosition == BreakIterator.DONE) {
@@ -613,7 +680,17 @@ public class SmartReplyView extends ViewGroup {
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- return lp.show && super.drawChild(canvas, child, drawingTime);
+ if (!lp.show) {
+ return false;
+ }
+ mLastDrawChildTime = SystemClock.elapsedRealtime();
+ return super.drawChild(canvas, child, drawingTime);
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+ mLastDispatchDrawTime = SystemClock.elapsedRealtime();
}
/**