Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39217229 authored by Ming-Shin Lu's avatar Ming-Shin Lu Committed by Android (Google) Code Review
Browse files

Merge "Fix NavigationBar overlapping with the IME window" into sc-dev

parents 168fa576 08579765
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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() {
+26 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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());
    }
}