From 34562bcf33f29b2a117e63689429351586bb53ee Mon Sep 17 00:00:00 2001 From: Bill Lin Date: Wed, 21 Jul 2021 12:58:42 +0800 Subject: [PATCH] Fix QSTileViewImpl label set ellipsize performance issue health/microbench/systemui/systemui-latency-suite regress wake & unlock time : +50ms Root cuase: TextView.setEllipsize() overhead is high, and the overhead x QSTileView numbers would obviously affect the test latency time. Solution: By default we left tileView as Marquee but not setSelected(), then we setSelected on tile views when QQS expanding until proposedTranslation meet 1f(showing truncated at End with '...' visualization) Adding 3 major factors to achieve below state machine 1. Selected(T) : expansion == 1f or proposedTranslation < 0f 2. NoAction in transitioning : expansion > 0f or expansion < 1f 3. Signal when mLastHeaderTranslation != headerTranslation The expansion state will be: - init Collapsed : setSelected(true) - Header expanding QQS : setSelected(false) - QQS expanded : NoAction - QQS -> Expanding QS : NoAction - QS expanded : setSelected(true) - QS Collapsing -> QQS : setSelected(true) or QS full collapsing : setSelected(true) - QS collapsed in QQS : setSelected(false) - Back to init state : setSelected(true) Test: health/microbench/systemui/systemui-latency-suite Test: Manual check QS/QQS long label tile QQS : ellipsize at end QS: Marquee Test: SystemUITests Bug: 192680464 Change-Id: Iebf1e84043501916dd90378973a6736135c9f653 --- .../android/systemui/qs/PagedTileLayout.java | 2 +- .../com/android/systemui/qs/QSFragment.java | 12 +++++---- .../src/com/android/systemui/qs/QSPanel.java | 9 ++++--- .../com/android/systemui/qs/QuickQSPanel.java | 26 +++++++++++++++++++ .../systemui/qs/tileimpl/QSTileViewImpl.kt | 3 --- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index ce1066ee41c25..1bd36644bbc57 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -268,7 +268,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { } @Override - public void setExpansion(float expansion) { + public void setExpansion(float expansion, float proposedTranslation) { mLastExpansion = expansion; updateSelected(); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index 04f692dcc1e63..ae3b884e3ab72 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -491,11 +491,13 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca : headerTranslation); } int currentHeight = getView().getHeight(); - mLastHeaderTranslation = headerTranslation; - if (expansion == mLastQSExpansion && mLastKeyguardAndExpanded == onKeyguardAndExpanded - && mLastViewHeight == currentHeight) { + if (expansion == mLastQSExpansion + && mLastKeyguardAndExpanded == onKeyguardAndExpanded + && mLastViewHeight == currentHeight + && mLastHeaderTranslation == headerTranslation) { return; } + mLastHeaderTranslation = headerTranslation; mLastQSExpansion = expansion; mLastKeyguardAndExpanded = onKeyguardAndExpanded; mLastViewHeight = currentHeight; @@ -515,8 +517,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca } mFooter.setExpansion(onKeyguardAndExpanded ? 1 : expansion); mQSPanelController.setRevealExpansion(expansion); - mQSPanelController.getTileLayout().setExpansion(expansion); - mQuickQSPanelController.getTileLayout().setExpansion(expansion); + mQSPanelController.getTileLayout().setExpansion(expansion, proposedTranslation); + mQuickQSPanelController.getTileLayout().setExpansion(expansion, proposedTranslation); mQSPanelScrollView.setTranslationY(translationScaleY * heightDiff); if (fullyCollapsed) { mQSPanelScrollView.setScrollY(0); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 425bdc24fe1b1..09d520dd556b2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -740,7 +740,7 @@ public class QSPanel extends LinearLayout implements Tunable { void setListening(boolean listening, UiEventLogger uiEventLogger); /** - * Set the minimum number of rows to show + * Sets the minimum number of rows to show * * @param minRows the minimum. */ @@ -749,7 +749,7 @@ public class QSPanel extends LinearLayout implements Tunable { } /** - * Set the max number of columns to show + * Sets the max number of columns to show * * @param maxColumns the maximum * @@ -759,7 +759,10 @@ public class QSPanel extends LinearLayout implements Tunable { return false; } - default void setExpansion(float expansion) {} + /** + * Sets the expansion value and proposedTranslation to panel. + */ + default void setExpansion(float expansion, float proposedTranslation) {} int getNumVisibleTiles(); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java index 985943bc8b054..c5bfe97403e74 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java @@ -177,6 +177,8 @@ public class QuickQSPanel extends QSPanel { static class QQSSideLabelTileLayout extends SideLabelTileLayout { + private boolean mLastSelected; + QQSSideLabelTileLayout(Context context) { super(context, null); setClipChildren(false); @@ -222,5 +224,29 @@ public class QuickQSPanel extends QSPanel { } } } + + @Override + public void setExpansion(float expansion, float proposedTranslation) { + if (expansion > 0f && expansion < 1f) { + return; + } + // The cases we must set select for marquee when QQS/QS collapsed, and QS full expanded. + // Expansion == 0f is when QQS is fully showing (as opposed to 1f, which is QS). At this + // point we want them to be selected so the tiles will marquee (but not at other points + // of expansion. + boolean selected = (expansion == 1f || proposedTranslation < 0f); + if (mLastSelected == selected) { + return; + } + // We set it as not important while we change this, so setting each tile as selected + // will not cause them to announce themselves until the user has actually selected the + // item. + setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + for (int i = 0; i < getChildCount(); i++) { + getChildAt(i).setSelected(selected); + } + setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); + mLastSelected = selected; + } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 70685a68e182f..222539d495268 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -195,9 +195,6 @@ open class QSTileViewImpl @JvmOverloads constructor( // sibling methods to have special behavior for labelContainer. labelContainer.forceUnspecifiedMeasure = true secondaryLabel.alpha = 0f - // Do not marque in QQS - label.ellipsize = TextUtils.TruncateAt.END - secondaryLabel.ellipsize = TextUtils.TruncateAt.END } setLabelColor(getLabelColorForState(QSTile.State.DEFAULT_STATE)) setSecondaryLabelColor(getSecondaryLabelColorForState(QSTile.State.DEFAULT_STATE))