diff options
| author | 2021-05-20 07:18:58 +0000 | |
|---|---|---|
| committer | 2021-05-20 07:18:58 +0000 | |
| commit | fb127be77fcae9fc5e138a5ec0a0e0ee8718aafb (patch) | |
| tree | 3705dc2c6be81f048ac15217eef0e42b3ca1fcbf | |
| parent | 86d3f3deaea4af79b77ecc7e2fbdcc6d10954279 (diff) | |
| parent | 9a1c747208ee0e809b1b26a01b68267500a9c7e0 (diff) | |
Merge "Fix lockscreen can't get IME insets when split-screen activated" into sc-dev
3 files changed, 40 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 1ec07d047e13..735fae3391a2 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -4603,13 +4603,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return super.forAllWindows(callback, traverseTopToBottom); } - private boolean skipImeWindowsDuringTraversal(DisplayContent dc) { + private static boolean skipImeWindowsDuringTraversal(DisplayContent dc) { // We skip IME windows so they're processed just above their target, except // in split-screen mode where we process the IME containers above the docked divider. // Note that this method check should align with {@link // WindowState#applyImeWindowsIfNeeded} in case of any state mismatch. - return dc.getImeTarget(IME_TARGET_LAYERING) != null - && !dc.getDefaultTaskDisplayArea().isSplitScreenModeActivated(); + return dc.mImeLayeringTarget != null + && (!dc.getDefaultTaskDisplayArea().isSplitScreenModeActivated() + || dc.mImeLayeringTarget.getTask() == null); } /** Like {@link #forAllWindows}, but ignores {@link #skipImeWindowsDuringTraversal} */ diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b93312acb055..d09cc46a8cb4 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -4855,8 +4855,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // (i.e. Like {@link DisplayContent.ImeContainer#skipImeWindowsDuringTraversal}, the IME // window will be ignored to traverse when the IME target is still in split-screen mode). if (isImeLayeringTarget() - && !getDisplayContent().getDefaultTaskDisplayArea().isSplitScreenModeActivated()) { - if (getDisplayContent().forAllImeWindows(callback, traverseTopToBottom)) { + && (!mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated() + || getTask() == null)) { + if (mDisplayContent.forAllImeWindows(callback, traverseTopToBottom)) { return true; } } 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 e3b0bb263830..152a575c847d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; +import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.Surface.ROTATION_0; @@ -50,6 +51,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.wm.DisplayContent.IME_TARGET_CONTROL; +import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING; import static com.android.server.wm.WindowContainer.SYNC_STATE_WAITING_FOR_DRAW; import static com.google.common.truth.Truth.assertThat; @@ -58,6 +60,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -923,4 +926,34 @@ public class WindowStateTests extends WindowTestsBase { verify(app.getDisplayContent()).updateImeControlTarget(); assertEquals(mAppWindow, mDisplayContent.getImeTarget(IME_TARGET_CONTROL).getWindow()); } + + @UseTestDisplay(addWindows = { W_ACTIVITY, W_INPUT_METHOD, W_NOTIFICATION_SHADE }) + @Test + public void testNotificationShadeHasImeInsetsWhenSplitscreenActivated() { + WindowState app = createWindow(null, TYPE_BASE_APPLICATION, + mAppWindow.mToken, "app"); + + // Simulate entering multi-window mode and verify if the split-screen is activated. + app.mActivityRecord.getRootTask().setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); + assertEquals(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, app.getWindowingMode()); + assertTrue(mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated()); + + // Simulate notificationShade is shown and being IME layering target. + mNotificationShadeWindow.setHasSurface(true); + mNotificationShadeWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE; + assertTrue(mNotificationShadeWindow.canBeImeTarget()); + mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_IME).setWindow( + mImeWindow, null, null); + + mDisplayContent.computeImeTarget(true); + assertEquals(mNotificationShadeWindow, mDisplayContent.getImeTarget(IME_TARGET_LAYERING)); + mDisplayContent.getInsetsStateController().getRawInsetsState() + .setSourceVisible(ITYPE_IME, true); + + // Verify notificationShade can still get IME insets even the split-screen is activated. + InsetsState state = mDisplayContent.getInsetsStateController().getInsetsForWindow( + mNotificationShadeWindow); + assertNotNull(state.peekSource(ITYPE_IME)); + assertTrue(state.getSource(ITYPE_IME).isVisible()); + } } |