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

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

Merge "Fix IME snapshot missing to remove by 2 consecutive creation calls" into tm-dev

parents 14e9f410 1137b137
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4140,6 +4140,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        final SurfaceControl.Transaction t = getPendingTransaction();
        // Prepare IME screenshot for the target if it allows to attach into.
        if (mInputMethodWindow != null && mInputMethodWindow.isVisible()) {
            // Remove the obsoleted IME snapshot first in case the new snapshot happens to
            // override the current one before the transition finish and the surface never be
            // removed on the task.
            removeImeSurfaceImmediately();
            mImeScreenshot = new ImeScreenshot(
                    mWmService.mSurfaceControlFactory.apply(null), mImeLayeringTarget);
            mImeScreenshot.attachAndShow(t);
+26 −0
Original line number Diff line number Diff line
@@ -2050,6 +2050,32 @@ public class DisplayContentTests extends WindowTestsBase {
        verify(mDisplayContent, never()).showImeScreenshot();
    }

    @UseTestDisplay(addWindows = {W_INPUT_METHOD})
    @Test
    public void testShowImeScreenshot_removeCurSnapshotBeforeCreateNext() {
        final Task rootTask = createTask(mDisplayContent);
        final Task task = createTaskInRootTask(rootTask, 0 /* userId */);
        final ActivityRecord activity = createActivityRecord(mDisplayContent, task);
        final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, activity, "win");

        mDisplayContent.setImeLayeringTarget(win);
        mDisplayContent.setImeInputTarget(win);
        spyOn(mDisplayContent);
        spyOn(mDisplayContent.mInputMethodWindow);
        doReturn(true).when(mDisplayContent.mInputMethodWindow).isVisible();
        mDisplayContent.getInsetsStateController().getImeSourceProvider().setImeShowing(true);

        // Verify when the timing of 2 showImeScreenshot invocations are very close, will first
        // detach the current snapshot then create the next one.
        mDisplayContent.showImeScreenshot();
        DisplayContent.ImeScreenshot curSnapshot = mDisplayContent.mImeScreenshot;
        spyOn(curSnapshot);
        mDisplayContent.showImeScreenshot();
        verify(curSnapshot).detach(any());
        assertNotNull(mDisplayContent.mImeScreenshot);
        assertNotEquals(curSnapshot, mDisplayContent.mImeScreenshot);
    }

    @Test
    public void testRotateBounds_keepSamePhysicalPosition() {
        final DisplayContent dc =