From 785a7511b69570c6b25d04086bf55275dba04f08 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 31 Aug 2023 14:27:33 -0400 Subject: [PATCH] Add error handling to prevent IllegalArgumentException ActivityLaunchAnimator.Controller.fromView requires an instance of LaunchableView, however findViewWithBackground had no checks to return one. updated the check to make the exception less likely. Flag: not needed Fixes: 297564681 Test: ran launcher and launched apps Change-Id: Iddbe55c1ff66b067f8456d058cbc60a2a698c4ae Merged-In: Iddbe55c1ff66b067f8456d058cbc60a2a698c4ae --- .../launcher3/QuickstepTransitionManager.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 110d2755bf..1df4ac8035 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -151,6 +151,7 @@ import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.animation.DelegateLaunchAnimatorController; +import com.android.systemui.animation.LaunchableView; import com.android.systemui.animation.RemoteAnimationDelegate; import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; @@ -1799,7 +1800,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener @Nullable private static ContainerAnimationRunner from( View v, StartingWindowListener startingWindowListener, RunnableList onEndCallback) { - View viewToUse = findViewWithBackground(v); + View viewToUse = findLaunchableViewWithBackground(v); if (viewToUse == null) { viewToUse = v; } @@ -1837,11 +1838,15 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener new ActivityLaunchAnimator.AnimationDelegate(controller, callback, listener)); } - /** Finds the closest parent of [view] (inclusive) with a background drawable. */ + /** + * Finds the closest parent of [view] (inclusive) that implements {@link LaunchableView} and + * has a background drawable. + */ @Nullable - private static View findViewWithBackground(View view) { + private static T findLaunchableViewWithBackground( + View view) { View current = view; - while (current.getBackground() == null) { + while (current.getBackground() == null || !(current instanceof LaunchableView)) { if (!(current.getParent() instanceof View)) { return null; } @@ -1849,7 +1854,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener current = (View) view.getParent(); } - return current; + return (T) current; } @Override