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

Commit 0c45be98 authored by Tiger's avatar Tiger Committed by Android Build Coastguard Worker
Browse files

Update mPosition when creating a new InsetsSourceControl

This should be part of commit: ac6cde62
that InsetsSourceProvider.mPosition should always be the same as
InsetsSourceControl.mSurfacePosition except during mHasPendingPosition.

Fix: 370738846
Flag: EXEMPT bugfix
Test: Click on the IME switch button and see if the IME position is
      correct.
Test: atest InsetsSourceProviderTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b9474405880eb483cfda7c13111f985bf7d0247d)
Merged-In: I5de9a80cbbb601bbdf39009f962fb1175751db28
Change-Id: I5de9a80cbbb601bbdf39009f962fb1175751db28
parent 69f77e18
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ class InsetsSourceProvider {
        }
        final Point position = getWindowFrameSurfacePosition();
        if (!mPosition.equals(position)) {
            mPosition.set(position.x, position.y);
            mPosition.set(position);
            if (windowState != null && windowState.getWindowFrames().didFrameSizeChange()
                    && windowState.mWinAnimator.getShown() && mWindowContainer.okToDisplay()) {
                windowState.applyWithNextDraw(mSetControlPositionConsumer);
@@ -543,6 +543,7 @@ class InsetsSourceProvider {
        }
        boolean initiallyVisible = mClientVisible;
        final Point surfacePosition = getWindowFrameSurfacePosition();
        mPosition.set(surfacePosition);
        mAdapter = new ControlAdapter(surfacePosition);
        if (mSource.getType() == WindowInsets.Type.ime()) {
            if (android.view.inputmethod.Flags.refactorInsetsController()) {
+22 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.view.InsetsSource;
@@ -259,6 +260,27 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
        assertEquals(Insets.of(0, 0, 0, 100), insets);
    }

    @Test
    public void testUpdateInsetsControlPosition() {
        final WindowState target = createWindow(null, TYPE_APPLICATION, "target");

        final WindowState ime1 = createWindow(null, TYPE_INPUT_METHOD, "ime1");
        ime1.getFrame().set(new Rect(0, 0, 0, 0));
        mImeProvider.setWindowContainer(ime1, null, null);
        mImeProvider.updateControlForTarget(target, false /* force */, null /* statsToken */);
        ime1.getFrame().set(new Rect(0, 400, 500, 500));
        mImeProvider.updateInsetsControlPosition(ime1);
        assertEquals(new Point(0, 400), mImeProvider.getControl(target).getSurfacePosition());

        final WindowState ime2 = createWindow(null, TYPE_INPUT_METHOD, "ime2");
        ime2.getFrame().set(new Rect(0, 0, 0, 0));
        mImeProvider.setWindowContainer(ime2, null, null);
        mImeProvider.updateControlForTarget(target, false /* force */, null /* statsToken */);
        ime2.getFrame().set(new Rect(0, 400, 500, 500));
        mImeProvider.updateInsetsControlPosition(ime2);
        assertEquals(new Point(0, 400), mImeProvider.getControl(target).getSurfacePosition());
    }

    @Test
    public void testSetRequestedVisibleTypes() {
        final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");