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

Commit 1218fc96 authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Prevent animating app from setting exclusion rects"

parents e6de1595 8009e920
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -2622,8 +2622,24 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    /** @return false if this window desires touch events. */
    boolean cantReceiveTouchInput() {
        return mAppToken != null && mAppToken.getTask() != null
                && (mAppToken.getTask().mStack.shouldIgnoreInput() || mAppToken.hiddenRequested);
        if (mAppToken == null || mAppToken.getTask() == null) {
            return false;
        }

        return mAppToken.getTask().mStack.shouldIgnoreInput()
                || mAppToken.hiddenRequested
                || isAnimatingToRecents();
    }

    /**
     * Returns {@code true} if the window is animating to home as part of the recents animation.
     */
    private boolean isAnimatingToRecents() {
        final RecentsAnimationController recentsAnimationController =
                mWmService.getRecentsAnimationController();
        return recentsAnimationController != null
                && recentsAnimationController.isAnimatingTask(getTask())
                && !recentsAnimationController.isTargetApp(mAppToken);
    }

    @Override
+26 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;

import android.graphics.Insets;
import android.graphics.Matrix;
@@ -547,4 +548,29 @@ public class WindowStateTests extends WindowTestsBase {
        assertEquals(OFFSET_SUM, values[Matrix.MTRANS_X], 0f);
        assertEquals(0f, values[Matrix.MTRANS_Y], 0f);
    }

    @Test
    public void testCantReceiveTouchDuringRecentsAnimation() {
        final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");

        // Mock active recents animation
        RecentsAnimationController recentsController = mock(RecentsAnimationController.class);
        when(recentsController.isAnimatingTask(win0.mAppToken.getTask())).thenReturn(true);
        mWm.setRecentsAnimationController(recentsController);
        assertTrue(win0.cantReceiveTouchInput());
    }

    @Test
    public void testCantReceiveTouchWhenAppTokenHiddenRequested() {
        final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
        win0.mAppToken.hiddenRequested = true;
        assertTrue(win0.cantReceiveTouchInput());
    }

    @Test
    public void testCantReceiveTouchWhenShouldIgnoreInput() {
        final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
        win0.mAppToken.getStack().setAdjustedForMinimizedDock(1 /* Any non 0 value works */);
        assertTrue(win0.cantReceiveTouchInput());
    }
}