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

Commit f948afe6 authored by lumark's avatar lumark Committed by Ming-Shin Lu
Browse files

Don't set as IME target when the stack is minimized in split screen

It could be reasonable that when in split screen mode, if navigating
to home screen by tapping back key or home key to let the docked primary
stack minimized, even the last state is focused on EditText, the IME window
should not be shown on the bottom or the divider handle icon hidden.

Added a check in WindowState#canBeImeTarget to ignore when the stack is
in docked minimized state.

Fix: 133151818
Test: atest WindowStateTests#testCanBeImeTarget
Test: manual
1. Open few apps from Apps list. (in this case Settings & Gmail)
2. Dock both the apps in split screen.
3. Tap on Settings search to bring up IME > Rotate the device >
   Switch IME focus to Gmail in lower frame.
4. Again rotate the device back to portrait > Bring IME focus to lower app
5. Navigate to home screen by tapping on back key and observe.
6. Expected the divider handle icon should be shown on the top of divider,
   and IME window should not shown on the bottom.

Change-Id: I1433f2766150d0916cbe08a0698c232fb7b4199c
parent be3d17ea
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2092,6 +2092,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return false;
        }

        final TaskStack stack = getStack();
        if (stack != null && stack.shouldIgnoreInput()) {
            // Ignore when the stack shouldn't receive input event.
            // (i.e. the minimized stack in split screen mode.)
            return false;
        }

        final int fl = mAttrs.flags & (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
        final int type = mAttrs.type;

+19 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.hardware.camera2.params.OutputConfiguration.ROTATION_90;
import static android.view.InsetsState.TYPE_TOP_BAR;
import static android.view.Surface.ROTATION_0;
@@ -36,6 +37,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
@@ -249,6 +251,23 @@ public class WindowStateTests extends WindowTestsBase {
        // Invisible window can't be IME targets even if they have the right flags.
        assertFalse(appWindow.canBeImeTarget());
        assertFalse(imeWindow.canBeImeTarget());

        // Simulate the window is in split screen primary stack and the current state is
        // minimized and home stack is resizable, so that we should ignore input for the stack.
        final DockedStackDividerController controller =
                mDisplayContent.getDockedDividerController();
        final TaskStack stack = createTaskStackOnDisplay(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY,
                ACTIVITY_TYPE_STANDARD, mDisplayContent);
        spyOn(appWindow);
        spyOn(controller);
        spyOn(stack);
        doReturn(true).when(controller).isMinimizedDock();
        doReturn(true).when(controller).isHomeStackResizable();
        doReturn(stack).when(appWindow).getStack();

        // Make sure canBeImeTarget is false due to shouldIgnoreInput is true;
        assertFalse(appWindow.canBeImeTarget());
        assertTrue(stack.shouldIgnoreInput());
    }

    @Test