From 65ba861856ef0fb72075da0e1fba9b353019ea07 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Fri, 5 Nov 2021 23:23:17 +0800 Subject: [PATCH] Prevent resize animation from changing the requested visibilities The insets resize animation is used to produce the callbacks of the animation progress to the app. It shouldn't change the state of the insets controller. Fix: 205082601 Test: 1. Open a sticky-immersive app on a device which has taskbar. 2. Make sure taskbar is minimized on apps. 3. Swipe from bottom twice to go to home screen. 4. Open the same app again and see if task bar is hidden. Merged-In: I5d9213d7b3e32eccbf3a51335654f5f53899e6ae Change-Id: I5d9213d7b3e32eccbf3a51335654f5f53899e6ae (cherry picked from commit cb11735c85f4ded6fef2c84008e34c6156a42144) --- core/java/android/view/InsetsController.java | 5 +++++ core/java/android/view/InsetsResizeAnimationRunner.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index adda721e00a4f..9bf71ec809987 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -1266,6 +1266,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) { cancelAnimation(runner, false /* invokeCallback */); if (DEBUG) Log.d(TAG, "notifyFinished. shown: " + shown); + if (runner.getAnimationType() == ANIMATION_TYPE_RESIZE) { + // The resize animation doesn't show or hide the insets. We shouldn't change the + // requested visibility. + return; + } if (shown) { showDirectly(runner.getTypes(), true /* fromIme */); } else { diff --git a/core/java/android/view/InsetsResizeAnimationRunner.java b/core/java/android/view/InsetsResizeAnimationRunner.java index e1352dd8dd4f7..edcfc95fe4e43 100644 --- a/core/java/android/view/InsetsResizeAnimationRunner.java +++ b/core/java/android/view/InsetsResizeAnimationRunner.java @@ -131,6 +131,9 @@ public class InsetsResizeAnimationRunner implements InsetsAnimationControlRunner @Override public boolean applyChangeInsets(InsetsState outState) { + if (mCancelled) { + return false; + } final float fraction = mAnimation.getInterpolatedFraction(); for (@InternalInsetsType int type = 0; type < InsetsState.SIZE; type++) { final InsetsSource fromSource = mFromState.peekSource(type);