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

Commit 49fb27a6 authored by Jerry Chang's avatar Jerry Chang
Browse files

Fix IME not shown from recents to split-screen task

This reland Id7ac6de6 and make sure to cancel the running animation when
DisplayImeController no longer controlling IME.

Fix: 258814082
Fix: 251906905
Bug: 260534444
Test: repro steps of bugs
Test: atest DisplayImeControllerTest
Test: atest PlatformScenarioTests:BubblesHomeGestureTest
Change-Id: Ibf6055769fc114cdf23e6ecb5895f3a67b714350
parent b4838aa9
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -274,30 +274,31 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            }

            if (hasImeSourceControl) {
                final Point lastSurfacePosition = mImeSourceControl != null
                if (mAnimation != null) {
                    final Point lastSurfacePosition = hadImeSourceControl
                            ? mImeSourceControl.getSurfacePosition() : null;
                    final boolean positionChanged =
                            !imeSourceControl.getSurfacePosition().equals(lastSurfacePosition);
                final boolean leashChanged =
                        !haveSameLeash(mImeSourceControl, imeSourceControl);
                if (mAnimation != null) {
                    if (positionChanged) {
                        startAnimation(mImeShowing, true /* forceRestart */);
                    }
                } else {
                    if (leashChanged) {
                    if (!haveSameLeash(mImeSourceControl, imeSourceControl)) {
                        applyVisibilityToLeash(imeSourceControl);
                    }
                    if (!mImeShowing) {
                        removeImeSurface();
                    }
                    if (mImeSourceControl != null) {
                        mImeSourceControl.release(SurfaceControl::release);
                }
            } else if (mAnimation != null) {
                mAnimation.cancel();
            }

            if (hadImeSourceControl && mImeSourceControl != imeSourceControl) {
                mImeSourceControl.release(SurfaceControl::release);
            }
            mImeSourceControl = imeSourceControl;
        }
        }

        private void applyVisibilityToLeash(InsetsSourceControl imeSourceControl) {
            SurfaceControl leash = imeSourceControl.getLeash();
+11 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static android.view.Surface.ROTATION_0;
import static android.view.WindowInsets.Type.ime;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -131,6 +133,15 @@ public class DisplayImeControllerTest extends ShellTestCase {
        verify(mT).show(any());
    }

    @Test
    public void insetsControlChanged_updateImeSourceControl() {
        mPerDisplay.insetsControlChanged(insetsStateWithIme(false), insetsSourceControl());
        assertNotNull(mPerDisplay.mImeSourceControl);

        mPerDisplay.insetsControlChanged(new InsetsState(), new InsetsSourceControl[]{});
        assertNull(mPerDisplay.mImeSourceControl);
    }

    private InsetsSourceControl[] insetsSourceControl() {
        return new InsetsSourceControl[]{
                new InsetsSourceControl(