From 8cf0df7f9673fd35cf71a6c8e2c6d67d1618a40d Mon Sep 17 00:00:00 2001 From: minch Date: Thu, 12 Dec 2024 18:26:50 +0000 Subject: [PATCH] Do not rely on `getTaskViewCount` to iterate TaskViews Using `getChildCount` to iterate TaskViews instead of `getTaskViewCount` when indices are used. As it is not safe to assume the TaskView starts from index 0. Flag: EXEMPT as no functionality changes Bug: 379942019 Test: Manual Change-Id: I599b5117f0848e429ebf83fc4b85451e52b4bcab --- .../src/com/android/quickstep/views/RecentsView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6021b71d9b..ffded3641b 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -6186,10 +6186,12 @@ public abstract class RecentsView< } } - final int taskCount = getTaskViewCount(); int lastTaskScroll = getLastTaskScroll(clearAllScroll, clearAllWidth); - for (int i = 0; i < taskCount; i++) { - TaskView taskView = requireTaskViewAt(i); + for (int i = 0; i < getChildCount(); i++) { + TaskView taskView = getTaskViewAt(i); + if (taskView == null) { + continue; + } float scrollDiff = taskView.getScrollAdjustment(showAsGrid); int pageScroll = newPageScrolls[i] + Math.round(scrollDiff); if ((mIsRtl && pageScroll < lastTaskScroll)