1/Clean up RecentTasks list

- Move some logic into the RecentTasks list
- Added some callbacks for future handling of trimming recent tasks based
  on additional policy
- Fix issue when cleaning up tasks where the wrong activity/app info can
  be fetched since the tmp caches were not cleared
- Add some initial tests for existing task list behaviour.

Bug: 34270611
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java

Change-Id: I26730461fa5fb3f5afdabe092438c229381f4f2b
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
index cc8bd69..b4db4a3 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
@@ -103,12 +103,18 @@
 
     protected static TaskRecord createTask(ActivityStackSupervisor supervisor,
             ComponentName component, ActivityStack stack) {
+        return createTask(supervisor, component, 0 /* flags */, stack);
+    }
+
+    protected static TaskRecord createTask(ActivityStackSupervisor supervisor,
+            ComponentName component, int flags, ActivityStack stack) {
         final ActivityInfo aInfo = new ActivityInfo();
         aInfo.applicationInfo = new ApplicationInfo();
         aInfo.applicationInfo.packageName = component.getPackageName();
 
         Intent intent = new Intent();
         intent.setComponent(component);
+        intent.setFlags(flags);
 
         final TaskRecord task = new TaskRecord(supervisor.mService, 0, aInfo, intent /*intent*/,
                 null /*_taskDescription*/);