Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd056f8c authored by Will's avatar Will
Browse files

Fix tapping on dreams to dismiss.

A recent change to show a status bar in dreams broke the ability to
dismiss dreams with a tap. This change restores the tap behavior.

Test: atest DreamOverlayServiceTest
Bug: 210528110
Change-Id: I1bfc4fb384aa31ff135d02736e357c110f27f00e
parent 471b37a9
Loading
Loading
Loading
Loading
+38 −34
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ

    // The service listens to view changes in order to declare that input occurring in areas outside
    // the overlay should be passed through to the dream underneath.
    private View.OnAttachStateChangeListener mRootViewAttachListener =
    private final View.OnAttachStateChangeListener mRootViewAttachListener =
            new View.OnAttachStateChangeListener() {
                @Override
                public void onViewAttachedToWindow(View v) {
@@ -82,13 +82,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
                @Override
                public void onViewDetachedFromWindow(View v) {
                    v.getViewTreeObserver()
                    .removeOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener);
                            .removeOnComputeInternalInsetsListener(
                                    mOnComputeInternalInsetsListener);
                }
            };

    // A hook into the internal inset calculation where we declare the overlays as the only
    // touchable regions.
    private ViewTreeObserver.OnComputeInternalInsetsListener mOnComputeInternalInsetsListener  =
    private final ViewTreeObserver.OnComputeInternalInsetsListener
            mOnComputeInternalInsetsListener =
            new ViewTreeObserver.OnComputeInternalInsetsListener() {
                @Override
                public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
@@ -163,7 +165,9 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
        }

        window.setContentView(mDreamOverlayComponent.getDreamOverlayContainerView());

        mDreamOverlayContentView = mDreamOverlayComponent.getDreamOverlayContentView();
        mDreamOverlayContentView.addOnAttachStateChangeListener(mRootViewAttachListener);

        mDreamOverlayComponent.getDreamOverlayStatusBarViewController().init();

+16 −0
Original line number Diff line number Diff line
@@ -191,4 +191,20 @@ public class DreamOverlayServiceTest extends SysuiTestCase {

        verify(mDreamOverlayStatusBarViewController).init();
    }

    @Test
    public void testRootViewAttachListenerIsAddedToDreamOverlayContentView() throws Exception {
        final DreamOverlayService service = new DreamOverlayService(mContext, mMainExecutor,
                mDreamOverlayStateController, mDreamOverlayStatusBarViewComponentFactory);

        final IBinder proxy = service.onBind(new Intent());
        final IDreamOverlay overlay = IDreamOverlay.Stub.asInterface(proxy);

        // Inform the overlay service of dream starting.
        overlay.startDream(mWindowParams, mDreamOverlayCallback);
        mMainExecutor.runAllReady();

        verify(mDreamOverlayContentView).addOnAttachStateChangeListener(
                any(View.OnAttachStateChangeListener.class));
    }
}