From 796874386a7e5fc59fd7e932e99381f8c90ccb7c Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 6 Jul 2021 11:50:46 +0800 Subject: [PATCH] Wait starting window finished in syncInputTransactions This CL is attempt to fix the test flakiness happens when invoking tapOnDisplayCenter on the test activity but the starting window is still exists. Use ActivityRecord#hasStartingWindow to check all running activities to ensure input window transations will wait until the starting window has finished animating. Bug: 191996095 Test: atest MultiDisplaySystemDecorationTests#\ testDisplayPolicyImeHideImeNoSystemDecorations --iterations 100 Change-Id: Ie9ca44a7b4c972fc1393d9ce55a5982a2b62dac7 (cherry picked from commit 5e1b80b1db99397cf3905a8a5fbc6fd8a7790741) --- .../com/android/server/wm/WindowManagerService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index f37be64af18ed..1265744185d2f 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -8117,9 +8117,15 @@ public class WindowManagerService extends IWindowManager.Stub // This could prevent if there is no container animation, we still have to apply the // pending transaction and exit waiting. mAnimator.mNotifyWhenNoAnimation = true; + boolean animateStarting = false; while (timeoutRemaining > 0) { + // Waiting until all starting windows has finished animating. + animateStarting = mRoot.forAllActivities(a -> { + return a.hasStartingWindow(); + }); boolean isAnimating = mAnimator.isAnimationScheduled() - || mRoot.isAnimating(TRANSITION | CHILDREN, ANIMATION_TYPE_ALL); + || mRoot.isAnimating(TRANSITION | CHILDREN, ANIMATION_TYPE_ALL) + || animateStarting; if (!isAnimating) { // isAnimating is a legacy transition query and will be removed, so also add // a check for whether this is in a shell-transition when not using legacy. @@ -8139,13 +8145,14 @@ public class WindowManagerService extends IWindowManager.Stub WindowContainer animatingContainer; animatingContainer = mRoot.getAnimatingContainer(TRANSITION | CHILDREN, ANIMATION_TYPE_ALL); - if (mAnimator.isAnimationScheduled() || animatingContainer != null) { + if (mAnimator.isAnimationScheduled() || animatingContainer != null || animateStarting) { Slog.w(TAG, "Timed out waiting for animations to complete," + " animatingContainer=" + animatingContainer + " animationType=" + SurfaceAnimator.animationTypeToString( animatingContainer != null ? animatingContainer.mSurfaceAnimator.getAnimationType() - : SurfaceAnimator.ANIMATION_TYPE_NONE)); + : SurfaceAnimator.ANIMATION_TYPE_NONE) + + " animateStarting=" + animateStarting); } } }