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

Commit 2caec7ba authored by Louis Chang's avatar Louis Chang
Browse files

Avoid adjusting top focused root task while clear task

Top focused root task was updated while clear task for reuse, which
isn't necessary. This was happening after 046523ce merged.

Also avoid resuming the top activity in next focused
root task to prevent additional top-resumed-activity state changes.

Bug: 160613519
Test: asit/perf/junit/jank_systemui_test

Change-Id: I8ddbfc3b0a62ddb29833d324e42812ed0dc096db
parent a8a2aa77
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2549,7 +2549,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        final Task stack = getRootTask();
        final boolean mayAdjustTop = (isState(RESUMED) || stack.mResumedActivity == null)
                && stack.isFocusedStackOnDisplay();
                && stack.isFocusedStackOnDisplay()
                // Do not adjust focus task because the task will be reused to launch new activity.
                && !task.isClearingToReuseTask();
        final boolean shouldAdjustGlobalFocus = mayAdjustTop
                // It must be checked before {@link #makeFinishingLocked} is called, because a stack
                // is not visible if it only contains finishing activities.
+0 −2
Original line number Diff line number Diff line
@@ -2023,8 +2023,6 @@ class ActivityStarter {
            // of history or if it is finished immediately), thus disassociating the task. Also note
            // that mReuseTask is reset as a result of {@link Task#performClearTaskLocked}
            // launching another activity.
            // TODO(b/36119896):  We shouldn't trigger activity launches in this path since we are
            // already launching one.
            targetTask.performClearTaskLocked();
            targetTask.setIntent(mStartActivity);
            mAddingToTask = true;
+15 −4
Original line number Diff line number Diff line
@@ -1836,14 +1836,25 @@ class Task extends WindowContainer<WindowContainer> {
     */
    void performClearTaskLocked() {
        mReuseTask = true;
        mStackSupervisor.beginDeferResume();
        try {
            performClearTask("clear-task-all");
        } finally {
            mStackSupervisor.endDeferResume();
            mReuseTask = false;
        }
    }

    ActivityRecord performClearTaskForReuseLocked(ActivityRecord newR, int launchFlags) {
        mReuseTask = true;
        final ActivityRecord result = performClearTaskLocked(newR, launchFlags);
        mStackSupervisor.beginDeferResume();
        final ActivityRecord result;
        try {
            result = performClearTaskLocked(newR, launchFlags);
        } finally {
            mStackSupervisor.endDeferResume();
            mReuseTask = false;
        }
        return result;
    }