Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64ad4e34 authored by Jordan Silva's avatar Jordan Silva
Browse files

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
parent 64832004
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>,
            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<STATE_TYPE extends BaseState<STATE_TYPE>,

            // Run any queued runnable
            if (listener != null) {
                listener.onAnimationEnd(null);
                listener.onAnimationEnd(new AnimatorSet());
            }
            return;
        }