Loading services/core/java/com/android/server/wm/WindowToken.java +9 −5 Original line number Diff line number Diff line Loading @@ -758,12 +758,16 @@ class WindowToken extends WindowContainer<WindowState> { /** @see WindowState#freezeInsetsState() */ void setInsetsFrozen(boolean freeze) { forAllWindows(w -> { if (w.mToken == this) { if (freeze) { forAllWindows(WindowState::freezeInsetsState, true /* traverseTopToBottom */); w.freezeInsetsState(); } else { forAllWindows(WindowState::clearFrozenInsetsState, true /* traverseTopToBottom */); w.clearFrozenInsetsState(); } } }, true /* traverseTopToBottom */); } @Override @WindowManager.LayoutParams.WindowType int getWindowType() { Loading services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.view.InsetsState.ITYPE_IME; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; Loading Loading @@ -250,4 +251,29 @@ public class WindowTokenTests extends WindowTestsBase { verify(selectFunc).apply(token2.windowType, options); } /** * Test that {@link WindowToken#setInsetsFrozen(boolean)} will set the frozen insets * states for its children windows and by default it shouldn't let IME window setting * the frozen insets state even the window of the window token is the IME layering target. */ @UseTestDisplay(addWindows = W_INPUT_METHOD) @Test public void testSetInsetsFrozen_notAffectImeWindowState() { // Pre-condition: make the IME window be controlled by IME insets provider. mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_IME).setWindow( mDisplayContent.mInputMethodWindow, null, null); // Simulate an app window to be the IME layering target, assume the app window has no // frozen insets state by default. final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); mDisplayContent.setImeLayeringTarget(app); assertNull(app.getFrozenInsetsState()); assertTrue(app.isImeLayeringTarget()); // Verify invoking setInsetsFrozen shouldn't let IME window setting the frozen insets state. app.mToken.setInsetsFrozen(true); assertNotNull(app.getFrozenInsetsState()); assertNull(mDisplayContent.mInputMethodWindow.getFrozenInsetsState()); } } Loading
services/core/java/com/android/server/wm/WindowToken.java +9 −5 Original line number Diff line number Diff line Loading @@ -758,12 +758,16 @@ class WindowToken extends WindowContainer<WindowState> { /** @see WindowState#freezeInsetsState() */ void setInsetsFrozen(boolean freeze) { forAllWindows(w -> { if (w.mToken == this) { if (freeze) { forAllWindows(WindowState::freezeInsetsState, true /* traverseTopToBottom */); w.freezeInsetsState(); } else { forAllWindows(WindowState::clearFrozenInsetsState, true /* traverseTopToBottom */); w.clearFrozenInsetsState(); } } }, true /* traverseTopToBottom */); } @Override @WindowManager.LayoutParams.WindowType int getWindowType() { Loading
services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.view.InsetsState.ITYPE_IME; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; Loading Loading @@ -250,4 +251,29 @@ public class WindowTokenTests extends WindowTestsBase { verify(selectFunc).apply(token2.windowType, options); } /** * Test that {@link WindowToken#setInsetsFrozen(boolean)} will set the frozen insets * states for its children windows and by default it shouldn't let IME window setting * the frozen insets state even the window of the window token is the IME layering target. */ @UseTestDisplay(addWindows = W_INPUT_METHOD) @Test public void testSetInsetsFrozen_notAffectImeWindowState() { // Pre-condition: make the IME window be controlled by IME insets provider. mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_IME).setWindow( mDisplayContent.mInputMethodWindow, null, null); // Simulate an app window to be the IME layering target, assume the app window has no // frozen insets state by default. final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); mDisplayContent.setImeLayeringTarget(app); assertNull(app.getFrozenInsetsState()); assertTrue(app.isImeLayeringTarget()); // Verify invoking setInsetsFrozen shouldn't let IME window setting the frozen insets state. app.mToken.setInsetsFrozen(true); assertNotNull(app.getFrozenInsetsState()); assertNull(mDisplayContent.mInputMethodWindow.getFrozenInsetsState()); } }