Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41ab3f3e authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Run setCurrentPage in applyLoadPlan after scroll initialized" into tm-qpr-dev

parents 4afab0b2 0733ebd3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -90,9 +90,9 @@ public final class RecentsViewStateController extends
            // While animating into recents, update the visible task data as needed
            builder.addOnFrameCallback(() -> mRecentsView.loadVisibleTaskData(FLAG_UPDATE_ALL));
            mRecentsView.updateEmptyMessage();
            // TODO(b/238461210): Remove logging once root cause of flake detected.
            // TODO(b/246283207): Remove logging once root cause of flake detected.
            if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
                Log.d("b/238461210", "RecentsView#setStateWithAnimationInternal getCurrentPage(): "
                Log.d("b/246283207", "RecentsView#setStateWithAnimationInternal getCurrentPage(): "
                                + mRecentsView.getCurrentPage()
                                + ", getScrollForPage(getCurrentPage())): "
                                + mRecentsView.getScrollForPage(mRecentsView.getCurrentPage()));
+22 −22
Original line number Diff line number Diff line
@@ -1511,21 +1511,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            addView(mClearAllButton);
        }

        boolean settlingOnNewTask = mNextPage != INVALID_PAGE;
        if (settlingOnNewTask) {
            // Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
            mCurrentPage = previousCurrentPage;
        } else {
            // TODO(b/238461210): Remove logging once root cause of flake detected.
            if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
                Log.d("b/238461210", "RecentsView#applyLoadPlan() -> !settlingOnNewTask -> "
                                + "previousCurrentPage: " + previousCurrentPage
                                + ", getScrollForPage(previousCurrentPage): "
                                + getScrollForPage(previousCurrentPage));
            }
            setCurrentPage(previousCurrentPage);
        }

        // Keep same previous focused task
        TaskView newFocusedTaskView = getTaskViewByTaskId(focusedTaskId);
        // If the list changed, maybe the focused task doesn't exist anymore
@@ -1550,21 +1535,36 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        }

        int targetPage = -1;
        if (!settlingOnNewTask) {
        if (mNextPage != INVALID_PAGE) {
            // Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
            mCurrentPage = previousCurrentPage;
            if (currentTaskId != -1) {
                currentTaskView = getTaskViewByTaskId(currentTaskId);
                if (currentTaskView != null) {
                    targetPage = indexOfChild(currentTaskView);
                }
            }
        } else {
            // Set the current page to the running task, but not if settling on new task.
            if (runningTaskId != -1) {
                targetPage = indexOfChild(newRunningTaskView);
            } else if (getTaskViewCount() > 0) {
                targetPage = indexOfChild(requireTaskViewAt(0));
            }
        } else if (currentTaskId != -1) {
            currentTaskView = getTaskViewByTaskId(currentTaskId);
            if (currentTaskView != null) {
                targetPage = indexOfChild(currentTaskView);
            }
        }
        if (targetPage != -1 && mCurrentPage != targetPage) {
            setCurrentPage(targetPage);
            int finalTargetPage = targetPage;
            runOnPageScrollsInitialized(() -> {
                // TODO(b/246283207): Remove logging once root cause of flake detected.
                if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
                    Log.d("b/246283207", "RecentsView#applyLoadPlan() -> "
                            + "previousCurrentPage: " + previousCurrentPage
                            + ", targetPage: " + finalTargetPage
                            + ", getScrollForPage(targetPage): "
                            + getScrollForPage(finalTargetPage));
                }
                setCurrentPage(finalTargetPage);
            });
        }

        if (mIgnoreResetTaskId != -1 &&
+2 −2
Original line number Diff line number Diff line
@@ -772,9 +772,9 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        }

        if (mScroller.isFinished() && pageScrollChanged) {
            // TODO(b/238461210): Remove logging once root cause of flake detected.
            // TODO(b/246283207): Remove logging once root cause of flake detected.
            if (Utilities.IS_RUNNING_IN_TEST_HARNESS && !(this instanceof Workspace)) {
                Log.d("b/238461210", this.getClass().getSimpleName() + "#onLayout() -> "
                Log.d("b/246283207", this.getClass().getSimpleName() + "#onLayout() -> "
                        + "if(mScroller.isFinished() && pageScrollChanged) -> getNextPage(): "
                        + getNextPage() + ", getScrollForPage(getNextPage()): "
                        + getScrollForPage(getNextPage()));