diff --git a/core/java/android/view/InsetsAnimationControlCallbacks.java b/core/java/android/view/InsetsAnimationControlCallbacks.java index 4227f78564a7f..74c186948b2f2 100644 --- a/core/java/android/view/InsetsAnimationControlCallbacks.java +++ b/core/java/android/view/InsetsAnimationControlCallbacks.java @@ -40,8 +40,10 @@ public interface InsetsAnimationControlCallbacks { /** * Schedule the apply by posting the animation callback. + * + * @param runner The runner that requested applying insets */ - void scheduleApplyChangeInsets(); + void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner); /** * Finish the final steps after the animation. diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index ef6a9b212e926..05abc60321163 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -156,7 +156,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mPendingFraction = sanitize(fraction); mPendingInsets = sanitize(insets); mPendingAlpha = sanitize(alpha); - mController.scheduleApplyChangeInsets(); + mController.scheduleApplyChangeInsets(this); } @VisibleForTesting diff --git a/core/java/android/view/InsetsAnimationThreadControlRunner.java b/core/java/android/view/InsetsAnimationThreadControlRunner.java index 3870f26e9990b..9dfdd0604e6bc 100644 --- a/core/java/android/view/InsetsAnimationThreadControlRunner.java +++ b/core/java/android/view/InsetsAnimationThreadControlRunner.java @@ -54,7 +54,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } @Override - public void scheduleApplyChangeInsets() { + public void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner) { mControl.applyChangeInsets(mState); } diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index 8eb9b5f6ef234..72ddaca27a768 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -1076,8 +1076,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting @Override - public void scheduleApplyChangeInsets() { - if (mStartingAnimation) { + public void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner) { + if (mStartingAnimation || runner.getAnimationType() == ANIMATION_TYPE_USER) { mAnimCallback.run(); mAnimCallbackScheduled = false; return; diff --git a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java index 9d251dac7c784..5f12bf04d931b 100644 --- a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java +++ b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java @@ -229,7 +229,7 @@ public class InsetsAnimationControlImplTest { doAnswer(invocation -> { mController.applyChangeInsets(mInsetsState); return null; - }).when(mMockController).scheduleApplyChangeInsets(); + }).when(mMockController).scheduleApplyChangeInsets(any()); mController.finish(true /* shown */); assertEquals(Insets.of(0, 100, 100, 0), mController.getCurrentInsets()); verify(mMockController).notifyFinished(eq(mController), eq(true /* shown */)); diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index 9e954f29438c6..007af249c580e 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -398,7 +398,7 @@ class InsetsPolicy { /** Called on SurfaceAnimationThread without global WM lock held. */ @Override - public void scheduleApplyChangeInsets() { + public void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner) { InsetsState state = getState(); if (mAnimationControl.applyChangeInsets(state)) { mAnimationControl.finish(mAnimatingShown);