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

Commit 4b057c67 authored by Winson's avatar Winson
Browse files

Fixing crash when dismissing last stack task.

- The crash was due to us trying to get an anchor task when there were
  no more tasks in the stack.  The original call to check the stack
  task count was poorly named so updating the name of that call as well.

Bug: 26500050

Change-Id: I9652e90a6a2e19008c5c84ce877afca576b3175f
parent 671e8f91
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -192,13 +192,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        loader.loadTasks(this, plan, loadOpts);

        TaskStack stack = plan.getTaskStack();
        ArrayList<Task> tasks = stack.getStackTasks();
        int taskCount = stack.getTaskCount();
        mRecentsView.setTaskStack(stack);

        // Mark the task that is the launch target
        int launchTaskIndexInStack = 0;
        if (launchState.launchedToTaskId != -1) {
            ArrayList<Task> tasks = stack.getStackTasks();
            int taskCount = tasks.size();
            for (int j = 0; j < taskCount; j++) {
                Task t = tasks.get(j);
                if (t.key.id == launchState.launchedToTaskId) {
@@ -210,9 +210,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        }

        // Animate the SystemUI scrims into view
        boolean hasStatusBarScrim = stack.getStackTaskCount() > 0;
        boolean hasStatusBarScrim = taskCount > 0;
        boolean animateStatusBarScrim = launchState.launchedFromHome;
        boolean hasNavBarScrim = (stack.getStackTaskCount() > 0) && !config.hasTransposedNavBar;
        boolean hasNavBarScrim = (taskCount > 0) && !config.hasTransposedNavBar;
        boolean animateNavBarScrim = true;
        mScrimViews.prepareEnterRecentsAnimation(hasStatusBarScrim, animateStatusBarScrim,
                hasNavBarScrim, animateNavBarScrim);
@@ -232,7 +232,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            MetricsLogger.count(this, "overview_source_home", 1);
        }
        // Keep track of the total stack task count
        int taskCount = stack.getStackTaskCount();
        MetricsLogger.histogram(this, "overview_task_count", taskCount);
    }

+4 −4
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
            sInstanceLoadPlan.preloadRawTasks(topTaskHome.value);
            loader.preloadTasks(sInstanceLoadPlan, topTaskHome.value);
            TaskStack stack = sInstanceLoadPlan.getTaskStack();
            if (stack.getStackTaskCount() > 0) {
            if (stack.getTaskCount() > 0) {
                // We try and draw the thumbnail transition bitmap in parallel before
                // toggle/show recents is called
                preCacheThumbnailTransitionBitmapAsync(topTask, stack, mDummyStackView);
@@ -403,7 +403,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        TaskStack focusedStack = plan.getTaskStack();

        // Return early if there are no tasks in the focused stack
        if (focusedStack == null || focusedStack.getStackTaskCount() == 0) return;
        if (focusedStack == null || focusedStack.getTaskCount() == 0) return;

        ActivityManager.RunningTaskInfo runningTask = ssp.getTopMostTask();
        // Return early if there is no running task
@@ -455,7 +455,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        TaskStack focusedStack = plan.getTaskStack();

        // Return early if there are no tasks in the focused stack
        if (focusedStack == null || focusedStack.getStackTaskCount() == 0) return;
        if (focusedStack == null || focusedStack.getTaskCount() == 0) return;

        ActivityManager.RunningTaskInfo runningTask = ssp.getTopMostTask();
        // Return early if there is no running task (can't determine affiliated tasks in this case)
@@ -845,7 +845,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
            return;
        }

        boolean hasRecentTasks = stack.getStackTaskCount() > 0;
        boolean hasRecentTasks = stack.getTaskCount() > 0;
        boolean useThumbnailTransition = (topTask != null) && !isTopTaskHome && hasRecentTasks;

        if (useThumbnailTransition) {
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ public class RecentsTaskLoadPlan {
    /** Returns whether there are any tasks in any stacks. */
    public boolean hasTasks() {
        if (mStack != null) {
            return mStack.getStackTaskCount() > 0;
            return mStack.getTaskCount() > 0;
        }
        return false;
    }
+20 −4
Original line number Diff line number Diff line
@@ -681,16 +681,32 @@ public class TaskStack {
    }

    /**
     * Returns the number of tasks in the active stack.
     * Returns the number of stack and freeform tasks.
     */
    public int getStackTaskCount() {
    public int getTaskCount() {
        return mStackTaskList.size();
    }

    /**
     * Returns the number of freeform tasks in the active stack.
     * Returns the number of stack tasks.
     */
    public int getStackTaskCount() {
        ArrayList<Task> tasks = mStackTaskList.getTasks();
        int stackCount = 0;
        int taskCount = tasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task task = tasks.get(i);
            if (!task.isFreeformTask()) {
                stackCount++;
            }
        }
        return stackCount;
    }

    /**
     * Returns the number of freeform tasks.
     */
    public int getStackTaskFreeformCount() {
    public int getFreeformTaskCount() {
        ArrayList<Task> tasks = mStackTaskList.getTasks();
        int freeformCount = 0;
        int taskCount = tasks.size();
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ public class RecentsTransitionHelper {
            int taskIndexFromFront = 0;
            int taskIndex = stack.indexOfStackTask(task);
            if (taskIndex > -1) {
                taskIndexFromFront = stack.getStackTaskCount() - taskIndex - 1;
                taskIndexFromFront = stack.getTaskCount() - taskIndex - 1;
            }
            EventBus.getDefault().send(new LaunchTaskSucceededEvent(taskIndexFromFront));
        } else {
Loading