Add task affiliation

Introduces new flag Intent.FLAG_ACTIVITY_LAUNCH_BEHIND which
causes the newly launched task to affiliate with the launching task.
(Later this flag will also launch the task behind the current task).
This shows up in a new member of the RecentTaskInfo class. This also
causes the recents list returned by getRecentsInfo to be rearranged
so that affiliated tasks are together.

Fixes bug 16157517.

Change-Id: Ia1386af50da2f01809278b62d249f05c6a0de951
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 70311af..1f92bf9 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -2137,7 +2137,7 @@
                             + " Callers=" + Debug.getCallers(4));
                     if (DEBUG_TASKS) Slog.v(TAG, "Pushing next activity " + p
                             + " out to target's task " + target.task);
-                    p.setTask(targetTask, false);
+                    p.setTask(targetTask, null);
                     targetTask.addActivityAtBottom(p);
 
                     mWindowManager.setAppGroupId(p.appToken, targetTaskId);
@@ -2268,7 +2268,7 @@
                             + start + "-" + i + " to task=" + task + ":" + taskInsertionPoint);
                     for (int srcPos = start; srcPos >= i; --srcPos) {
                         final ActivityRecord p = activities.get(srcPos);
-                        p.setTask(task, false);
+                        p.setTask(task, null);
                         task.addActivityAtIndex(taskInsertionPoint, p);
 
                         if (DEBUG_ADD_REMOVE) Slog.i(TAG, "Removing and adding activity " + p
@@ -3885,6 +3885,7 @@
                 // Task creator asked to remove this when done, or this task was a voice
                 // interaction, so it should not remain on the recent tasks list.
                 mService.mRecentTasks.remove(task);
+                task.closeRecentsChain();
             }
         }