diff options
| author | 2019-09-05 11:49:53 -0700 | |
|---|---|---|
| committer | 2019-10-01 14:00:07 -0700 | |
| commit | 8009e920c8310d46670c17c09a23941a3522267b (patch) | |
| tree | e0751eaa849ba049b3551d3af33fc2aa9b5e618a | |
| parent | 3019d9c8d71fad748a05b4961a7474e8c6631ad5 (diff) | |
Prevent animating app from setting exclusion rects
Back gesture still shows if user attempts to swipe
back while we're animating an app away to home screen.
Full screen exclusion rects for launcher are only
granted after the animation has completed, but the
user was able to interact w/ ongoing animations to
see the back arrow.
fixes: 138622418
Test: Open app, swipe home and quickly swipe from
the edge of the screen. Should go to -1 screen and
not see back arrow.
Change-Id: I18603159fbb6b76e0fdb7911cbe7a6e2386c9f87
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowState.java | 20 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java | 26 |
2 files changed, 44 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 0a65e3240885..28dfc322ddef 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -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 diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index f41f126593de..0503d74b38d5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -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()); + } } |