am 4732660a: am ab3276dd: Merge "Make an exception for screenshot optimization." into klp-dev

* commit '4732660a50f3373812e8ae55cbda264d469bfded':
  Make an exception for screenshot optimization.
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9c1c863..93ed555 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6640,6 +6640,10 @@
         return list;
     }
 
+    TaskRecord getMostRecentTask() {
+        return mRecentTasks.get(0);
+    }
+
     @Override
     public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
             int flags, int userId) {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index fc83f05..066989b 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -674,8 +674,8 @@
         }
 
         TaskRecord tr = who.task;
-        if (tr.intent != null && (tr.intent.getFlags()
-                &Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
+        if (mService.getMostRecentTask() != tr && tr.intent != null &&
+                (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
             // If this task is being excluded from recents, we don't want to take
             // the expense of capturing a thumbnail, since we will never show it.
             return null;