From e8a4aa7869b19036b4d51ba888fbbbe137cd6b6e Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Wed, 16 Nov 2022 00:57:08 +0000 Subject: [PATCH] Media doesn't clip based on shade footer Padding moved to a different view in the QS hierarchy. This caused the wrong clipping to be computed and applied to the UMO. Fixes: 248562534 Test: Manually checked clipping of UMO on small device Change-Id: Ib3a39a43d0e54b229af97b7d484ce2ec55d2917c --- .../com/android/systemui/qs/QSFragment.java | 8 +++++--- .../android/systemui/qs/QSPanelController.java | 4 ++++ .../android/systemui/qs/QSFragmentTest.java | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index 1422a25bfe12c..0b7ccbfe7c3fb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -757,7 +757,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca return ShadeInterpolation.getContentAlpha(progress); } - private void updateQsBounds() { + @VisibleForTesting + void updateQsBounds() { if (mLastQSExpansion == 1.0f) { // Fully expanded, let's set the layout bounds as clip bounds. This is necessary because // it's a scrollview and otherwise wouldn't be clipped. However, we set the horizontal @@ -773,9 +774,10 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca mQSPanelScrollView.getLocationOnScreen(mLocationTemp); int left = mLocationTemp[0]; int top = mLocationTemp[1]; - mQsMediaHost.getCurrentClipping().set(left, top, left + getView().getMeasuredWidth(), + mQsMediaHost.getCurrentClipping().set(left, top, + left + getView().getMeasuredWidth(), top + mQSPanelScrollView.getMeasuredHeight() - - mQSPanelScrollView.getPaddingBottom()); + - mQSPanelController.getPaddingBottom()); } private boolean headerWillBeAnimating() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java index 64962b495c962..1827eaf3fad12 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java @@ -239,5 +239,9 @@ public class QSPanelController extends QSPanelControllerBase { public boolean isBouncerInTransit() { return mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit(); } + + public int getPaddingBottom() { + return mView.getPaddingBottom(); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 72e022ed7bbbb..aedb9354e6db7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -19,6 +19,7 @@ import static com.android.systemui.statusbar.StatusBarState.SHADE; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -450,6 +451,23 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { verify(mQSPanelController).setListening(true, true); } + @Test + public void testUpdateQSBounds_setMediaClipCorrectly() { + QSFragment fragment = resumeAndGetFragment(); + disableSplitShade(); + + Rect mediaHostClip = new Rect(); + when(mQSPanelController.getPaddingBottom()).thenReturn(50); + setLocationOnScreen(mQSPanelScrollView, 25); + when(mQSPanelScrollView.getMeasuredHeight()).thenReturn(200); + when(mQSMediaHost.getCurrentClipping()).thenReturn(mediaHostClip); + + fragment.updateQsBounds(); + + assertEquals(25, mediaHostClip.top); + assertEquals(175, mediaHostClip.bottom); + } + @Override protected Fragment instantiate(Context context, String className, Bundle arguments) { MockitoAnnotations.initMocks(this);