From 3a925384dad6b84437ec6d8d11fb94b75336479e Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Wed, 29 Mar 2023 19:51:17 -0700 Subject: [PATCH] Clear touch region on dream overlay container on start. Since the updated TouchInsetManager logic only sets the touch regions for surface controls of tracked views, the dream overlay's touch region will not be set if no view is tracked. This changelist ensures that the touch region for the overlay is cleared on attach. Test: atest DreamOverlayContainerViewControllerTest#testRootSurfaceControlInsetSetOnAttach Fixes: 276023607 Change-Id: I8cc96ba3c1d35510620ca6ed605e386fe11aecc1 --- .../dreams/DreamOverlayContainerViewController.java | 4 ++++ .../DreamOverlayContainerViewControllerTest.java | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index 4b478cdca9f90..7c6a748646648 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -25,6 +25,7 @@ import static com.android.systemui.dreams.complication.ComplicationLayoutParams. import android.animation.Animator; import android.content.res.Resources; +import android.graphics.Region; import android.os.Handler; import android.util.MathUtils; import android.view.View; @@ -223,6 +224,9 @@ public class DreamOverlayContainerViewController extends mJitterStartTimeMillis = System.currentTimeMillis(); mHandler.postDelayed(this::updateBurnInOffsets, mBurnInProtectionUpdateInterval); mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback(mBouncerExpansionCallback); + final Region emptyRegion = Region.obtain(); + mView.getRootSurfaceControl().setTouchableRegion(emptyRegion); + emptyRegion.recycle(); // Start dream entry animations. Skip animations for low light clock. if (!mStateController.isLowLightActive()) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java index 2a72e7d85d3cc..18abfa546ea6e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java @@ -26,8 +26,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.res.Resources; +import android.graphics.Region; import android.os.Handler; import android.testing.AndroidTestingRunner; +import android.view.AttachedSurfaceControl; import android.view.ViewGroup; import android.view.ViewRootImpl; import android.view.ViewTreeObserver; @@ -75,6 +77,9 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { @Mock ComplicationHostViewController mComplicationHostViewController; + @Mock + AttachedSurfaceControl mAttachedSurfaceControl; + @Mock ViewGroup mDreamOverlayContentView; @@ -108,6 +113,8 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { when(mDreamOverlayContainerView.getResources()).thenReturn(mResources); when(mDreamOverlayContainerView.getViewTreeObserver()).thenReturn(mViewTreeObserver); when(mDreamOverlayContainerView.getViewRootImpl()).thenReturn(mViewRoot); + when(mDreamOverlayContainerView.getRootSurfaceControl()) + .thenReturn(mAttachedSurfaceControl); mController = new DreamOverlayContainerViewController( mDreamOverlayContainerView, @@ -127,6 +134,12 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { mBouncerlessScrimController); } + @Test + public void testRootSurfaceControlInsetSetOnAttach() { + mController.onViewAttached(); + verify(mAttachedSurfaceControl).setTouchableRegion(eq(Region.obtain())); + } + @Test public void testDreamOverlayStatusBarViewControllerInitialized() { mController.init();