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

Commit 21674014 authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Fix unexpected IME visible temporary while dismissing the editor dialog

In DC#computeImeParent we defer reparenting IME surface to the target
until the target has started the input to be the input target since the
IME requested visibility will updated after then.

However the logic didn't aware of the IME input target may null when it
be removed, so IME surface will be appear on the display area if the
next layering target has not yet to start the input.

The lucky thing is CloseImeEditorPopupDialogTest caught this errorprone
when verifying IME layer will expected gone after IME-snapshot/dialog
dismissed, but actually may failed by IME layer may still visible
after dismissed the dialog.

Fix this defer IME reparent logic and also consolidate
CloseImeEditorPopupDialogTest in FlickerTest to verify IME snpshot and
IME visiblity until IME window has gone to ensure the layer tracing
could record the full animation frames to verify the IME-snapshot /
IME layer visiblity correctly during the animation.

Fix: 231108751
Test: atest FlickerTests:CloseImeEditorPopupDialogTest
        --rerun-until-failure 20
Change-Id: I863231507c210739fd363746ccbc8ac9072e8094
parent 3d70f2c7
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4407,8 +4407,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            boolean imeLayeringTargetMayUseIme =
            boolean imeLayeringTargetMayUseIme =
                    LayoutParams.mayUseInputMethod(mImeLayeringTarget.mAttrs.flags)
                    LayoutParams.mayUseInputMethod(mImeLayeringTarget.mAttrs.flags)
                    || mImeLayeringTarget.mAttrs.type == TYPE_APPLICATION_STARTING;
                    || mImeLayeringTarget.mAttrs.type == TYPE_APPLICATION_STARTING;
            if (imeLayeringTargetMayUseIme && mImeInputTarget != null
            if (imeLayeringTargetMayUseIme && (mImeInputTarget == null
                    && mImeLayeringTarget.mActivityRecord != mImeInputTarget.getActivityRecord()) {
                    || mImeLayeringTarget.mActivityRecord != mImeInputTarget.getActivityRecord())) {
                // Do not change parent if the window hasn't requested IME.
                // Do not change parent if the window hasn't requested IME.
                return null;
                return null;
            }
            }
+3 −0
Original line number Original line Diff line number Diff line
@@ -643,6 +643,7 @@ public class DisplayContentTests extends WindowTestsBase {
        final DisplayContent dc = mDisplayContent;
        final DisplayContent dc = mDisplayContent;
        final WindowState ws = createWindow(null, TYPE_APPLICATION, dc, "app window");
        final WindowState ws = createWindow(null, TYPE_APPLICATION, dc, "app window");
        dc.setImeLayeringTarget(ws);
        dc.setImeLayeringTarget(ws);
        dc.setImeInputTarget(ws);


        // Adjust bounds so that matchesRootDisplayAreaBounds() returns false.
        // Adjust bounds so that matchesRootDisplayAreaBounds() returns false.
        final Rect bounds = new Rect(dc.getBounds());
        final Rect bounds = new Rect(dc.getBounds());
@@ -1154,6 +1155,7 @@ public class DisplayContentTests extends WindowTestsBase {
        dc.setImeLayeringTarget(createWindow(null, TYPE_STATUS_BAR, "app"));
        dc.setImeLayeringTarget(createWindow(null, TYPE_STATUS_BAR, "app"));
        dc.getImeTarget(IME_TARGET_LAYERING).getWindow().setWindowingMode(
        dc.getImeTarget(IME_TARGET_LAYERING).getWindow().setWindowingMode(
                WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW);
                WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW);
        dc.setImeInputTarget(dc.getImeTarget(IME_TARGET_LAYERING).getWindow());
        assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
        assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
    }
    }


@@ -1172,6 +1174,7 @@ public class DisplayContentTests extends WindowTestsBase {
    public void testComputeImeParent_noApp() throws Exception {
    public void testComputeImeParent_noApp() throws Exception {
        final DisplayContent dc = createNewDisplay();
        final DisplayContent dc = createNewDisplay();
        dc.setImeLayeringTarget(createWindow(null, TYPE_STATUS_BAR, "statusBar"));
        dc.setImeLayeringTarget(createWindow(null, TYPE_STATUS_BAR, "statusBar"));
        dc.setImeInputTarget(dc.getImeTarget(IME_TARGET_LAYERING).getWindow());
        assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
        assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -59,7 +59,7 @@ class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter)
            }
            }
            transitions {
            transitions {
                imeTestApp.dismissDialog(wmHelper)
                imeTestApp.dismissDialog(wmHelper)
                instrumentation.uiAutomation.syncInputTransactions()
                wmHelper.waitImeGone()
            }
            }
            teardown {
            teardown {
                eachRun {
                eachRun {
@@ -91,7 +91,7 @@ class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter)
                    .then()
                    .then()
                    .isVisible(FlickerComponentName.IME_SNAPSHOT)
                    .isVisible(FlickerComponentName.IME_SNAPSHOT)
                    .then()
                    .then()
                    .isInvisible(FlickerComponentName.IME_SNAPSHOT)
                    .isInvisible(FlickerComponentName.IME_SNAPSHOT, isOptional = true)
                    .isInvisible(FlickerComponentName.IME)
                    .isInvisible(FlickerComponentName.IME)
        }
        }
    }
    }