Disabling movement of entire affiliated task set.

- This CL removes the dependency on the last-active-time of the task
  record, since that is dependent on the current system time (which can
  be changed by the user).  Instead of working around the previous
  behavior in ActivityManager which moves all affiliated tasks to the
  top when one task is launched, we change the behavior in the AM
  directly, and prevent re-sorting the list of recent tasks improperly
  (aside from the stable sort which puts the freeform tasks first).

Bug: 27398177

Change-Id: I9fa9b3497d08082fe00aa724538255de87e746d6
diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java
index 88faee7..cea76f2 100644
--- a/services/core/java/com/android/server/am/RecentTasks.java
+++ b/services/core/java/com/android/server/am/RecentTasks.java
@@ -65,6 +65,9 @@
     private static final int MAX_RECENT_BITMAPS = 3;
     private static final int DEFAULT_INITIAL_CAPACITY = 5;
 
+    // Whether or not to move all affiliated tasks to the front when one of the tasks is launched
+    private static final boolean MOVE_AFFILIATED_TASKS_TO_FRONT = false;
+
     /**
      * Save recent tasks information across reboots.
      */
@@ -513,7 +516,7 @@
         if (task.inRecents) {
             int taskIndex = indexOf(task);
             if (taskIndex >= 0) {
-                if (!isAffiliated) {
+                if (!isAffiliated || MOVE_AFFILIATED_TASKS_TO_FRONT) {
                     // Simple case: this is not an affiliated task, so we just move it to the front.
                     remove(taskIndex);
                     add(0, task);