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

Commit f8e04b64 authored by Winson Chung's avatar Winson Chung
Browse files

Break out of quickscrub if task fails to launch

- Return the user to their previous state if quickscrub fails to launch
  the new task (ie. if it finishes itself mid-launch).

Bug: 117163033
Change-Id: If03cf0431be40d9b81dfcc5dffcb2bf4844bbbd2
parent 899b87cc
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class QuickScrubController implements OnAlarmListener {
    private int mQuickScrubSection;
    private boolean mStartedFromHome;
    private boolean mFinishedTransitionToQuickScrub;
    private int mLaunchingTaskId;
    private Runnable mOnFinishedTransitionToQuickScrubRunnable;
    private ActivityControlHelper mActivityControlHelper;
    private TouchInteractionLog mTouchInteractionLog;
@@ -105,6 +106,7 @@ public class QuickScrubController implements OnAlarmListener {
            if (taskView != null) {
                mWaitingForTaskLaunch = true;
                mTouchInteractionLog.launchTaskStart();
                mLaunchingTaskId = taskView.getTask().key.id;
                taskView.launchTask(true, (result) -> {
                    mTouchInteractionLog.launchTaskEnd(result);
                    if (!result) {
@@ -146,6 +148,7 @@ public class QuickScrubController implements OnAlarmListener {
        mActivityControlHelper = null;
        mOnFinishedTransitionToQuickScrubRunnable = null;
        mRecentsView.setNextPageSwitchRunnable(null);
        mLaunchingTaskId = 0;
    }

    /**
@@ -211,6 +214,18 @@ public class QuickScrubController implements OnAlarmListener {
        }
    }

    public void onTaskRemoved(int taskId) {
        if (mLaunchingTaskId == taskId) {
            // The task has been removed mid-launch, break out of quickscrub and return the user
            // to where they were before (and notify the launch failed)
            TaskView taskView = mRecentsView.getTaskView(taskId);
            if (taskView != null) {
                taskView.notifyTaskLaunchFailed(TAG);
            }
            breakOutOfQuickScrub();
        }
    }

    public void snapToNextTaskIfAvailable() {
        if (mInQuickScrub && mRecentsView.getChildCount() > 0) {
            int duration = mStartedFromHome ? QUICK_SCRUB_FROM_HOME_START_DURATION
+4 −0
Original line number Diff line number Diff line
@@ -183,6 +183,10 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
            if (!mHandleTaskStackChanges) {
                return;
            }

            // Notify the quick scrub controller that a particular task has been removed
            mQuickScrubController.onTaskRemoved(taskId);

            BackgroundExecutor.get().submit(() -> {
                TaskView taskView = getTaskView(taskId);
                if (taskView == null) {