Swipe up from excludeFromRecents task should be shown left of desktop tasks

- excludeFromRecents are sometimes added as index 0 after moveRunningTaskToFront, breking the model that fullscreen tasks should be shown after desktop tasks
- Added getRunningTaskExpectedIndex to compute expected runningTask postion in all scenario, and apply this position both when adding the view in showCurrentTask and moveRunningTaskToExpectedPosition

Fix: 380232192
Test: Swipe up from following scenario in phone/tablet, repeat several times
1) 1st fullscreen task
2) 2nd fullscreen task
3) excludeFromRecents task
4) Desktop task
Flag: EXEMPT BUG_FIX

Change-Id: Iec551fb1403a6bb5307b684a50f7ae7d31bd4644
This commit is contained in:
Alex Chau
2024-11-21 14:28:42 +00:00
parent 6ce105c269
commit 64ae9bcfe5
2 changed files with 29 additions and 19 deletions
@@ -783,7 +783,7 @@ public abstract class AbsSwipeUpHandler<
&& recentsAttachedToAppWindow) {
// Only move running task if RecentsView has never been attached before, to avoid
// TaskView jumping to new position as we move the tasks.
mRecentsView.moveRunningTaskToFront();
mRecentsView.moveRunningTaskToExpectedPosition();
}
mAnimationFactory.setRecentsAttachedToAppWindow(
recentsAttachedToAppWindow, animate, updateRunningTaskAlpha);
@@ -1773,26 +1773,17 @@ public abstract class RecentsView<
}
/**
* Moves the running task to the front of the carousel in tablets, to minimize animation
* required to move the running task in grid.
* Moves the running task to the expected position in the carousel. In tablets, this minimize
* animation required to move the running task into focused task position.
*/
public void moveRunningTaskToFront() {
if (!mContainer.getDeviceProfile().isTablet) {
return;
}
public void moveRunningTaskToExpectedPosition() {
TaskView runningTaskView = getRunningTaskView();
if (runningTaskView == null) {
if (runningTaskView == null || mCurrentPage != indexOfChild(runningTaskView)) {
return;
}
if (indexOfChild(runningTaskView) != mCurrentPage) {
return;
}
int frontIndex = enableLargeDesktopWindowingTile() ? getDesktopTaskViewCount() : 0;
if (mCurrentPage <= frontIndex) {
int runningTaskExpectedIndex = getRunningTaskExpectedIndex(runningTaskView);
if (mCurrentPage == runningTaskExpectedIndex) {
return;
}
@@ -1805,12 +1796,31 @@ public abstract class RecentsView<
mMovingTaskView = null;
runningTaskView.resetPersistentViewTransforms();
addView(runningTaskView, frontIndex);
setCurrentPage(frontIndex);
addView(runningTaskView, runningTaskExpectedIndex);
setCurrentPage(runningTaskExpectedIndex);
updateTaskSize();
}
private int getRunningTaskExpectedIndex(TaskView runningTaskView) {
if (mContainer.getDeviceProfile().isTablet) {
if (runningTaskView instanceof DesktopTaskView) {
return 0; // Desktop running task is always in front.
} else if (enableLargeDesktopWindowingTile()) {
return getDesktopTaskViewCount(); // Other running task is behind desktop tasks.
} else {
return 0;
}
} else {
int currentIndex = indexOfChild(runningTaskView);
if (currentIndex != -1) {
return currentIndex; // Keep the position if running task already in layout.
} else {
return 0; // New running task are added to the front to begin with.
}
}
}
@Override
protected void onScrollerAnimationAborted() {
ActiveGestureProtoLogProxy.logOnScrollerAnimationAborted();
@@ -2980,7 +2990,7 @@ public abstract class RecentsView<
mTmpRunningTasks = new Task[]{runningTasks[0]};
taskView.bind(mTmpRunningTasks[0], mOrientationState, mTaskOverlayFactory);
}
addView(taskView, 0);
addView(taskView, getRunningTaskExpectedIndex(taskView));
runningTaskViewId = taskView.getTaskViewId();
if (wasEmpty) {
addView(mClearAllButton);