Resize mRemoteTargetHandles when RecentsAnimationStarts

* TopTaskTracker gets updated too late after we've exited
split screen so we can't use that to determine how many
RemoteTargetHandles to use
* We default to 2, and then scale it down to 1. Because we
modify the array holding the handles directly, it should
also get updated in AbsSwipeUpHandler
* Temporary solution to stop setting up RecentsView if we detect that
TopTaskTracker has incorrect data and re-setup when we get
onRecentsAnimationStart()

Test: Tested quickswitch in gestural and recents button
double tap in button nav.
Bug: 236226779
Flag: none

Change-Id: I1bae7aed1f8712ddd1bf496acfcb851c0e32a115
This commit is contained in:
Vinit Nayak
2023-05-16 13:40:29 -07:00
parent 883871e280
commit 57de6565a0
3 changed files with 45 additions and 3 deletions
@@ -147,6 +147,7 @@ import com.android.wm.shell.startingsurface.SplashScreenExitAnimationUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
@@ -662,6 +663,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
} else {
runningTasks = mGestureState.getRunningTask().getPlaceholderTasks();
}
// Safeguard against any null tasks being sent to recents view, happens when quickswitching
// very quickly w/ split tasks because TopTaskTracker provides stale information compared to
// actual running tasks in the recents animation.
// TODO(b/236226779), Proper fix (ag/22237143)
if (Arrays.stream(runningTasks).anyMatch(Objects::isNull)) {
return;
}
mRecentsView.onGestureAnimationStart(runningTasks, mDeviceState.getRotationTouchHelper());
}
@@ -915,7 +924,12 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
if (DesktopTaskView.DESKTOP_MODE_SUPPORTED && targets.hasDesktopTasks()) {
mRemoteTargetHandles = mTargetGluer.assignTargetsForDesktop(targets);
} else {
int untrimmedAppCount = mRemoteTargetHandles.length;
mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
if (mRemoteTargetHandles.length < untrimmedAppCount && mIsSwipeForSplit) {
updateIsGestureForSplit(mRemoteTargetHandles.length);
setupRecentsViewUi();
}
}
mRecentsAnimationController = controller;
mRecentsAnimationTargets = targets;