Use opening window with largest screen area during ActivityTransition
When determining the endState while starting an ActivityTransition animation, we were taking the first app in the set of opening apps without a parent in the same transition. This left us with incorrect endState bounds when PIP was active and we were launching a fullscreen activity behind it, as we took the bounds of the PIP window instead of the fullscreen bounds. This change simply tweaks the behavior so we grab the app with the largest screenspace bounds as the endState.
Bug: 323294573
Test: Manually verified endState bounds via logging during both PIP and non-PIP activity launch
Flag: NONE
Change-Id: I719c9f04c811dc973d1fc2db095794e1ada164f7
diff --git a/packages/SystemUI/animation/Android.bp b/packages/SystemUI/animation/Android.bp
index 99b7c36..2268d16 100644
--- a/packages/SystemUI/animation/Android.bp
+++ b/packages/SystemUI/animation/Android.bp
@@ -44,6 +44,7 @@
"androidx.core_core-animation-nodeps",
"androidx.core_core-ktx",
"androidx.annotation_annotation",
+ "com_android_systemui_flags_lib",
"SystemUIShaderLib",
"WindowManager-Shell-shared",
"animationlib",
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
index 1b99e19..ea1cb34 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
@@ -43,6 +43,7 @@
import com.android.app.animation.Interpolators
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.policy.ScreenDecorationsUtils
+import com.android.systemui.Flags.activityTransitionUseLargestWindow
import kotlin.math.roundToInt
private const val TAG = "ActivityTransitionAnimator"
@@ -648,11 +649,27 @@
var candidate: RemoteAnimationTarget? = null
for (it in apps) {
if (it.mode == RemoteAnimationTarget.MODE_OPENING) {
- if (!it.hasAnimatingParent) {
- return it
- }
- if (candidate == null) {
- candidate = it
+ if (activityTransitionUseLargestWindow()) {
+ if (
+ candidate == null ||
+ !it.hasAnimatingParent && candidate.hasAnimatingParent
+ ) {
+ candidate = it
+ continue
+ }
+ if (
+ !it.hasAnimatingParent &&
+ it.screenSpaceBounds.hasGreaterAreaThan(candidate.screenSpaceBounds)
+ ) {
+ candidate = it
+ }
+ } else {
+ if (!it.hasAnimatingParent) {
+ return it
+ }
+ if (candidate == null) {
+ candidate = it
+ }
}
}
}
@@ -960,5 +977,9 @@
e.printStackTrace()
}
}
+
+ private fun Rect.hasGreaterAreaThan(other: Rect): Boolean {
+ return (this.width() * this.height()) > (other.width() * other.height())
+ }
}
}