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

Commit fc45e260 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Only notify insets changed caused by z-order under some...

Merge "Merge "Only notify insets changed caused by z-order under some conditions" into rvc-dev am: 0d145e89 am: 17a684ff" into rvc-d1-dev-plus-aosp
parents b45df911 c20146e4
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -729,8 +729,12 @@ 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;
            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;
        }
+1 −1
Original line number Diff line number Diff line
@@ -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();
+15 −8
Original line number Diff line number Diff line
@@ -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());
    }