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

Commit adf9c428 authored by Jagrut Desai's avatar Jagrut Desai Committed by Android (Google) Code Review
Browse files

Merge "Adding gesture error detection to RecentsAnimationCallback" into main

parents 2d1d1419 3a3bf975
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;

import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.CANCEL_RECENTS_ANIMATION;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.START_RECENTS_ANIMATION;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_CANCEL_RECENTS_ANIMATION;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_FINISH_RECENTS_ANIMATION;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_START_RECENTS_ANIMATION;

import android.graphics.Rect;
import android.os.Bundle;
@@ -112,7 +113,7 @@ public class RecentsAnimationCallbacks implements
            ActiveGestureLog.INSTANCE.addLog(
                    /* event= */ "RecentsAnimationCallbacks.onAnimationStart (canceled)",
                    /* extras= */ 0,
                    /* gestureEvent= */ START_RECENTS_ANIMATION);
                    /* gestureEvent= */ ON_START_RECENTS_ANIMATION);
            notifyAnimationCanceled();
            animationController.finish(false /* toHome */, false /* sendUserLeaveHint */);
            return;
@@ -145,7 +146,7 @@ public class RecentsAnimationCallbacks implements
                ActiveGestureLog.INSTANCE.addLog(
                        /* event= */ "RecentsAnimationCallbacks.onAnimationStart",
                        /* extras= */ targets.apps.length,
                        /* gestureEvent= */ START_RECENTS_ANIMATION);
                        /* gestureEvent= */ ON_START_RECENTS_ANIMATION);
                for (RecentsAnimationListener listener : getListeners()) {
                    listener.onRecentsAnimationStart(mController, targets);
                }
@@ -159,7 +160,7 @@ public class RecentsAnimationCallbacks implements
        Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> {
            ActiveGestureLog.INSTANCE.addLog(
                    /* event= */ "RecentsAnimationCallbacks.onAnimationCanceled",
                    /* gestureEvent= */ CANCEL_RECENTS_ANIMATION);
                    /* gestureEvent= */ ON_CANCEL_RECENTS_ANIMATION);
            for (RecentsAnimationListener listener : getListeners()) {
                listener.onRecentsAnimationCanceled(thumbnailDatas);
            }
@@ -193,7 +194,8 @@ public class RecentsAnimationCallbacks implements
    private final void onAnimationFinished(RecentsAnimationController controller) {
        Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> {
            ActiveGestureLog.INSTANCE.addLog(
                    /* event= */ "RecentsAnimationCallbacks.onAnimationFinished");
                    /* event= */ "RecentsAnimationCallbacks.onAnimationFinished",
                    ON_FINISH_RECENTS_ANIMATION);
            for (RecentsAnimationListener listener : getListeners()) {
                listener.onRecentsAnimationFinished(controller);
            }
+51 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ public class ActiveGestureErrorDetector {
    public enum GestureEvent {
        MOTION_DOWN, MOTION_UP, MOTION_MOVE, SET_END_TARGET, SET_END_TARGET_HOME,
        SET_END_TARGET_NEW_TASK, SET_END_TARGET_ALL_APPS, ON_SETTLED_ON_END_TARGET,
        ON_START_RECENTS_ANIMATION, ON_FINISH_RECENTS_ANIMATION, ON_CANCEL_RECENTS_ANIMATION,
        START_RECENTS_ANIMATION, FINISH_RECENTS_ANIMATION, CANCEL_RECENTS_ANIMATION,
        SET_ON_PAGE_TRANSITION_END_CALLBACK, CANCEL_CURRENT_ANIMATION, CLEANUP_SCREENSHOT,
        SCROLLER_ANIMATION_ABORTED, TASK_APPEARED, EXPECTING_TASK_APPEARED,
@@ -226,6 +227,32 @@ public class ActiveGestureErrorDetector {
                                    + " couldn't start the recents activity",
                            writer);
                    break;
                case ON_START_RECENTS_ANIMATION:
                    errorDetected |= printErrorIfTrue(
                            !encounteredEvents.contains(GestureEvent.START_RECENTS_ANIMATION),
                            prefix,
                            /* errorMessage= */ "ON_START_RECENTS_ANIMATION "
                                    + "onAnimationStart callback ran before startRecentsAnimation",
                            writer);
                    break;
                case ON_CANCEL_RECENTS_ANIMATION:
                    errorDetected |= printErrorIfTrue(
                            !encounteredEvents.contains(GestureEvent.ON_START_RECENTS_ANIMATION),
                            prefix,
                            /* errorMessage= */ "ON_CANCEL_RECENTS_ANIMATION "
                                    + "onAnimationCanceled callback ran before onAnimationStart "
                                    + "callback",
                            writer);
                    break;
                case ON_FINISH_RECENTS_ANIMATION:
                    errorDetected |= printErrorIfTrue(
                            !encounteredEvents.contains(GestureEvent.ON_START_RECENTS_ANIMATION),
                            prefix,
                            /* errorMessage= */ "ON_FINISH_RECENTS_ANIMATION "
                                    + "onAnimationFinished callback ran before onAnimationStart "
                                    + "callback",
                            writer);
                    break;
                case MOTION_DOWN:
                case SET_END_TARGET:
                case SET_END_TARGET_HOME:
@@ -357,6 +384,30 @@ public class ActiveGestureErrorDetector {
                /* errorMessage= */ "onTaskAppeared was expected to be called but wasn't.",
                writer);

        errorDetected |= printErrorIfTrue(
                /* condition= */ encounteredEvents.contains(GestureEvent.START_RECENTS_ANIMATION)
                        && !encounteredEvents.contains(GestureEvent.ON_START_RECENTS_ANIMATION),
                prefix,
                /* errorMessage= */
                "startRecentAnimation was called but onAnimationStart callback was not",
                writer);
        errorDetected |= printErrorIfTrue(
                /* condition= */
                encounteredEvents.contains(GestureEvent.FINISH_RECENTS_ANIMATION)
                        && !encounteredEvents.contains(GestureEvent.ON_FINISH_RECENTS_ANIMATION),
                prefix,
                /* errorMessage= */
                "finishController was called but onAnimationFinished callback was not",
                writer);
        errorDetected |= printErrorIfTrue(
                /* condition= */
                encounteredEvents.contains(GestureEvent.CANCEL_RECENTS_ANIMATION)
                        && !encounteredEvents.contains(GestureEvent.ON_CANCEL_RECENTS_ANIMATION),
                prefix,
                /* errorMessage= */
                "onRecentsAnimationCanceled was called but onAnimationCanceled was not",
                writer);

        if (!errorDetected) {
            writer.println(prefix + "\tNo errors detected.");
        }