diff options
| author | 2022-03-29 15:09:03 +0000 | |
|---|---|---|
| committer | 2022-03-29 15:09:03 +0000 | |
| commit | 841a55dc3a0d4593b6ac3b1a7efd13ef9ff659b0 (patch) | |
| tree | fdbb3bc8a40cf7327fe3908c7cd744057e44b35d | |
| parent | 14e9f41072c9d8fab711a3976fe82ea1e48ad4d8 (diff) | |
| parent | 1137b137ddbd1cbe139aad39f521fce8d84912eb (diff) | |
Merge "Fix IME snapshot missing to remove by 2 consecutive creation calls" into tm-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 4 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 8eb0046ff923..52651b9fd076 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -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); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 91692676e216..eb85d0098d17 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -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 = |