Fix crash when swiping up from task that doesn't appear in the list
Bug: 74567248
Test: Clear all tasks, open assistant and swipe up
Change-Id: Ie5e81ffbc921f76eb6b279f38b5e7aa423fc5af2
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 98597c8..33f1310 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -520,14 +520,18 @@
// Make sure the window follows the first task if it moves, e.g. during quick scrub.
View firstTask = mRecentsView.getPageAt(0);
- int scrollForFirstTask = mRecentsView.getScrollForPage(0);
- int offsetFromFirstTask = (scrollForFirstTask - mRecentsView.getScrollX());
- synchronized (mTargetRect) {
- mTargetRect.set(mInitialTargetRect);
- Utilities.scaleRectFAboutCenter(mTargetRect, firstTask.getScaleX());
- float offsetX = offsetFromFirstTask + firstTask.getTranslationX();
- float offsetY = mRecentsView.getTranslationY();
- mTargetRect.offset(offsetX, offsetY);
+ // The first task may be null if we are swiping up from a task that does not
+ // appear in the list (ie. the assistant)
+ if (firstTask != null) {
+ int scrollForFirstTask = mRecentsView.getScrollForPage(0);
+ int offsetFromFirstTask = (scrollForFirstTask - mRecentsView.getScrollX());
+ synchronized (mTargetRect) {
+ mTargetRect.set(mInitialTargetRect);
+ Utilities.scaleRectFAboutCenter(mTargetRect, firstTask.getScaleX());
+ float offsetX = offsetFromFirstTask + firstTask.getTranslationX();
+ float offsetY = mRecentsView.getTranslationY();
+ mTargetRect.offset(offsetX, offsetY);
+ }
}
if (mRecentsAnimationWrapper.controller != null) {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 6fb8a36..ab76e40 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -569,8 +569,11 @@
// Load the tasks (if the loading is already
mLoadPlanId = mModel.loadTasks(runningTaskId, this::applyLoadPlan);
- // Hide the task that we are animating into
- getPageAt(mCurrentPage).setAlpha(0);
+ // Hide the task that we are animating into, ignore if there is no associated task (ie. the
+ // assistant)
+ if (getPageAt(mCurrentPage) != null) {
+ getPageAt(mCurrentPage).setAlpha(0);
+ }
}
public QuickScrubController getQuickScrubController() {