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

Commit 15e2c773 authored by Alex Chau's avatar Alex Chau
Browse files

Refactor TaskView.getTaskIds and its attribute container to support any number of tasks

- getTaskIds and getTaskIdAttributeContainers will now return an array with any sizes:
  - Not bound -> empty array
  - Single task -> 1 element array
  - Split task -> 2 elements array
  - Desktop task -> N elements array
- Updates TaskView.containsTaskId/containsMultipleTasks accordingly
- Removed unnecessary overrides in GroupedTaskView and DesktopTaskView
- Updates RecentsView.hasAllValidTaskIds accordingly
- Reviewed all direct and indirect usage of getTaskIds, to make sure caller don't access the array without length checking; migrate usage to stream if applicable
- Simplfied RecentsView.shouldAddStubTaskView to use getTaskViewByTaskIds to find TaksView with exact match of taskIds
- Simplfied RecentsView.setContentAlpha to match TaskView ref instead of doing taskId matching

Bug: 249371338
Test: With single, split, desktop task in Overview, try different CUJs like launch, menu, dismiss, scroll, swipe up etc.
Flag: NONE
Change-Id: I39a5a36c85ce8b366fe25132a349b08244fb1217
parent 56f9df06
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;


public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsState>
public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsState>
        implements StateListener<RecentsState> {
        implements StateListener<RecentsState> {
@@ -144,8 +145,9 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsSta
    @Override
    @Override
    public void setCurrentTask(int runningTaskViewId) {
    public void setCurrentTask(int runningTaskViewId) {
        super.setCurrentTask(runningTaskViewId);
        super.setCurrentTask(runningTaskViewId);
        int runningTaskId = getTaskIdsForRunningTaskView()[0];
        int[] runningTaskIds = getTaskIdsForRunningTaskView();
        if (mHomeTask != null && mHomeTask.key.id != runningTaskId) {
        if (mHomeTask != null
                && Arrays.stream(runningTaskIds).noneMatch(taskId -> taskId == mHomeTask.key.id)) {
            mHomeTask = null;
            mHomeTask = null;
            setRunningTaskHidden(false);
            setRunningTaskHidden(false);
        }
        }
@@ -182,13 +184,14 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsSta
        // as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
        // as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
        // track the index of the next task appropriately, as if we are switching on any other app.
        // track the index of the next task appropriately, as if we are switching on any other app.
        // TODO(b/195607777) Confirm home task info is front-most task and not mixed in with others
        // TODO(b/195607777) Confirm home task info is front-most task and not mixed in with others
        int runningTaskId = getTaskIdsForRunningTaskView()[0];
        int[] runningTaskIds = getTaskIdsForRunningTaskView();
        if (mHomeTask != null && mHomeTask.key.id == runningTaskId
        if (mHomeTask != null
                && Arrays.stream(runningTaskIds).allMatch(taskId -> taskId == mHomeTask.key.id)
                && !taskGroups.isEmpty()) {
                && !taskGroups.isEmpty()) {
            // Check if the task list has running task
            // Check if the task list has running task
            boolean found = false;
            boolean found = false;
            for (GroupTask group : taskGroups) {
            for (GroupTask group : taskGroups) {
                if (group.containsTask(runningTaskId)) {
                if (Arrays.stream(runningTaskIds).allMatch(group::containsTask)) {
                    found = true;
                    found = true;
                    break;
                    break;
                }
                }
+2 −12
Original line number Original line Diff line number Diff line
@@ -204,18 +204,14 @@ public class DesktopTaskView extends TaskView {
    }
    }


    private void updateTaskIdContainer() {
    private void updateTaskIdContainer() {
        // TODO(b/249371338): TaskView expects the array to have at least 2 elements.
        mTaskIdContainer = new int[mTasks.size()];
        // At least 2 elements in the array
        mTaskIdContainer = new int[Math.max(mTasks.size(), 2)];
        for (int i = 0; i < mTasks.size(); i++) {
        for (int i = 0; i < mTasks.size(); i++) {
            mTaskIdContainer[i] = mTasks.get(i).key.id;
            mTaskIdContainer[i] = mTasks.get(i).key.id;
        }
        }
    }
    }


    private void updateTaskIdAttributeContainer() {
    private void updateTaskIdAttributeContainer() {
        // TODO(b/249371338): TaskView expects the array to have at least 2 elements.
        mTaskIdAttributeContainer = new TaskIdAttributeContainer[mTasks.size()];
        // At least 2 elements in the array
        mTaskIdAttributeContainer = new TaskIdAttributeContainer[Math.max(mTasks.size(), 2)];
        for (int i = 0; i < mTasks.size(); i++) {
        for (int i = 0; i < mTasks.size(); i++) {
            Task task = mTasks.get(i);
            Task task = mTasks.get(i);
            TaskThumbnailViewDeprecated thumbnailView = mSnapshotViewMap.get(task.key.id);
            TaskThumbnailViewDeprecated thumbnailView = mSnapshotViewMap.get(task.key.id);
@@ -247,12 +243,6 @@ public class DesktopTaskView extends TaskView {
        return mTaskThumbnailViewDeprecated;
        return mTaskThumbnailViewDeprecated;
    }
    }


    @Override
    public boolean containsTaskId(int taskId) {
        // Thumbnail map contains taskId -> thumbnail map. Use the keys for contains
        return mSnapshotViewMap.contains(taskId);
    }

    @Override
    @Override
    public void onTaskListVisibilityChanged(boolean visible, int changes) {
    public void onTaskListVisibilityChanged(boolean visible, int changes) {
        cancelPendingLoadTasks();
        cancelPendingLoadTasks();
+30 −17
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ import static com.android.launcher3.Flags.enableOverviewIconMenu;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.quickstep.util.SplitScreenUtils.convertLauncherSplitBoundsToShell;
import static com.android.quickstep.util.SplitScreenUtils.convertLauncherSplitBoundsToShell;


import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PointF;
@@ -46,6 +47,7 @@ import kotlin.Unit;


import java.util.Arrays;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashMap;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Consumer;


/**
/**
@@ -129,9 +131,11 @@ public class GroupedTaskView extends TaskView {
            @Nullable SplitBounds splitBoundsConfig) {
            @Nullable SplitBounds splitBoundsConfig) {
        super.bind(primary, orientedState);
        super.bind(primary, orientedState);
        mSecondaryTask = secondary;
        mSecondaryTask = secondary;
        mTaskIdContainer[1] = secondary.key.id;
        mTaskIdContainer = new int[]{mTaskIdContainer[0], secondary.key.id};
        mTaskIdAttributeContainer[1] = new TaskIdAttributeContainer(secondary, mSnapshotView2,
        mTaskIdAttributeContainer = new TaskIdAttributeContainer[]{
                mIconView2, STAGE_POSITION_BOTTOM_OR_RIGHT);
                mTaskIdAttributeContainer[0],
                new TaskIdAttributeContainer(secondary, mSnapshotView2,
                        mIconView2, STAGE_POSITION_BOTTOM_OR_RIGHT)};
        mTaskIdAttributeContainer[0].setStagePosition(
        mTaskIdAttributeContainer[0].setStagePosition(
                SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT);
                SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT);
        mSnapshotView2.bind(secondary);
        mSnapshotView2.bind(secondary);
@@ -154,6 +158,9 @@ public class GroupedTaskView extends TaskView {
    public void setUpShowAllInstancesListener() {
    public void setUpShowAllInstancesListener() {
        // sets up the listener for the left/top task
        // sets up the listener for the left/top task
        super.setUpShowAllInstancesListener();
        super.setUpShowAllInstancesListener();
        if (mTaskIdAttributeContainer.length < 2) {
            return;
        }


        // right/bottom task's base package name
        // right/bottom task's base package name
        String taskPackageName = mTaskIdAttributeContainer[1].getTask().key.getPackageName();
        String taskPackageName = mTaskIdAttributeContainer[1].getTask().key.getPackageName();
@@ -307,17 +314,21 @@ public class GroupedTaskView extends TaskView {
        mSnapshotView2.refresh();
        mSnapshotView2.refresh();
    }
    }


    @Override
    public boolean containsTaskId(int taskId) {
        return (mTask != null && mTask.key.id == taskId)
                || (mSecondaryTask != null && mSecondaryTask.key.id == taskId);
    }

    @Override
    @Override
    public TaskThumbnailViewDeprecated[] getThumbnails() {
    public TaskThumbnailViewDeprecated[] getThumbnails() {
        return new TaskThumbnailViewDeprecated[]{mTaskThumbnailViewDeprecated, mSnapshotView2};
        return new TaskThumbnailViewDeprecated[]{mTaskThumbnailViewDeprecated, mSnapshotView2};
    }
    }


    /**
     * Returns taskId that split selection was initiated with,
     * {@link ActivityTaskManager#INVALID_TASK_ID} if no tasks in this TaskView are part of
     * split selection
     */
    protected int getThisTaskCurrentlyInSplitSelection() {
        int initialTaskId = getRecentsView().getSplitSelectController().getInitialTaskId();
        return containsTaskId(initialTaskId) ? initialTaskId : INVALID_TASK_ID;
    }

    @Override
    @Override
    protected int getLastSelectedChildTaskIndex() {
    protected int getLastSelectedChildTaskIndex() {
        SplitSelectStateController splitSelectController =
        SplitSelectStateController splitSelectController =
@@ -382,13 +393,15 @@ public class GroupedTaskView extends TaskView {
        } else {
        } else {
            // Currently being split with this taskView, let the non-split selected thumbnail
            // Currently being split with this taskView, let the non-split selected thumbnail
            // take up full thumbnail area
            // take up full thumbnail area
            TaskIdAttributeContainer container =
            Optional<TaskIdAttributeContainer> nonSplitContainer = Arrays.stream(
                    mTaskIdAttributeContainer[initSplitTaskId == mTask.key.id ? 1 : 0];
                    mTaskIdAttributeContainer).filter(
            container.getThumbnailView().measure(widthMeasureSpec,
                            container -> container.getTask().key.id != initSplitTaskId).findAny();
                    View.MeasureSpec.makeMeasureSpec(
            nonSplitContainer.ifPresent(
                            heightSize -
                    taskIdAttributeContainer -> taskIdAttributeContainer.getThumbnailView().measure(
                                    mContainer.getDeviceProfile().overviewTaskThumbnailTopMarginPx,
                            widthMeasureSpec, MeasureSpec.makeMeasureSpec(
                            MeasureSpec.EXACTLY));
                                    heightSize - mContainer.getDeviceProfile()
                                            .overviewTaskThumbnailTopMarginPx,
                                    MeasureSpec.EXACTLY)));
        }
        }
        if (!enableOverviewIconMenu()) {
        if (!enableOverviewIconMenu()) {
            updateIconPlacement();
            updateIconPlacement();
@@ -529,7 +542,7 @@ public class GroupedTaskView extends TaskView {
            mDigitalWellBeingToast.setBannerVisibility(visibility);
            mDigitalWellBeingToast.setBannerVisibility(visibility);
            mSnapshotView2.setVisibility(visibility);
            mSnapshotView2.setVisibility(visibility);
            mDigitalWellBeingToast2.setBannerVisibility(visibility);
            mDigitalWellBeingToast2.setBannerVisibility(visibility);
        } else if (taskId == getTaskIds()[0]) {
        } else if (mTaskIdContainer.length > 0 && mTaskIdContainer[0] == taskId) {
            mTaskThumbnailViewDeprecated.setVisibility(visibility);
            mTaskThumbnailViewDeprecated.setVisibility(visibility);
            mDigitalWellBeingToast.setBannerVisibility(visibility);
            mDigitalWellBeingToast.setBannerVisibility(visibility);
        } else {
        } else {
+43 −45
Original line number Original line Diff line number Diff line
@@ -626,7 +626,6 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
     */
     */
    protected int mRunningTaskViewId = -1;
    protected int mRunningTaskViewId = -1;
    private int mTaskViewIdCount;
    private int mTaskViewIdCount;
    private final int[] INVALID_TASK_IDS = new int[]{-1, -1};
    protected boolean mRunningTaskTileHidden;
    protected boolean mRunningTaskTileHidden;
    @Nullable
    @Nullable
    private Task[] mTmpRunningTasks;
    private Task[] mTmpRunningTasks;
@@ -1413,7 +1412,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
     */
     */
    @Nullable
    @Nullable
    public TaskView getTaskViewByTaskIds(int[] taskIds) {
    public TaskView getTaskViewByTaskIds(int[] taskIds) {
        if (!hasAnyValidTaskIds(taskIds)) {
        if (!hasAllValidTaskIds(taskIds)) {
            return null;
            return null;
        }
        }


@@ -1432,9 +1431,11 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        return null;
        return null;
    }
    }


    /** Returns false if {@code taskIds} is null or contains invalid values, true otherwise */
    /** Returns false if {@code taskIds} is null or contains any invalid values, true otherwise */
    private boolean hasAnyValidTaskIds(int[] taskIds) {
    private boolean hasAllValidTaskIds(int[] taskIds) {
        return taskIds != null && !Arrays.equals(taskIds, INVALID_TASK_IDS);
        return taskIds != null
                && taskIds.length > 0
                && Arrays.stream(taskIds).noneMatch(taskId -> taskId == INVALID_TASK_ID);
    }
    }


    public void setOverviewStateEnabled(boolean enabled) {
    public void setOverviewStateEnabled(boolean enabled) {
@@ -1720,10 +1721,12 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
            return;
            return;
        }
        }


        int[] currentTaskId = INVALID_TASK_IDS;
        int[] currentTaskIds;
        TaskView currentTaskView = getTaskViewAt(mCurrentPage);
        TaskView currentTaskView = getTaskViewAt(mCurrentPage);
        if (currentTaskView != null && currentTaskView.getTask() != null) {
        if (currentTaskView != null && currentTaskView.getTask() != null) {
            currentTaskId = currentTaskView.getTaskIds();
            currentTaskIds = currentTaskView.getTaskIds();
        } else {
            currentTaskIds = new int[0];
        }
        }


        // Unload existing visible task data
        // Unload existing visible task data
@@ -1735,8 +1738,8 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo


        // Save running task ID if it exists before rebinding all taskViews, otherwise the task from
        // Save running task ID if it exists before rebinding all taskViews, otherwise the task from
        // the runningTaskView currently bound could get assigned to another TaskView
        // the runningTaskView currently bound could get assigned to another TaskView
        int[] runningTaskId = getTaskIdsForTaskViewId(mRunningTaskViewId);
        int[] runningTaskIds = getTaskIdsForTaskViewId(mRunningTaskViewId);
        int[] focusedTaskId = getTaskIdsForTaskViewId(mFocusedTaskViewId);
        int[] focusedTaskIds = getTaskIdsForTaskViewId(mFocusedTaskViewId);


        // Reset the focused task to avoiding initializing TaskViews layout as focused task during
        // Reset the focused task to avoiding initializing TaskViews layout as focused task during
        // binding. The focused task view will be updated after all the TaskViews are bound.
        // binding. The focused task view will be updated after all the TaskViews are bound.
@@ -1819,7 +1822,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        }
        }


        // Keep same previous focused task
        // Keep same previous focused task
        TaskView newFocusedTaskView = getTaskViewByTaskIds(focusedTaskId);
        TaskView newFocusedTaskView = getTaskViewByTaskIds(focusedTaskIds);
        // If the list changed, maybe the focused task doesn't exist anymore
        // If the list changed, maybe the focused task doesn't exist anymore
        if (newFocusedTaskView == null && getTaskViewCount() > 0) {
        if (newFocusedTaskView == null && getTaskViewCount() > 0) {
            newFocusedTaskView = getTaskViewAt(0);
            newFocusedTaskView = getTaskViewAt(0);
@@ -1830,10 +1833,10 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        updateChildTaskOrientations();
        updateChildTaskOrientations();


        TaskView newRunningTaskView = null;
        TaskView newRunningTaskView = null;
        if (hasAnyValidTaskIds(runningTaskId)) {
        if (hasAllValidTaskIds(runningTaskIds)) {
            // Update mRunningTaskViewId to be the new TaskView that was assigned by binding
            // Update mRunningTaskViewId to be the new TaskView that was assigned by binding
            // the full list of tasks to taskViews
            // the full list of tasks to taskViews
            newRunningTaskView = getTaskViewByTaskIds(runningTaskId);
            newRunningTaskView = getTaskViewByTaskIds(runningTaskIds);
            if (newRunningTaskView != null) {
            if (newRunningTaskView != null) {
                setRunningTaskViewId(newRunningTaskView.getTaskViewId());
                setRunningTaskViewId(newRunningTaskView.getTaskViewId());
            } else {
            } else {
@@ -1853,8 +1856,8 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        if (mNextPage != INVALID_PAGE) {
        if (mNextPage != INVALID_PAGE) {
            // Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
            // Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
            mCurrentPage = previousCurrentPage;
            mCurrentPage = previousCurrentPage;
            if (hasAnyValidTaskIds(currentTaskId)) {
            if (hasAllValidTaskIds(currentTaskIds)) {
                currentTaskView = getTaskViewByTaskIds(currentTaskId);
                currentTaskView = getTaskViewByTaskIds(currentTaskIds);
                if (currentTaskView != null) {
                if (currentTaskView != null) {
                    targetPage = indexOfChild(currentTaskView);
                    targetPage = indexOfChild(currentTaskView);
                }
                }
@@ -1863,7 +1866,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
            targetPage = previousFocusedPage;
            targetPage = previousFocusedPage;
        } else {
        } else {
            // Set the current page to the running task, but not if settling on new task.
            // Set the current page to the running task, but not if settling on new task.
            if (hasAnyValidTaskIds(runningTaskId)) {
            if (hasAllValidTaskIds(runningTaskIds)) {
                targetPage = indexOfChild(newRunningTaskView);
                targetPage = indexOfChild(newRunningTaskView);
            } else if (getTaskViewCount() > 0) {
            } else if (getTaskViewCount() > 0) {
                targetPage = indexOfChild(requireTaskViewAt(0));
                targetPage = indexOfChild(requireTaskViewAt(0));
@@ -1963,7 +1966,8 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
    public void resetTaskVisuals() {
    public void resetTaskVisuals() {
        for (int i = getTaskViewCount() - 1; i >= 0; i--) {
        for (int i = getTaskViewCount() - 1; i >= 0; i--) {
            TaskView taskView = requireTaskViewAt(i);
            TaskView taskView = requireTaskViewAt(i);
            if (mIgnoreResetTaskId != taskView.getTaskIds()[0]) {
            if (Arrays.stream(taskView.getTaskIds()).noneMatch(
                    taskId -> taskId == mIgnoreResetTaskId)) {
                taskView.resetViewTransforms();
                taskView.resetViewTransforms();
                taskView.setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1);
                taskView.setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1);
                taskView.setStableAlpha(mContentAlpha);
                taskView.setStableAlpha(mContentAlpha);
@@ -2343,7 +2347,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        for (int i = 0; i < getTaskViewCount(); i++) {
        for (int i = 0; i < getTaskViewCount(); i++) {
            TaskView taskView = requireTaskViewAt(i);
            TaskView taskView = requireTaskViewAt(i);
            TaskIdAttributeContainer[] containers = taskView.getTaskIdAttributeContainers();
            TaskIdAttributeContainer[] containers = taskView.getTaskIdAttributeContainers();
            if (containers[0] == null && containers[1] == null) {
            if (containers.length == 0) {
                continue;
                continue;
            }
            }
            int index = indexOfChild(taskView);
            int index = indexOfChild(taskView);
@@ -2498,7 +2502,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        // For now 2 distinct task IDs is max for split screen
        // For now 2 distinct task IDs is max for split screen
        TaskView runningTaskView = getTaskViewFromTaskViewId(taskViewId);
        TaskView runningTaskView = getTaskViewFromTaskViewId(taskViewId);
        if (runningTaskView == null) {
        if (runningTaskView == null) {
            return INVALID_TASK_IDS;
            return new int[0];
        }
        }


        return runningTaskView.getTaskIds();
        return runningTaskView.getTaskIds();
@@ -2736,22 +2740,19 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
     * Returns true if we should add a stub taskView for the running task id
     * Returns true if we should add a stub taskView for the running task id
     */
     */
    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
        TaskView taskView = getTaskViewByTaskId(runningTasks[0].key.id);
        int[] runningTaskIds = Arrays.stream(runningTasks).mapToInt(task -> task.key.id).toArray();
        if (taskView == null) {
        TaskView matchingTaskView = null;
            // No TaskView found, add a stub task.
        if (hasDesktopTask(runningTasks) && runningTaskIds.length == 1) {
            return true;
            // TODO(b/249371338): Unsure if it's expected, desktop runningTasks only have a single
            // taskId, therefore we match any DesktopTaskView that contains the runningTaskId.
            TaskView taskview = getTaskViewByTaskId(runningTaskIds[0]);
            if (taskview instanceof DesktopTaskView) {
                matchingTaskView = taskview;
            }
            }

        if (runningTasks.length > 1) {
            // Ensure all taskIds matches the TaskView, otherwise add a stub task.
            return Arrays.stream(runningTasks).anyMatch(
                    runningTask -> !taskView.containsTaskId(runningTask.key.id));
        } else {
        } else {
            // Ensure the TaskView only contains a single taskId, or is a DesktopTask,
            matchingTaskView = getTaskViewByTaskIds(runningTaskIds);
            // otherwise add a stub task.
            // TODO(b/249371338): Figure out why DesktopTask only have a single runningTask.
            return taskView.containsMultipleTasks() && !taskView.isDesktopTask();
        }
        }
        return matchingTaskView == null;
    }
    }


    /**
    /**
@@ -4273,13 +4274,10 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        alpha = Utilities.boundToRange(alpha, 0, 1);
        alpha = Utilities.boundToRange(alpha, 0, 1);
        mContentAlpha = alpha;
        mContentAlpha = alpha;


        int runningTaskId = getTaskIdsForRunningTaskView()[0];
        TaskView runningTaskView = getRunningTaskView();
        for (int i = getTaskViewCount() - 1; i >= 0; i--) {
        for (int i = getTaskViewCount() - 1; i >= 0; i--) {
            TaskView child = requireTaskViewAt(i);
            TaskView child = requireTaskViewAt(i);
            int[] childTaskIds = child.getTaskIds();
            if (runningTaskView != null && mRunningTaskTileHidden && child == runningTaskView) {
            if (runningTaskId != INVALID_TASK_ID
                    && mRunningTaskTileHidden
                    && (childTaskIds[0] == runningTaskId || childTaskIds[1] == runningTaskId)) {
                continue;
                continue;
            }
            }
            child.setStableAlpha(alpha);
            child.setStableAlpha(alpha);
@@ -4753,7 +4751,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo


        // Prevent dismissing whole task if we're only initiating from one of 2 tasks in split pair
        // Prevent dismissing whole task if we're only initiating from one of 2 tasks in split pair
        mSplitSelectStateController.setDismissingFromSplitPair(mSplitHiddenTaskView != null
        mSplitSelectStateController.setDismissingFromSplitPair(mSplitHiddenTaskView != null
                && mSplitHiddenTaskView.containsMultipleTasks());
                && mSplitHiddenTaskView instanceof GroupedTaskView);
        mSplitSelectStateController.setInitialTaskSelect(splitSelectSource.intent,
        mSplitSelectStateController.setInitialTaskSelect(splitSelectSource.intent,
                splitSelectSource.position.stagePosition, splitSelectSource.itemInfo,
                splitSelectSource.position.stagePosition, splitSelectSource.itemInfo,
                splitSelectSource.splitEvent, splitSelectSource.alreadyRunningTaskId);
                splitSelectSource.splitEvent, splitSelectSource.alreadyRunningTaskId);
@@ -4774,14 +4772,14 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
                mSplitSelectStateController.isAnimateCurrentTaskDismissal();
                mSplitSelectStateController.isAnimateCurrentTaskDismissal();
        boolean isInitiatingTaskViewSplitPair =
        boolean isInitiatingTaskViewSplitPair =
                mSplitSelectStateController.isDismissingFromSplitPair();
                mSplitSelectStateController.isDismissingFromSplitPair();
        if (isInitiatingSplitFromTaskView && isInitiatingTaskViewSplitPair) {
        if (isInitiatingSplitFromTaskView && isInitiatingTaskViewSplitPair
                && mSplitHiddenTaskView instanceof GroupedTaskView) {
            // Splitting from Overview for split pair task
            // Splitting from Overview for split pair task
            createInitialSplitSelectAnimation(builder);
            createInitialSplitSelectAnimation(builder);


            // Animate pair thumbnail into full thumbnail
            // Animate pair thumbnail into full thumbnail
            boolean primaryTaskSelected =
            boolean primaryTaskSelected = mSplitHiddenTaskView.getTaskIds()[0]
                    mSplitHiddenTaskView.getTaskIdAttributeContainers()[0].getTask().key.id ==
                    == mSplitSelectStateController.getInitialTaskId();
                            mSplitSelectStateController.getInitialTaskId();
            TaskIdAttributeContainer taskIdAttributeContainer = mSplitHiddenTaskView
            TaskIdAttributeContainer taskIdAttributeContainer = mSplitHiddenTaskView
                    .getTaskIdAttributeContainers()[primaryTaskSelected ? 1 : 0];
                    .getTaskIdAttributeContainers()[primaryTaskSelected ? 1 : 0];
            TaskThumbnailViewDeprecated thumbnail = taskIdAttributeContainer.getThumbnailView();
            TaskThumbnailViewDeprecated thumbnail = taskIdAttributeContainer.getThumbnailView();
@@ -5232,7 +5230,8 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        mPendingAnimation.addOnFrameCallback(this::redrawLiveTile);
        mPendingAnimation.addOnFrameCallback(this::redrawLiveTile);
        mPendingAnimation.addEndListener(isSuccess -> {
        mPendingAnimation.addEndListener(isSuccess -> {
            if (isSuccess) {
            if (isSuccess) {
                if (tv.getTaskIds()[1] != -1 && mRemoteTargetHandles != null) {
                if (tv instanceof GroupedTaskView && hasAllValidTaskIds(tv.getTaskIds())
                        && mRemoteTargetHandles != null) {
                    // TODO(b/194414938): make this part of the animations instead.
                    // TODO(b/194414938): make this part of the animations instead.
                    TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
                    TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
                            mRemoteTargetHandles[0].getTransformParams().getTargetSet().nonApps,
                            mRemoteTargetHandles[0].getTransformParams().getTargetSet().nonApps,
@@ -5879,8 +5878,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
        }
        }


        taskView.setShowScreenshot(true);
        taskView.setShowScreenshot(true);
        for (TaskIdAttributeContainer container :
        for (TaskIdAttributeContainer container : taskView.getTaskIdAttributeContainers()) {
                taskView.getTaskIdAttributeContainers()) {
            if (container == null) {
            if (container == null) {
                continue;
                continue;
            }
            }
+44 −56

File changed.

Preview size limit exceeded, changes collapsed.