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

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

Merge "Disabling movement of entire affiliated task set." into nyc-dev

am: 7e2d589c

* commit '7e2d589c':
  Disabling movement of entire affiliated task set.

Change-Id: Icd0246efd006d52ae49cfa71d0b7fb7238c914ee
parents f92b74f8 7e2d589c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.WindowManager.LayoutParams;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.Interpolators;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
@@ -166,6 +167,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            if (action.equals(Intent.ACTION_SCREEN_OFF)) {
                // When the screen turns off, dismiss Recents to Home
                dismissRecentsToHomeIfVisible(false);
            } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
                // For the time being, if the time changes, then invalidate the
                // last-stack-active-time, this ensures that we will just show the last N tasks
                // the next time that Recents loads, but prevents really old tasks from showing
                // up if the task time is set forward.
                Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
                        0);
            }
        }
    };
@@ -311,6 +319,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        // Register the broadcast receiver to handle messages when the screen is turned off
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_TIME_CHANGED);
        registerReceiver(mSystemBroadcastReceiver, filter);

        getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
+7 −32
Original line number Diff line number Diff line
@@ -140,39 +140,10 @@ public class RecentsTaskLoadPlan {
            lastStackActiveTime = 0;
        }
        long newLastStackActiveTime = -1;
        long prevLastActiveTime = lastStackActiveTime;
        int taskCount = mRawTasks.size();
        for (int i = 0; i < taskCount; i++) {
            ActivityManager.RecentTaskInfo t = mRawTasks.get(i);

            /*
             * Affiliated tasks are returned in a specific order from ActivityManager but without a
             * lastActiveTime since it hasn't yet been started. However, we later sort the task list
             * by lastActiveTime, which rearranges the tasks. For now, we need to workaround this
             * by updating the lastActiveTime of this task to the lastActiveTime of the task it is
             * affiliated with, in the same order that we encounter it in the original list (just
             * its index in the task group for the task it is affiliated with).
             *
             * If the parent task is not available, then we will use the last active time of the
             * previous task as a base point (since the task itself may not have an active time)
             * for the entire affiliated group.
             */
            if (t.persistentId != t.affiliatedTaskId) {
                Task.TaskKey parentTask = affiliatedTasks.get(t.affiliatedTaskId);
                long parentTaskLastActiveTime = parentTask != null
                        ? parentTask.lastActiveTime
                        : prevLastActiveTime;
                if (RecentsDebugFlags.Static.EnableAffiliatedTaskGroups) {
                    t.lastActiveTime = parentTaskLastActiveTime +
                            affiliatedTaskCounts.get(t.affiliatedTaskId, 0) + 1;
                } else {
                    if (t.lastActiveTime == 0) {
                        t.lastActiveTime = parentTaskLastActiveTime -
                                affiliatedTaskCounts.get(t.affiliatedTaskId, 0) - 1;
                    }
                }
            }

            // Compose the task key
            Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent,
                    t.userId, t.firstActiveTime, t.lastActiveTime);
@@ -180,9 +151,14 @@ public class RecentsTaskLoadPlan {
            // This task is only shown in the stack if it statisfies the historical time or min
            // number of tasks constraints. Freeform tasks are also always shown.
            boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
            boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) ||
                    (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS)));
            boolean isStackTask = isFreeformTask || !isHistoricalTask(t) ||
                    (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS));
            boolean isLaunchTarget = taskKey.id == runningTaskId;

            // The last stack active time is the baseline for which we show visible tasks.  Since
            // the system will store all the tasks, we don't want to show the tasks prior to the
            // last visible ones, otherwise, as you dismiss them, the previous tasks may satisfy
            // the other stack-task constraints.
            if (isStackTask && newLastStackActiveTime < 0) {
                newLastStackActiveTime = t.lastActiveTime;
            }
@@ -211,7 +187,6 @@ public class RecentsTaskLoadPlan {
            allTasks.add(task);
            affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
            affiliatedTasks.put(taskKey.id, taskKey);
            prevLastActiveTime = t.lastActiveTime;
        }
        if (newLastStackActiveTime != -1) {
            Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
+5 −0
Original line number Diff line number Diff line
@@ -117,6 +117,11 @@ public class Task {
    @ViewDebug.ExportedProperty(deepExport=true, prefix="key_")
    public TaskKey key;

    /**
     * The temporary sort index in the stack, used when ordering the stack.
     */
    public int temporarySortIndexInStack;

    /**
     * The group will be computed separately from the initialization of the task
     */
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ public class TaskKeyLruCache<V> {
    final V getAndInvalidateIfModified(Task.TaskKey key) {
        Task.TaskKey lastKey = mKeys.get(key.id);
        if (lastKey != null) {
            if ((lastKey.stackId != key.stackId) || (lastKey.lastActiveTime < key.lastActiveTime)) {
            if ((lastKey.stackId != key.stackId) ||
                    (lastKey.lastActiveTime != key.lastActiveTime)) {
                // The task has updated (been made active since the last time it was put into the
                // LRU cache) or the stack id for the task has changed, invalidate that cache item
                remove(key);
+8 −14
Original line number Diff line number Diff line
@@ -517,16 +517,8 @@ public class TaskStack {
        }
    }

    // A comparator that sorts tasks by their last active time
    private Comparator<Task> LAST_ACTIVE_TIME_COMPARATOR = new Comparator<Task>() {
        @Override
        public int compare(Task o1, Task o2) {
            return Long.compare(o1.key.lastActiveTime, o2.key.lastActiveTime);
        }
    };

    // A comparator that sorts tasks by their last active time and freeform state
    private Comparator<Task> FREEFORM_LAST_ACTIVE_TIME_COMPARATOR = new Comparator<Task>() {
    // A comparator that sorts tasks by their freeform state
    private Comparator<Task> FREEFORM_COMPARATOR = new Comparator<Task>() {
        @Override
        public int compare(Task o1, Task o2) {
            if (o1.isFreeformTask() && !o2.isFreeformTask()) {
@@ -534,7 +526,7 @@ public class TaskStack {
            } else if (o2.isFreeformTask() && !o1.isFreeformTask()) {
                return -1;
            }
            return Long.compare(o1.key.lastActiveTime, o2.key.lastActiveTime);
            return Long.compare(o1.temporarySortIndexInStack, o2.temporarySortIndexInStack);
        }
    };

@@ -696,7 +688,10 @@ public class TaskStack {
        }

        // Sort all the tasks to ensure they are ordered correctly
        Collections.sort(allTasks, FREEFORM_LAST_ACTIVE_TIME_COMPARATOR);
        for (int i = allTasks.size() - 1; i >= 0; i--) {
            allTasks.get(i).temporarySortIndexInStack = i;
        }
        Collections.sort(allTasks, FREEFORM_COMPARATOR);

        mStackTaskList.set(allTasks);
        mRawTaskList = allTasks;
@@ -769,12 +764,11 @@ public class TaskStack {
    }

    /**
     * Computes a set of all the active and historical tasks ordered by their last active time.
     * Computes a set of all the active and historical tasks.
     */
    public ArrayList<Task> computeAllTasksList() {
        ArrayList<Task> tasks = new ArrayList<>();
        tasks.addAll(mStackTaskList.getTasks());
        Collections.sort(tasks, LAST_ACTIVE_TIME_COMPARATOR);
        return tasks;
    }

Loading