Loading services/core/java/com/android/server/wm/WindowState.java +18 −2 Original line number Diff line number Diff line Loading @@ -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 Loading services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } Loading
services/core/java/com/android/server/wm/WindowState.java +18 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } }