Merge "Fix IME insets animation stucked by wrong InsetsHint" into tm-dev am: 801a65da09
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18186208 Change-Id: I651fe4fe1d5d9669280ab3ee839a8220ced5ade0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -82,6 +82,7 @@ abstract class InsetsSourceProvider {
|
|||||||
private boolean mIsLeashReadyForDispatching;
|
private boolean mIsLeashReadyForDispatching;
|
||||||
private final Rect mSourceFrame = new Rect();
|
private final Rect mSourceFrame = new Rect();
|
||||||
private final Rect mLastSourceFrame = new Rect();
|
private final Rect mLastSourceFrame = new Rect();
|
||||||
|
private @NonNull Insets mInsetsHint = Insets.NONE;
|
||||||
|
|
||||||
private final Consumer<Transaction> mSetLeashPositionConsumer = t -> {
|
private final Consumer<Transaction> mSetLeashPositionConsumer = t -> {
|
||||||
if (mControl != null) {
|
if (mControl != null) {
|
||||||
@@ -298,6 +299,7 @@ abstract class InsetsSourceProvider {
|
|||||||
if (!insetsHint.equals(mControl.getInsetsHint())) {
|
if (!insetsHint.equals(mControl.getInsetsHint())) {
|
||||||
changed = true;
|
changed = true;
|
||||||
mControl.setInsetsHint(insetsHint);
|
mControl.setInsetsHint(insetsHint);
|
||||||
|
mInsetsHint = insetsHint;
|
||||||
}
|
}
|
||||||
mLastSourceFrame.set(mSource.getFrame());
|
mLastSourceFrame.set(mSource.getFrame());
|
||||||
}
|
}
|
||||||
@@ -433,8 +435,8 @@ abstract class InsetsSourceProvider {
|
|||||||
final SurfaceControl leash = mAdapter.mCapturedLeash;
|
final SurfaceControl leash = mAdapter.mCapturedLeash;
|
||||||
mControlTarget = target;
|
mControlTarget = target;
|
||||||
updateVisibility();
|
updateVisibility();
|
||||||
mControl = new InsetsSourceControl(mSource.getType(), leash, surfacePosition,
|
mControl = new InsetsSourceControl(mSource.getType(), leash, surfacePosition, mInsetsHint);
|
||||||
mSource.calculateInsets(mWindowContainer.getBounds(), true /* ignoreVisibility */));
|
|
||||||
ProtoLog.d(WM_DEBUG_WINDOW_INSETS,
|
ProtoLog.d(WM_DEBUG_WINDOW_INSETS,
|
||||||
"InsetsSource Control %s for target %s", mControl, mControlTarget);
|
"InsetsSource Control %s for target %s", mControl, mControlTarget);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,6 +449,36 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
|||||||
assertNotNull(app.getInsetsState().peekSource(ITYPE_NAVIGATION_BAR));
|
assertNotNull(app.getInsetsState().peekSource(ITYPE_NAVIGATION_BAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||||
|
@Test
|
||||||
|
public void testGetInsetsHintForNewControl() {
|
||||||
|
final WindowState app1 = createTestWindow("app1");
|
||||||
|
final WindowState app2 = createTestWindow("app2");
|
||||||
|
|
||||||
|
makeWindowVisible(mImeWindow);
|
||||||
|
final InsetsSourceProvider imeInsetsProvider = getController().getSourceProvider(ITYPE_IME);
|
||||||
|
imeInsetsProvider.setWindowContainer(mImeWindow, null, null);
|
||||||
|
imeInsetsProvider.updateSourceFrame(mImeWindow.getFrame());
|
||||||
|
|
||||||
|
imeInsetsProvider.updateControlForTarget(app1, false);
|
||||||
|
imeInsetsProvider.onPostLayout();
|
||||||
|
final InsetsSourceControl control1 = imeInsetsProvider.getControl(app1);
|
||||||
|
assertNotNull(control1);
|
||||||
|
assertEquals(imeInsetsProvider.getSource().getFrame().height(),
|
||||||
|
control1.getInsetsHint().bottom);
|
||||||
|
|
||||||
|
// Simulate the IME control target updated from app1 to app2 when IME insets was invisible.
|
||||||
|
imeInsetsProvider.setServerVisible(false);
|
||||||
|
imeInsetsProvider.updateControlForTarget(app2, false);
|
||||||
|
|
||||||
|
// Verify insetsHint of the new control is same as last IME source frame after the layout.
|
||||||
|
imeInsetsProvider.onPostLayout();
|
||||||
|
final InsetsSourceControl control2 = imeInsetsProvider.getControl(app2);
|
||||||
|
assertNotNull(control2);
|
||||||
|
assertEquals(imeInsetsProvider.getSource().getFrame().height(),
|
||||||
|
control2.getInsetsHint().bottom);
|
||||||
|
}
|
||||||
|
|
||||||
private WindowState createTestWindow(String name) {
|
private WindowState createTestWindow(String name) {
|
||||||
final WindowState win = createWindow(null, TYPE_APPLICATION, name);
|
final WindowState win = createWindow(null, TYPE_APPLICATION, name);
|
||||||
win.setHasSurface(true);
|
win.setHasSurface(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user