From bed0d636fe9babf3d6e445ebc8fcb081d7741e3b Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 14 Jun 2022 15:51:09 -0700 Subject: [PATCH] Proper fix for gesture nav flicker using runOnPageScrollsInitialized() I root caused the two areas causing the flicker: A. If page scrolls aren't initialized when we get onActivityInit(), the first scroll even after linkRecentsViewScroll() will jump based on min scroll (due to Clear all button). Fix is to defer linking until page scrolls are initialized. B. If page scrolls aren't initialized when the gesture starts, RecentsView can jump to the min scroll when calling showCurrentTask(), since that calls setCurrentPage(getRunningTaskIndex()) which might be out of bounds. Fix is to defer that setCurrentPage() until page scrolls are initialized. Test: open a random app that hasn't been opened in a while, touch down on nav handle and see if RecentsView scrolls partially or fully offscreen; repeat 20 times to be sure Fixes: 233112195 Change-Id: I000960775f8735920d97c87942065a430c9dce0c --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 2 +- quickstep/src/com/android/quickstep/views/RecentsView.java | 2 +- src/com/android/launcher3/PagedView.java | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 713fa25383..c4cc5a4c61 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -446,7 +446,7 @@ public abstract class AbsSwipeUpHandler, }); setupRecentsViewUi(); - linkRecentsViewScroll(); + mRecentsView.runOnPageScrollsInitialized(this::linkRecentsViewScroll); activity.runOnBindToTouchInteractionService(this::onLauncherBindToService); mActivity.registerActivityLifecycleCallbacks(mLifecycleCallbacks); diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 12ddc38be4..891aff4ab7 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2303,7 +2303,7 @@ public abstract class RecentsView setCurrentPage(getRunningTaskIndex())); setRunningTaskViewShowScreenshot(false); setRunningTaskHidden(runningTaskTileHidden); // Update task size after setting current task. diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index cba0b7d709..73be5beb2c 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1187,9 +1187,7 @@ public abstract class PagedView extends ViewGrou } public int getScrollForPage(int index) { - // TODO(b/233112195): Use !pageScrollsInitialized() instead of mPageScrolls == null, once we - // root cause where we should be using runOnPageScrollsInitialized(). - if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) { + if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) { return 0; } else { return mPageScrolls[index];