From c2568d6c5898f46e04c97c62c75a9c9e713f6940 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Thu, 1 Apr 2021 02:22:22 +0800 Subject: [PATCH] Set mIsAnimationPending when the leash is not ready The server might return a control without a leash to a client while the setup-transaction of the leash has not been applied yet. If the client tries to play the animation with the control, the animation won't take effect. This CL sets mIsAnimationPending while changing the requested visibility while the leash of the real control (not the fake one in transient mode) is not ready. So when the client receives the leash later, the animation will be played. Fix: 183362710 Test: steps in the bug Change-Id: I53108bacf98ac76c3f1e46cdae0a98581bef77f5 --- core/java/android/view/InsetsController.java | 2 +- core/java/android/view/InsetsSourceConsumer.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index c001ec9da3a46..c201e3beb9b2f 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -1131,7 +1131,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation continue; } final InsetsSourceControl control = consumer.getControl(); - if (control != null) { + if (control != null && control.getLeash() != null) { controls.put(consumer.getType(), new InsetsSourceControl(control)); typesReady |= toPublicType(consumer.getType()); } else if (animationType == ANIMATION_TYPE_SHOW) { diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index bc50dbe311b91..8e50fed7f3923 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -33,6 +33,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PACK import android.annotation.IntDef; import android.annotation.Nullable; +import android.graphics.Insets; import android.graphics.Rect; import android.util.Log; import android.util.imetracing.ImeTracing; @@ -240,10 +241,6 @@ public class InsetsSourceConsumer { mHasWindowFocus = false; } - boolean hasWindowFocus() { - return mHasWindowFocus; - } - boolean hasViewFocusWhenWindowFocusGain() { return mHasViewFocusWhenWindowFocusGain; } @@ -366,7 +363,16 @@ public class InsetsSourceConsumer { protected void setRequestedVisible(boolean requestedVisible) { if (mRequestedVisible != requestedVisible) { mRequestedVisible = requestedVisible; - mIsAnimationPending = false; + + // We need an animation later if the leash of a real control (which has an insets hint) + // is not ready. The !mIsAnimationPending check is in case that the requested visibility + // is changed twice before playing the animation -- we don't need an animation in this + // case. + mIsAnimationPending = !mIsAnimationPending + && mSourceControl != null + && mSourceControl.getLeash() == null + && !Insets.NONE.equals(mSourceControl.getInsetsHint()); + mController.onRequestedVisibilityChanged(this); if (DEBUG) Log.d(TAG, "setRequestedVisible: " + requestedVisible); }