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

Commit 0ff4ed6f authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not skip IME in forAllWindows if its target is invisible

This removed the logic added in [1]. Because forAllWindows can be
used to perform any operation. It is unsafe to skip generally.
Such as when performing applyKeyguardPolicy for all windows, it may
miss the chance to hide IME.

Also the original problem in [1] usually won't happen since IME
surface can be attached to app's surface, then the IME can be hidden
with the app naturally.

[1]: I57357ba85501397fa5926ab4dee116c42df24506

Bug: 339375944
Flag: com.android.window.flags.do_not_skip_ime_by_target_visibility
Test: WindowContainerTraversalTests#testTraverseImeRegardlessOfImeTarget
Change-Id: I73b952f384ec1f6104e548dad62a0483c6f5915d
parent ce8e50cf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,16 @@ flag {
    }
}

flag {
    name: "do_not_skip_ime_by_target_visibility"
    namespace: "windowing_frontend"
    description: "Avoid window traversal missing IME"
    bug: "339375944"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "apply_lifecycle_on_pip_change"
    namespace: "windowing_frontend"
+10 −8
Original line number Diff line number Diff line
@@ -4648,6 +4648,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        if (!isImeLayeringTarget()) {
            return false;
        }
        if (!com.android.window.flags.Flags.doNotSkipImeByTargetVisibility()) {
            // Note that we don't process IME window if the IME input target is not on the screen.
            // In case some unexpected IME visibility cases happen like starting the remote
            // animation on the keyguard but seeing the IME window that originally on the app
@@ -4657,6 +4658,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    && !(imeInputTarget.isDrawn() || imeInputTarget.isVisibleRequested())) {
                return false;
            }
        }
        return mDisplayContent.forAllImeWindows(callback, traverseTopToBottom);
    }

+2 −0
Original line number Diff line number Diff line
@@ -747,6 +747,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
        }
    }

    @android.platform.test.annotations.RequiresFlagsDisabled(
            com.android.window.flags.Flags.FLAG_DO_NOT_SKIP_IME_BY_TARGET_VISIBILITY)
    @SetupWindows(addWindows = W_INPUT_METHOD)
    @Test
    public void testLaunchRemoteAnimationWithoutImeBehind() {
+21 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;

import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;

import android.platform.test.annotations.Presubmit;
@@ -60,4 +61,24 @@ public class WindowContainerTraversalTests extends WindowTestsBase {
        verify(c).accept(eq(mDockedDividerWindow));
        verify(c).accept(eq(mImeWindow));
    }

    @android.platform.test.annotations.RequiresFlagsEnabled(
            com.android.window.flags.Flags.FLAG_DO_NOT_SKIP_IME_BY_TARGET_VISIBILITY)
    @SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
    @Test
    public void testTraverseImeRegardlessOfImeTarget() {
        mDisplayContent.setImeLayeringTarget(mAppWindow);
        mDisplayContent.setImeInputTarget(mAppWindow);
        mAppWindow.mHasSurface = false;
        mAppWindow.mActivityRecord.setVisibleRequested(false);
        mAppWindow.mActivityRecord.setVisible(false);

        final boolean[] foundIme = { false };
        mDisplayContent.forAllWindows(w -> {
            if (w == mImeWindow) {
                foundIme[0] = true;
            }
        }, true /* traverseTopToBottom */);
        assertTrue("IME must be found", foundIme[0]);
    }
}