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

Commit cc12b225 authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Don't wait until next fetch of recent tasks to reset the task list" into qt-dev

am: 8540e63d

Change-Id: I20b2ee78bf853a9e070862fd32a51324985dd277
parents 2e03e241 8540e63d
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -185,7 +184,6 @@ class RecentTasks {
    // front. Newly created tasks, or tasks that are removed from the list will continue to change
    // the list.  This does not affect affiliated tasks.
    private boolean mFreezeTaskListReordering;
    private long mFreezeTaskListReorderingTime;
    private long mFreezeTaskListTimeoutMs = FREEZE_TASK_LIST_TIMEOUT_MS;

    // Mainly to avoid object recreation on multiple calls.
@@ -220,6 +218,9 @@ class RecentTasks {
        }
    };

    private final Runnable mResetFreezeTaskListOnTimeoutRunnable =
            this::resetFreezeTaskListReorderingOnTimeout;

    @VisibleForTesting
    RecentTasks(ActivityTaskManagerService service, TaskPersister taskPersister) {
        mService = service;
@@ -255,8 +256,7 @@ class RecentTasks {
    }

    @VisibleForTesting
    void setFreezeTaskListTimeoutParams(long reorderingTime, long timeoutMs) {
        mFreezeTaskListReorderingTime = reorderingTime;
    void setFreezeTaskListTimeout(long timeoutMs) {
        mFreezeTaskListTimeoutMs = timeoutMs;
    }

@@ -272,7 +272,8 @@ class RecentTasks {
        // Always update the reordering time when this is called to ensure that the timeout
        // is reset
        mFreezeTaskListReordering = true;
        mFreezeTaskListReorderingTime = SystemClock.elapsedRealtime();
        mService.mH.removeCallbacks(mResetFreezeTaskListOnTimeoutRunnable);
        mService.mH.postDelayed(mResetFreezeTaskListOnTimeoutRunnable, mFreezeTaskListTimeoutMs);
    }

    /**
@@ -286,6 +287,7 @@ class RecentTasks {

        // Once we end freezing the task list, reset the existing task order to the stable state
        mFreezeTaskListReordering = false;
        mService.mH.removeCallbacks(mResetFreezeTaskListOnTimeoutRunnable);

        // If the top task is provided, then restore the top task to the front of the list
        if (topTask != null) {
@@ -295,6 +297,8 @@ class RecentTasks {

        // Resume trimming tasks
        trimInactiveRecentTasks();

        mService.getTaskChangeNotificationController().notifyTaskStackChanged();
    }

    /**
@@ -302,13 +306,8 @@ class RecentTasks {
     * before we need to iterate the task list in order (either for purposes of returning the list
     * to SystemUI or if we need to trim tasks in order)
     */
    @VisibleForTesting
    void resetFreezeTaskListReorderingOnTimeout() {
        // Unfreeze the recent task list if the time heuristic has passed
        if (mFreezeTaskListReorderingTime
                > (SystemClock.elapsedRealtime() - mFreezeTaskListTimeoutMs)) {
            return;
        }

        final ActivityStack focusedStack = mService.getTopDisplayFocusedStack();
        final TaskRecord topTask = focusedStack != null
                ? focusedStack.topTask()
@@ -875,9 +874,6 @@ class RecentTasks {
        final Set<Integer> includedUsers = getProfileIds(userId);
        includedUsers.add(Integer.valueOf(userId));

        // Check if the frozen task list has timed out
        resetFreezeTaskListReorderingOnTimeout();

        final ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<>();
        final int size = mTasks.size();
        int numVisibleTasks = 0;
@@ -1654,8 +1650,8 @@ class RecentTasks {
        pw.println("mRecentsUid=" + mRecentsUid);
        pw.println("mRecentsComponent=" + mRecentsComponent);
        pw.println("mFreezeTaskListReordering=" + mFreezeTaskListReordering);
        pw.println("mFreezeTaskListReorderingTime (time since)="
                + (SystemClock.elapsedRealtime() - mFreezeTaskListReorderingTime) + "ms");
        pw.println("mFreezeTaskListReorderingPendingTimeout="
                + mService.mH.hasCallbacks(mResetFreezeTaskListOnTimeoutRunnable));
        if (mTasks.isEmpty()) {
            return;
        }
+2 −5
Original line number Diff line number Diff line
@@ -712,7 +712,6 @@ public class RecentTasksTest extends ActivityTestsBase {
        mRecentTasks.add(mTasks.get(4));

        // Freeze the list
        long freezeTime = SystemClock.elapsedRealtime();
        mRecentTasks.setFreezeTaskListReordering();
        assertTrue(mRecentTasks.isFreezeTaskListReorderingSet());

@@ -720,13 +719,11 @@ public class RecentTasksTest extends ActivityTestsBase {
        mRecentTasks.add(mTasks.get(2));
        mRecentTasks.add(mTasks.get(1));

        // Override the freeze timeout params to simulate the timeout (simulate the freeze at 100ms
        // ago with a timeout of 1ms)
        mRecentTasks.setFreezeTaskListTimeoutParams(freezeTime - 100, 1);

        ActivityStack stack = mTasks.get(2).getStack();
        stack.moveToFront("", mTasks.get(2));
        doReturn(stack).when(mTestService.mRootActivityContainer).getTopDisplayFocusedStack();

        // Simulate the reset from the timeout
        mRecentTasks.resetFreezeTaskListReorderingOnTimeout();
        assertFalse(mRecentTasks.isFreezeTaskListReorderingSet());