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

Commit 5e848712 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only apply an IME target change if it's the current controlTarget" into main

parents ec79f3cc 56436513
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -321,7 +321,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
        if (Flags.refactorInsetsController()) {
        if (Flags.refactorInsetsController()) {
            // TODO(b/353463205) investigate if we should fail the statsToken, or if it's only
            // TODO(b/353463205) investigate if we should fail the statsToken, or if it's only
            //  temporary null.
            //  temporary null.
            if (target != null) {
            if (target != null && target == mControlTarget) {
                // If insets target is not available (e.g. RemoteInsetsControlTarget), use current
                // If insets target is not available (e.g. RemoteInsetsControlTarget), use current
                // IME input target to update IME request state. For example, switch from a task
                // IME input target to update IME request state. For example, switch from a task
                // with showing IME to a split-screen task without showing IME.
                // with showing IME to a split-screen task without showing IME.
@@ -334,6 +334,11 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
                } else {
                } else {
                    invokeOnImeRequestedChangedListener(target, statsToken);
                    invokeOnImeRequestedChangedListener(target, statsToken);
                }
                }
            } else {
                ProtoLog.w(WM_DEBUG_IME,
                        "Not invoking onImeRequestedChangedListener, target=%s, current "
                                + "controlTarget=%s",
                        target, mControlTarget);
            }
            }
        }
        }
    }
    }
+21 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
@@ -276,4 +278,23 @@ public class ImeInsetsSourceProviderTest extends WindowTestsBase {
        assertTrue(mImeProvider.isServerVisible());
        assertTrue(mImeProvider.isServerVisible());
        assertTrue(mImeProvider.isSurfaceVisible());
        assertTrue(mImeProvider.isSurfaceVisible());
    }
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER)
    public void testUpdateControlForTarget_differentControlTarget() throws RemoteException {
        final WindowState oldTarget = newWindowBuilder("app", TYPE_APPLICATION).build();
        final WindowState newTarget = newWindowBuilder("newapp", TYPE_APPLICATION).build();

        oldTarget.setRequestedVisibleTypes(
                WindowInsets.Type.defaultVisible() | WindowInsets.Type.ime());
        mDisplayContent.setImeControlTarget(oldTarget);
        mDisplayContent.setImeInputTarget(newTarget);

        // Having a null windowContainer will early return in updateControlForTarget
        mImeProvider.setWindowContainer(null, null, null);

        clearInvocations(mDisplayContent);
        mImeProvider.updateControlForTarget(newTarget, false /* force */, ImeTracker.Token.empty());
        verify(mDisplayContent, never()).getImeInputTarget();
    }
}
}