From 79a873095806c2b93264f5216ff121b3639f1dff Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Tue, 9 May 2023 12:03:39 +0000 Subject: [PATCH] Apply root task for launch activity animation. When launch task embedded, the opening targets will includes the root task and other TaskFragments, so the animation should choose the root task as the animating target. Bug: 279542263 Test: manual, launch task embedded task from notification shade several times. Change-Id: I90278e22580b9afb356ab68057bd187f9d59dbc7 --- .../animation/ActivityLaunchAnimator.kt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 4037fd4a09d86..764a8556a54d7 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt @@ -508,6 +508,26 @@ class ActivityLaunchAnimator( startAnimation(apps, nonApps, callback) } + private fun findRootTaskIfPossible( + apps: Array? + ): RemoteAnimationTarget? { + if (apps == null) { + return null + } + var candidate: RemoteAnimationTarget? = null + for (it in apps) { + if (it.mode == RemoteAnimationTarget.MODE_OPENING) { + if (it.taskInfo != null && !it.hasAnimatingParent) { + return it + } + if (candidate == null) { + candidate = it + } + } + } + return candidate + } + private fun startAnimation( apps: Array?, nonApps: Array?, @@ -517,8 +537,7 @@ class ActivityLaunchAnimator( Log.d(TAG, "Remote animation started") } - val window = apps?.firstOrNull { it.mode == RemoteAnimationTarget.MODE_OPENING } - + val window = findRootTaskIfPossible(apps) if (window == null) { Log.i(TAG, "Aborting the animation as no window is opening") removeTimeout()