Merge "Preemptively create Bitmap from GraphicBuffer" into oc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index 611169f..42e8921 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -78,6 +78,7 @@
 import com.android.systemui.recents.model.Task;
 import com.android.systemui.recents.model.TaskGrouping;
 import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.recents.model.ThumbnailData;
 import com.android.systemui.recents.views.RecentsTransitionHelper;
 import com.android.systemui.recents.views.RecentsTransitionHelper.AppTransitionAnimationSpecsFuture;
 import com.android.systemui.recents.views.TaskStackLayoutAlgorithm;
@@ -199,7 +200,8 @@
                 return;
             }
 
-            EventBus.getDefault().send(new TaskSnapshotChangedEvent(taskId, snapshot));
+            EventBus.getDefault().send(new TaskSnapshotChangedEvent(taskId,
+                    ThumbnailData.createFromTaskSnapshot(snapshot)));
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskSnapshotChangedEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskSnapshotChangedEvent.java
index 07c3b3d..e0ed7a9 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskSnapshotChangedEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskSnapshotChangedEvent.java
@@ -16,9 +16,8 @@
 
 package com.android.systemui.recents.events.ui;
 
-import android.app.ActivityManager.TaskSnapshot;
-
 import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.model.ThumbnailData;
 
 /**
  * Sent when a task snapshot has changed.
@@ -26,10 +25,10 @@
 public class TaskSnapshotChangedEvent extends EventBus.Event {
 
     public final int taskId;
-    public final TaskSnapshot taskSnapshot;
+    public final ThumbnailData thumbnailData;
 
-    public TaskSnapshotChangedEvent(int taskId, TaskSnapshot taskSnapshot) {
+    public TaskSnapshotChangedEvent(int taskId, ThumbnailData thumbnailData) {
         this.taskId = taskId;
-        this.taskSnapshot = taskSnapshot;
+        this.thumbnailData = thumbnailData;
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
index 5989b33..a2190b3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
@@ -16,7 +16,6 @@
 
 package com.android.systemui.recents.views;
 
-import android.app.ActivityManager;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -37,7 +36,6 @@
 
 import com.android.systemui.R;
 import com.android.systemui.recents.events.EventBus;
-import com.android.systemui.recents.events.EventBus.Event;
 import com.android.systemui.recents.events.ui.TaskSnapshotChangedEvent;
 import com.android.systemui.recents.misc.Utilities;
 import com.android.systemui.recents.model.Task;
@@ -386,15 +384,14 @@
     }
 
     public final void onBusEvent(TaskSnapshotChangedEvent event) {
-        if (mTask == null || event.taskId != mTask.key.id || event.taskSnapshot == null) {
+        if (mTask == null || event.taskId != mTask.key.id || event.thumbnailData == null
+                || event.thumbnailData.thumbnail == null) {
             return;
         }
-        setThumbnail(ThumbnailData.createFromTaskSnapshot(event.taskSnapshot));
+        setThumbnail(event.thumbnailData);
     }
 
     public void dump(String prefix, PrintWriter writer) {
-        String innerPrefix = prefix + "  ";
-
         writer.print(prefix); writer.print("TaskViewThumbnail");
         writer.print(" mTaskViewRect="); writer.print(Utilities.dumpRect(mTaskViewRect));
         writer.print(" mThumbnailRect="); writer.print(Utilities.dumpRect(mThumbnailRect));