From af3d637313dc1e875b6c9644fac63f0e8d402d3d Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Thu, 14 May 2020 19:01:11 -0700 Subject: [PATCH] Ignore empty frames in ime-controller. Locking the screen was causing the ime insetssource to report an empty frame. This isn't a valid frame for animation, so don't use it in the animator. Bug: 156287058 Test: enter split-screen, open ime in second split, lock/unlock. Change-Id: Id99b744670b8be583389b763c3180d958e6777ae --- .../systemui/wm/DisplayImeController.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java index c7e9accce093d..2968b92f51b79 100644 --- a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java +++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java @@ -178,6 +178,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged ValueAnimator mAnimation = null; int mRotation = Surface.ROTATION_0; boolean mImeShowing = false; + final Rect mImeFrame = new Rect(); PerDisplay(int displayId, int initialRotation) { mDisplayId = displayId; @@ -254,8 +255,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged } } - private int imeTop(InsetsSource imeSource, float surfaceOffset) { - return imeSource.getFrame().top + (int) surfaceOffset; + private int imeTop(float surfaceOffset) { + return mImeFrame.top + (int) surfaceOffset; } private void startAnimation(final boolean show, final boolean forceRestart) { @@ -263,6 +264,11 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged if (imeSource == null || mImeSourceControl == null) { return; } + // Set frame, but only if the new frame isn't empty -- this maintains continuity + final Rect newFrame = imeSource.getFrame(); + if (newFrame.height() != 0) { + mImeFrame.set(newFrame); + } mHandler.post(() -> { if (DEBUG) { Slog.d(TAG, "Run startAnim show:" + show + " was:" @@ -284,7 +290,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged } final float defaultY = mImeSourceControl.getSurfacePosition().y; final float x = mImeSourceControl.getSurfacePosition().x; - final float hiddenY = defaultY + imeSource.getFrame().height(); + final float hiddenY = defaultY + mImeFrame.height(); final float shownY = defaultY; final float startY = show ? hiddenY : shownY; final float endY = show ? shownY : hiddenY; @@ -306,7 +312,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged SurfaceControl.Transaction t = mTransactionPool.acquire(); float value = (float) animation.getAnimatedValue(); t.setPosition(mImeSourceControl.getLeash(), x, value); - dispatchPositionChanged(mDisplayId, imeTop(imeSource, value), t); + dispatchPositionChanged(mDisplayId, imeTop(value), t); t.apply(); mTransactionPool.release(t); }); @@ -319,11 +325,11 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged t.setPosition(mImeSourceControl.getLeash(), x, startY); if (DEBUG) { Slog.d(TAG, "onAnimationStart d:" + mDisplayId + " top:" - + imeTop(imeSource, hiddenY) + "->" + imeTop(imeSource, shownY) + + imeTop(hiddenY) + "->" + imeTop(shownY) + " showing:" + (mAnimationDirection == DIRECTION_SHOW)); } - dispatchStartPositioning(mDisplayId, imeTop(imeSource, hiddenY), - imeTop(imeSource, shownY), mAnimationDirection == DIRECTION_SHOW, + dispatchStartPositioning(mDisplayId, imeTop(hiddenY), + imeTop(shownY), mAnimationDirection == DIRECTION_SHOW, t); if (mAnimationDirection == DIRECTION_SHOW) { t.show(mImeSourceControl.getLeash());