Merge "Prevent Insets side visibility change during animation"
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 3c93bb7..bc70d63 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -467,6 +467,10 @@
         }
     }
 
+    boolean isAnimating() {
+        return mAnimationDirection != DIRECTION_NONE;
+    }
+
     private InsetsSourceConsumer createConsumerOfType(int type) {
         if (type == ITYPE_IME) {
             return new ImeInsetsSourceConsumer(mState, Transaction::new, this);
@@ -514,6 +518,7 @@
                 } else {
                     hideDirectly(types);
                 }
+                mAnimationDirection = show ? DIRECTION_SHOW : DIRECTION_HIDE;
                 mAnimator = ObjectAnimator.ofObject(
                         controller,
                         new InsetsProperty(),
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index b1caf18..c6d9898 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -167,7 +167,8 @@
     }
 
     private void applyHiddenToControl() {
-        if (mSourceControl == null || mSourceControl.getLeash() == null) {
+        if (mSourceControl == null || mSourceControl.getLeash() == null
+                || mController.isAnimating()) {
             return;
         }