From 64ad4e34ab865ea45dc19288dae1d04d0c23001a Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Thu, 5 Sep 2024 15:13:58 +0100 Subject: [PATCH] Fix Overview crash with 3 button navigation when animation is disabled The OverviewCommandHelper conversion to kotlin introduced a bug when using 3-button-navigation to go to Overview when the animation is disabled. A NullPointerException happens in the AnimatorListenerAdapter implementation in OverviewCommandHelper when StateManager.goToState calls onAnimationEnd providing a null argument to a function that shouldn't allow a null value. The abstract class AnimatorListenerAdapter implements AnimatorListener functions containing @NonNull Animator. However, AnimatorListenerAdapter overrides the interface functions without adding a @NonNull annotation in the arguments. In Java, this is allowed, causing only a warning. In Kotlin, due to the null safety nature, the compiler forces a null check for nullable types and doesn't allow the implementation of a @NonNull argument to become nullable. To fix this issue we created a empty AnimatorSet to provide to onAnimationEnd instead of null. For more context when @NonNull was added: - The @NonNull annotation was added to fix b/206801689, however it was never updated for AnimatorListenerAdapterImproved Commit Message Fix: 364860731 Bug: 352046797 Flag: EXEMPT bugfix Test: Manual. Instructions in the bug. Change-Id: I120af3d75e614581d6ac0f867a8c6f9419ee1bd3 --- src/com/android/launcher3/statemanager/StateManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java index ac07c0f2cf..303290dda3 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -253,7 +253,7 @@ public class StateManager, if (mConfig.currentAnimation == null) { // Run any queued runnable if (listener != null) { - listener.onAnimationEnd(null); + listener.onAnimationEnd(new AnimatorSet()); } return; } else if ((!mConfig.isUserControlled() && animated && mConfig.targetState == state) @@ -282,7 +282,7 @@ public class StateManager, // Run any queued runnable if (listener != null) { - listener.onAnimationEnd(null); + listener.onAnimationEnd(new AnimatorSet()); } return; }