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

Commit aca91898 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crash if AM returns empty task list" into tm-dev

parents a2929870 8b5be54b
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACT
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;

import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.android.launcher3.util.MainThreadInitializedObject;
@@ -183,30 +184,31 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
     */
    public static class CachedTaskInfo {

        @Nullable
        private final RunningTaskInfo mTopTask;
        private final List<RunningTaskInfo> mAllCachedTasks;

        CachedTaskInfo(List<RunningTaskInfo> allCachedTasks) {
            mAllCachedTasks = allCachedTasks;
            mTopTask = allCachedTasks.get(0);
            mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0);
        }

        public int getTaskId() {
            return mTopTask.taskId;
            return mTopTask == null ? -1 : mTopTask.taskId;
        }

        /**
         * Returns true if the root of the task chooser activity
         */
        public boolean isRootChooseActivity() {
            return ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction());
            return mTopTask != null && ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction());
        }

        /**
         * Returns true if the given task holds an Assistant activity that is excluded from recents
         */
        public boolean isExcludedAssistant() {
            return mTopTask.configuration.windowConfiguration
            return mTopTask != null && mTopTask.configuration.windowConfiguration
                    .getActivityType() == ACTIVITY_TYPE_ASSISTANT
                    && (mTopTask.baseIntent.getFlags() & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
        }
@@ -215,7 +217,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
         * Returns true if this represents the HOME task
         */
        public boolean isHomeTask() {
            return mTopTask.configuration.windowConfiguration
            return mTopTask != null && mTopTask.configuration.windowConfiguration
                    .getActivityType() == ACTIVITY_TYPE_HOME;
        }

@@ -224,7 +226,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
         * is loaded by the model
         */
        public Task[] getPlaceholderTasks() {
            return new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
            return mTopTask == null ? new Task[0]
                    : new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
        }

        /**
@@ -232,6 +235,9 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
         * placeholder until the true object is loaded by the model
         */
        public Task[] getPlaceholderTasks(int[] taskIds) {
            if (mTopTask == null) {
                return new Task[0];
            }
            Task[] result = new Task[taskIds.length];
            for (int i = 0; i < taskIds.length; i++) {
                final int index = i;
+2 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import java.util.ArrayList;
public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsState>
        implements StateListener<RecentsState> {

    @Nullable
    private Task mHomeTask;

    public FallbackRecentsView(Context context, AttributeSet attrs) {
@@ -89,7 +90,7 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsSta
            RotationTouchHelper rotationTouchHelper) {
        // TODO(b/195607777) General fallback love, but this might be correct
        //  Home task should be defined as the front-most task info I think?
        mHomeTask = homeTask[0];
        mHomeTask = homeTask.length > 0 ? homeTask[0] : null;
        onGestureAnimationStart(homeTask, rotationTouchHelper);
    }

+3 −0
Original line number Diff line number Diff line
@@ -2257,6 +2257,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * is called.  Also scrolls the view to this task.
     */
    private void showCurrentTask(Task[] runningTasks) {
        if (runningTasks.length == 0) {
            return;
        }
        int runningTaskViewId = -1;
        boolean needGroupTaskView = runningTasks.length > 1;
        if (shouldAddStubTaskView(runningTasks)) {