diff options
3 files changed, 21 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 17d0f08b19f9..ed055eb7eb09 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -729,7 +729,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo          // Sets mBehindIme for each window. Windows behind IME can get IME insets.          if (w.mBehindIme != mTmpWindowsBehindIme) {              w.mBehindIme = mTmpWindowsBehindIme; -            mWinInsetsChanged.add(w); +            if (getInsetsStateController().getRawInsetsState().getSourceOrDefaultVisibility( +                    ITYPE_IME)) { +                // If IME is invisible, behind IME or not doesn't make the insets different. +                mWinInsetsChanged.add(w); +            }          }          if (w == mInputMethodWindow) {              mTmpWindowsBehindIme = true; diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index e80d5937eb1f..63083faaddb1 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -246,7 +246,7 @@ class InsetsStateController {              // (e.g., z-order) have changed. They can affect the insets states that we dispatch to              // the clients.              for (int i = winInsetsChanged.size() - 1; i >= 0; i--) { -                winInsetsChanged.get(i).notifyInsetsChanged(); +                mDispatchInsetsChanged.accept(winInsetsChanged.get(i));              }          }          winInsetsChanged.clear(); diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java index 976ac2323989..0a27e1a1da68 100644 --- a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java @@ -30,7 +30,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;  import static org.junit.Assert.assertEquals;  import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals;  import static org.junit.Assert.assertNotNull;  import static org.junit.Assert.assertNull;  import static org.junit.Assert.assertTrue; @@ -41,7 +40,6 @@ import static org.mockito.Mockito.verify;  import android.graphics.Rect;  import android.platform.test.annotations.Presubmit; -import android.view.InsetsSource;  import android.view.InsetsSourceControl;  import android.view.InsetsState;  import android.view.test.InsetsModeSession; @@ -188,13 +186,23 @@ public class InsetsStateControllerTest extends WindowTestsBase {      @Test      public void testStripForDispatch_imeOrderChanged() { -        getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); +        // This can be the IME z-order target while app cannot be the IME z-order target. +        // This is also the only IME control target in this test, so IME won't be invisible caused +        // by the control-target change. +        mDisplayContent.mInputMethodInputTarget = createWindow(null, TYPE_APPLICATION, "base"); -        // This window can be the IME target while app cannot be the IME target. -        createWindow(null, TYPE_APPLICATION, "base"); +        // Make IME and stay visible during the test. +        mImeWindow.setHasSurface(true); +        getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); +        getController().onImeControlTargetChanged(mDisplayContent.mInputMethodInputTarget); +        final InsetsState requestedState = new InsetsState(); +        requestedState.getSource(ITYPE_IME).setVisible(true); +        mDisplayContent.mInputMethodInputTarget.updateRequestedInsetsState(requestedState); +        getController().onInsetsModified(mDisplayContent.mInputMethodInputTarget, requestedState);          // Send our spy window (app) into the system so that we can detect the invocation.          final WindowState win = createWindow(null, TYPE_APPLICATION, "app"); +        win.setHasSurface(true);          final WindowToken parent = win.mToken;          parent.removeChild(win);          final WindowState app = spy(win); @@ -206,7 +214,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {          mDisplayContent.applySurfaceChangesTransaction();          // app won't get visible IME insets while above IME even when IME is visible. -        getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); +        assertTrue(getController().getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME));          assertFalse(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());          // Reset invocation counter. @@ -220,8 +228,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {          // Make sure app got notified.          verify(app, atLeast(1)).notifyInsetsChanged(); -        // app will get visible IME insets while below IME when IME is visible. -        getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); +        // app will get visible IME insets while below IME.          assertTrue(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());      }  |