Loading services/core/java/com/android/server/wm/WindowState.java +23 −4 Original line number Diff line number Diff line Loading @@ -1455,11 +1455,30 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP @Override void onDisplayChanged(DisplayContent dc) { if (dc != null && mDisplayContent != null && dc != mDisplayContent && mDisplayContent.getImeInputTarget() == this) { if (mDisplayContent != null && dc != mDisplayContent) { if (mInsetsSourceProviders != null && mInsetsSourceProviders.size() > 0) { boolean notifyInsetsChange = false; for (int i = mInsetsSourceProviders.size() - 1; i >= 0; i--) { if (mInsetsSourceProviders.valueAt(i).isServerVisible()) { notifyInsetsChange = true; break; } } mDisplayContent.getInsetsStateController().updateAboveInsetsState( notifyInsetsChange); } if (dc != null) { dc.getInsetsStateController().updateAboveInsetsState( // This window doesn't have a frame yet. Don't let this window cause the // insets change. false /* notifyInsetsChange */); if (mDisplayContent.getImeInputTarget() == this) { dc.updateImeInputAndControlTarget(getImeInputTarget()); mDisplayContent.setImeInputTarget(null /* target */); } } } super.onDisplayChanged(dc); // Window was not laid out for this display yet, so make sure mLayoutSeq does not match. if (dc != null && mInputWindowHandle.getDisplayId() != dc.getDisplayId()) { Loading services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -548,6 +548,54 @@ public class InsetsStateControllerTest extends WindowTestsBase { verify(navBar, atLeastOnce()).notifyInsetsChanged(); } /** * Verifies that moving the insets receiving window (app) to another display will stop the * window from receiving insets from the original display. */ @UseTestDisplay @Test public void testUpdateAboveInsetsState_onDisplayChanged_app() { final WindowState app = createTestWindow("app"); final WindowState statusBar = createTestWindow("statusBar"); getController().getOrCreateSourceProvider(ID_STATUS_BAR, statusBars()) .setWindow(statusBar, null, null); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); getController().updateAboveInsetsState(true /* notifyInsetsChange */); assertNotNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); app.getTask().reparent(mDefaultDisplay.getDefaultTaskDisplayArea(), true /* onTop */); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); } /** * Verifies that moving the insets providing window (statusBar) to another display will stop the * window on the original display from receiving the insets. */ @UseTestDisplay @Test public void testUpdateAboveInsetsState_onDisplayChanged_statusBar() { final WindowState app = createTestWindow("app"); final WindowState statusBar = createTestWindow("statusBar"); getController().getOrCreateSourceProvider(ID_STATUS_BAR, statusBars()) .setWindow(statusBar, null, null); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); getController().updateAboveInsetsState(true /* notifyInsetsChange */); assertNotNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); statusBar.getTask().reparent(mDefaultDisplay.getDefaultTaskDisplayArea(), true /* onTop */); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); } @Test public void testUpdateAboveInsetsState_imeTargetOnScreenBehavior() { final WindowToken imeToken = createTestWindowToken(TYPE_INPUT_METHOD, mDisplayContent); Loading Loading
services/core/java/com/android/server/wm/WindowState.java +23 −4 Original line number Diff line number Diff line Loading @@ -1455,11 +1455,30 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP @Override void onDisplayChanged(DisplayContent dc) { if (dc != null && mDisplayContent != null && dc != mDisplayContent && mDisplayContent.getImeInputTarget() == this) { if (mDisplayContent != null && dc != mDisplayContent) { if (mInsetsSourceProviders != null && mInsetsSourceProviders.size() > 0) { boolean notifyInsetsChange = false; for (int i = mInsetsSourceProviders.size() - 1; i >= 0; i--) { if (mInsetsSourceProviders.valueAt(i).isServerVisible()) { notifyInsetsChange = true; break; } } mDisplayContent.getInsetsStateController().updateAboveInsetsState( notifyInsetsChange); } if (dc != null) { dc.getInsetsStateController().updateAboveInsetsState( // This window doesn't have a frame yet. Don't let this window cause the // insets change. false /* notifyInsetsChange */); if (mDisplayContent.getImeInputTarget() == this) { dc.updateImeInputAndControlTarget(getImeInputTarget()); mDisplayContent.setImeInputTarget(null /* target */); } } } super.onDisplayChanged(dc); // Window was not laid out for this display yet, so make sure mLayoutSeq does not match. if (dc != null && mInputWindowHandle.getDisplayId() != dc.getDisplayId()) { Loading
services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -548,6 +548,54 @@ public class InsetsStateControllerTest extends WindowTestsBase { verify(navBar, atLeastOnce()).notifyInsetsChanged(); } /** * Verifies that moving the insets receiving window (app) to another display will stop the * window from receiving insets from the original display. */ @UseTestDisplay @Test public void testUpdateAboveInsetsState_onDisplayChanged_app() { final WindowState app = createTestWindow("app"); final WindowState statusBar = createTestWindow("statusBar"); getController().getOrCreateSourceProvider(ID_STATUS_BAR, statusBars()) .setWindow(statusBar, null, null); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); getController().updateAboveInsetsState(true /* notifyInsetsChange */); assertNotNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); app.getTask().reparent(mDefaultDisplay.getDefaultTaskDisplayArea(), true /* onTop */); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); } /** * Verifies that moving the insets providing window (statusBar) to another display will stop the * window on the original display from receiving the insets. */ @UseTestDisplay @Test public void testUpdateAboveInsetsState_onDisplayChanged_statusBar() { final WindowState app = createTestWindow("app"); final WindowState statusBar = createTestWindow("statusBar"); getController().getOrCreateSourceProvider(ID_STATUS_BAR, statusBars()) .setWindow(statusBar, null, null); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); getController().updateAboveInsetsState(true /* notifyInsetsChange */); assertNotNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); statusBar.getTask().reparent(mDefaultDisplay.getDefaultTaskDisplayArea(), true /* onTop */); assertNull(app.mAboveInsetsState.peekSource(ID_STATUS_BAR)); } @Test public void testUpdateAboveInsetsState_imeTargetOnScreenBehavior() { final WindowToken imeToken = createTestWindowToken(TYPE_INPUT_METHOD, mDisplayContent); Loading