Merge "Add detailed exception for snappedIndex == -1 when dismissing tasks" into udc-dev am: dcbe9583fb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23535540
Change-Id: Id446aaa7fa907aaa4376b9d442f5bbc78a44298c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 0a31a62..55b9f95 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -3742,19 +3742,33 @@
taskViewIdArray.removeValue(
finalNextFocusedTaskView.getTaskViewId());
}
- if (snappedIndex < taskViewIdArray.size()) {
- taskViewIdToSnapTo = taskViewIdArray.get(snappedIndex);
- } else if (snappedIndex == taskViewIdArray.size()) {
- // If the snapped task is the last item from the
- // dismissed row,
- // snap to the same column in the other grid row
- IntArray inverseRowTaskViewIdArray =
- isSnappedTaskInTopRow ? getBottomRowIdArray()
- : getTopRowIdArray();
- if (snappedIndex < inverseRowTaskViewIdArray.size()) {
- taskViewIdToSnapTo = inverseRowTaskViewIdArray.get(
- snappedIndex);
+ try {
+ if (snappedIndex < taskViewIdArray.size()) {
+ taskViewIdToSnapTo = taskViewIdArray.get(snappedIndex);
+ } else if (snappedIndex == taskViewIdArray.size()) {
+ // If the snapped task is the last item from the
+ // dismissed row,
+ // snap to the same column in the other grid row
+ IntArray inverseRowTaskViewIdArray =
+ isSnappedTaskInTopRow ? getBottomRowIdArray()
+ : getTopRowIdArray();
+ if (snappedIndex < inverseRowTaskViewIdArray.size()) {
+ taskViewIdToSnapTo = inverseRowTaskViewIdArray.get(
+ snappedIndex);
+ }
}
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new IllegalStateException(
+ "b/269956477 invalid snappedIndex"
+ + "\nsnappedTaskViewId: "
+ + snappedTaskViewId
+ + "\nfocusedTaskViewId: "
+ + mFocusedTaskViewId
+ + "\ntopRowIdArray: "
+ + getTopRowIdArray().toConcatString()
+ + "\nbottomRowIdArray: "
+ + getBottomRowIdArray().toConcatString(),
+ e);
}
}
}