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

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

Merge "Add overview button rate-limiter to fix recurring bug" into main

parents 9ea209b8 89d64bb3
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -437,11 +437,13 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
    }

    protected void runOnInitBackgroundStateUI(Runnable callback) {
        mOnInitBackgroundStateUICallback = callback;
        ACTIVITY_TYPE activity = getCreatedActivity();
        if (activity != null && activity.getStateManager().getState() == mBackgroundState) {
            callback.run();
            onInitBackgroundStateUI();
            return;
        }
        mOnInitBackgroundStateUICallback = callback;
    }

    private void onInitBackgroundStateUI() {
+18 −1
Original line number Diff line number Diff line
@@ -78,6 +78,14 @@ public class OverviewCommandHelper {
     */
    private int mTaskFocusIndexOverride = -1;

    /**
     * Whether we should incoming toggle commands while a previous toggle command is still ongoing.
     * This serves as a rate-limiter to prevent overlapping animations that can clobber each other
     * and prevent clean-up callbacks from running. This thus prevents a recurring set of bugs with
     * janky recents animations and unresponsive home and overview buttons.
     */
    private boolean mWaitForToggleCommandComplete = false;

    public OverviewCommandHelper(TouchInteractionService service,
            OverviewComponentObserver observer,
            TaskAnimationManager taskAnimationManager) {
@@ -160,15 +168,20 @@ public class OverviewCommandHelper {
    private boolean launchTask(RecentsView recents, @Nullable TaskView taskView, CommandInfo cmd) {
        RunnableList callbackList = null;
        if (taskView != null) {
            mWaitForToggleCommandComplete = true;
            taskView.setEndQuickswitchCuj(true);
            callbackList = taskView.launchTasks();
        }

        if (callbackList != null) {
            callbackList.add(() -> scheduleNextTask(cmd));
            callbackList.add(() -> {
                scheduleNextTask(cmd);
                mWaitForToggleCommandComplete = false;
            });
            return false;
        } else {
            recents.startHome();
            mWaitForToggleCommandComplete = false;
            return true;
        }
    }
@@ -178,6 +191,9 @@ public class OverviewCommandHelper {
     * task is deferred until {@link #scheduleNextTask} is called
     */
    private <T extends StatefulActivity<?>> boolean executeCommand(CommandInfo cmd) {
        if (mWaitForToggleCommandComplete && cmd.type == TYPE_TOGGLE) {
            return true;
        }
        BaseActivityInterface<?, T> activityInterface =
                mOverviewComponentObserver.getActivityInterface();
        RecentsView recents = activityInterface.getVisibleRecentsView();
@@ -359,6 +375,7 @@ public class OverviewCommandHelper {
            pw.println("    pendingCommandType=" + mPendingCommands.get(0).type);
        }
        pw.println("  mTaskFocusIndexOverride=" + mTaskFocusIndexOverride);
        pw.println("  mWaitForToggleCommandComplete=" + mWaitForToggleCommandComplete);
    }

    private static class CommandInfo {