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

Commit 7d346bf9 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias Committed by Android (Google) Code Review
Browse files

Merge "Revert "Revert^2 "Cancel gestures on launcher destroy""" into tm-qpr-dev

parents b42c293a ece659d1
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHE
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.CANCEL_RECENTS_ANIMATION;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.EXPECTING_TASK_APPEARED;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.LAUNCHER_DESTROYED;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_SETTLED_ON_END_TARGET;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
@@ -183,7 +182,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
                    if (mActivity != activity) {
                        return;
                    }
                    handleActivityDestroyed();
                    mRecentsView = null;
                    mActivity = null;
                }
@@ -464,7 +462,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
            return false;
        }
        mStateCallback.resumeCallbacks();

        T createdActivity = mActivityInterface.getCreatedActivity();
        if (createdActivity != null) {
@@ -534,15 +531,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        return true;
    }

    private void handleActivityDestroyed() {
        ActiveGestureLog.INSTANCE.addLog("Launcher activity destroyed", LAUNCHER_DESTROYED);
        if (mActivityInterface.shouldCancelGestureOnDestroy()) {
            onGestureCancelled();
        } else {
            mStateCallback.pauseCallbacks();
        }
    }

    /**
     * Return true if the window should be translated horizontally if the recents view scrolls
     */
+0 −8
Original line number Diff line number Diff line
@@ -123,14 +123,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
    public abstract AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
            boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback);

    /**
     * Returns {@code true} iff an ongoing navigational gesture should be cancelled on activity
     * destroy. Otherwise, the MultiStateCallbacks will be paused until the activity is recreated.
     */
    public boolean shouldCancelGestureOnDestroy() {
        return true;
    }

    public abstract ActivityInitListener createActivityInitListener(
            Predicate<Boolean> onInitListener);

+0 −5
Original line number Diff line number Diff line
@@ -87,11 +87,6 @@ public final class FallbackActivityInterface extends
        return factory;
    }

    @Override
    public boolean shouldCancelGestureOnDestroy() {
        return false;
    }

    @Override
    public ActivityInitListener createActivityInitListener(
            Predicate<Boolean> onInitListener) {
+2 −33
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.quickstep.util.ActiveGestureLog;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;
import java.util.function.Consumer;

@@ -53,9 +52,6 @@ public class MultiStateCallback {

    private int mState = 0;

    private boolean mCallbacksPaused = false;
    private final List<Runnable> mPendingCallbacks = new ArrayList<>();

    public MultiStateCallback(String[] stateNames) {
        this(stateNames, stateFlag -> null);
    }
@@ -82,24 +78,6 @@ public class MultiStateCallback {
        }
    }

    /** Pauses callbacks. */
    public void pauseCallbacks() {
        mCallbacksPaused = true;
    }

    /** Immediately queues any callbacks that were pending paused. */
    public void resumeCallbacks() {
        if (!mCallbacksPaused) {
            return;
        }
        mCallbacksPaused = false;
        List<Runnable> queuedCallbacks = new ArrayList<>(mPendingCallbacks);
        mPendingCallbacks.clear();
        for (Runnable runnable : queuedCallbacks) {
            runnable.run();
        }
    }

    /**
     * Adds the provided state flags to the global state and executes any callbacks as a result.
     */
@@ -121,12 +99,7 @@ public class MultiStateCallback {
            if ((mState & state) == state) {
                LinkedList<Runnable> callbacks = mCallbacks.valueAt(i);
                while (!callbacks.isEmpty()) {
                    Runnable cb = callbacks.pollFirst();
                    if (mCallbacksPaused) {
                        mPendingCallbacks.add(cb);
                    } else {
                        cb.run();
                    }
                    callbacks.pollFirst().run();
                }
            }
        }
@@ -178,15 +151,11 @@ public class MultiStateCallback {
            if (wasOn != isOn) {
                ArrayList<Consumer<Boolean>> listeners = mStateChangeListeners.valueAt(i);
                for (Consumer<Boolean> listener : listeners) {
                    if (mCallbacksPaused) {
                        mPendingCallbacks.add(() -> listener.accept(isOn));
                    } else {
                    listener.accept(isOn);
                }
            }
        }
    }
    }

    /**
     * Sets a callback to be run when the provided states in the given {@param stateMask} is
+1 −8
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public class ActiveGestureErrorDetector {
        ON_SETTLED_ON_END_TARGET, 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,
        FLAG_USING_OTHER_ACTIVITY_INPUT_CONSUMER, LAUNCHER_DESTROYED,
        FLAG_USING_OTHER_ACTIVITY_INPUT_CONSUMER,

        /**
         * These GestureEvents are specifically associated to state flags that get set in
@@ -162,13 +162,6 @@ public class ActiveGestureErrorDetector {
                                        + "before/without setting end target to new task",
                                writer);
                        break;
                    case LAUNCHER_DESTROYED:
                        errorDetected |= printErrorIfTrue(
                                true,
                                prefix,
                                /* errorMessage= */ "Launcher destroyed mid-gesture",
                                writer);
                        break;
                    case STATE_GESTURE_COMPLETED:
                        errorDetected |= printErrorIfTrue(
                                !encounteredEvents.contains(GestureEvent.MOTION_UP),
Loading