Merge "Add SmartReplyView internals to StatusBar dump" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
226b035e3d
@@ -3345,6 +3345,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
ipw.println("}");
|
||||
} else if (mPrivateLayout != null) {
|
||||
mPrivateLayout.dumpSmartReplies(ipw);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user