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
This commit is contained in:
Jerry Chang
2022-12-28 12:55:03 +00:00
parent b4838aa947
commit 49fb27a6b4
2 changed files with 23 additions and 11 deletions

View File

@@ -274,29 +274,30 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
}
if (hasImeSourceControl) {
final Point lastSurfacePosition = mImeSourceControl != null
? mImeSourceControl.getSurfacePosition() : null;
final boolean positionChanged =
!imeSourceControl.getSurfacePosition().equals(lastSurfacePosition);
final boolean leashChanged =
!haveSameLeash(mImeSourceControl, imeSourceControl);
if (mAnimation != null) {
final Point lastSurfacePosition = hadImeSourceControl
? mImeSourceControl.getSurfacePosition() : null;
final boolean positionChanged =
!imeSourceControl.getSurfacePosition().equals(lastSurfacePosition);
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);
}
}
mImeSourceControl = imeSourceControl;
} else if (mAnimation != null) {
mAnimation.cancel();
}
if (hadImeSourceControl && mImeSourceControl != imeSourceControl) {
mImeSourceControl.release(SurfaceControl::release);
}
mImeSourceControl = imeSourceControl;
}
private void applyVisibilityToLeash(InsetsSourceControl imeSourceControl) {

View File

@@ -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(