diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt index 1b56d4a201d981d93b732a2fa1980becb21f5415..0f2e4bace46d552f48ba417f19ed1741d45ade22 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt @@ -25,6 +25,7 @@ import android.graphics.Path import android.graphics.Rect import android.graphics.RectF import android.os.Build +import android.os.Handler import android.os.Looper import android.os.RemoteException import android.util.Log @@ -58,7 +59,14 @@ class ActivityLaunchAnimator( /** The animator used when animating a Dialog into an app. */ // TODO(b/218989950): Remove this animator and instead set the duration of the dim fade out to // TIMINGS.contentBeforeFadeOutDuration. - private val dialogToAppAnimator: LaunchAnimator = DEFAULT_DIALOG_TO_APP_ANIMATOR + private val dialogToAppAnimator: LaunchAnimator = DEFAULT_DIALOG_TO_APP_ANIMATOR, + + /** + * Whether we should disable the WindowManager timeout. This should be set to true in tests + * only. + */ + // TODO(b/301385865): Remove this flag. + private val disableWmTimeout: Boolean = false, ) { companion object { /** The timings when animating a View into an app. */ @@ -252,7 +260,7 @@ class ActivityLaunchAnimator( Log.d( TAG, "Calling controller.onIntentStarted(willAnimate=$willAnimate) " + - "[controller=$this]" + "[controller=$this]" ) } this.onIntentStarted(willAnimate) @@ -431,7 +439,8 @@ class ActivityLaunchAnimator( internal val delegate: AnimationDelegate init { - delegate = AnimationDelegate(controller, callback, listener, launchAnimator) + delegate = + AnimationDelegate(controller, callback, listener, launchAnimator, disableWmTimeout) } @BinderThread @@ -461,13 +470,26 @@ class ActivityLaunchAnimator( /** Listener for animation lifecycle events. */ private val listener: Listener? = null, /** The animator to use to animate the window launch. */ - private val launchAnimator: LaunchAnimator = DEFAULT_LAUNCH_ANIMATOR + private val launchAnimator: LaunchAnimator = DEFAULT_LAUNCH_ANIMATOR, + + /** + * Whether we should disable the WindowManager timeout. This should be set to true in tests + * only. + */ + // TODO(b/301385865): Remove this flag. + disableWmTimeout: Boolean = false, ) : RemoteAnimationDelegate<IRemoteAnimationFinishedCallback> { private val launchContainer = controller.launchContainer private val context = launchContainer.context private val transactionApplierView = controller.openingWindowSyncView ?: controller.launchContainer private val transactionApplier = SyncRtSurfaceTransactionApplier(transactionApplierView) + private val timeoutHandler = + if (!disableWmTimeout) { + Handler(Looper.getMainLooper()) + } else { + null + } private val matrix = Matrix() private val invertMatrix = Matrix() @@ -487,11 +509,11 @@ class ActivityLaunchAnimator( @UiThread internal fun postTimeout() { - launchContainer.postDelayed(onTimeout, LAUNCH_TIMEOUT) + timeoutHandler?.postDelayed(onTimeout, LAUNCH_TIMEOUT) } private fun removeTimeout() { - launchContainer.removeCallbacks(onTimeout) + timeoutHandler?.removeCallbacks(onTimeout) } @UiThread diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt index cc004363a0499905f88ee174372562a5b24e7307..59c7e7669b63ccb8d93f7f2c452315a83108ecdb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt @@ -57,7 +57,8 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() { @Before fun setup() { - activityLaunchAnimator = ActivityLaunchAnimator(testLaunchAnimator, testLaunchAnimator) + activityLaunchAnimator = + ActivityLaunchAnimator(testLaunchAnimator, testLaunchAnimator, disableWmTimeout = true) activityLaunchAnimator.callback = callback activityLaunchAnimator.addListener(listener) }