Refresh thumbnail splash when task icon changes.

This is usually a result of TaskIconCache updating in the background.

Fix: 267744363
Test: manual.
Change-Id: I83620f3774def7ffb07906a6d45b64e9aad6de71
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index 3f7d677..5cf79ea 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -355,6 +355,12 @@
         mSnapshotView2.setSplashAlpha(mTaskThumbnailSplashAlpha);
     }
 
+    @Override
+    protected void refreshTaskThumbnailSplash() {
+        super.refreshTaskThumbnailSplash();
+        mSnapshotView2.refreshSplashView();
+    }
+
     /**
      *     Sets visibility for thumbnails and associated elements (DWB banners).
      *     IconView is unaffected.
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 886fc80..c6dc15a 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -92,6 +92,7 @@
 
     @Override
     public void onTaskIconChanged(int taskId) {
+        super.onTaskIconChanged(taskId);
         // If Launcher needs to return to split select state, do it now, after the icon has updated.
         if (mActivity.hasPendingSplitSelectInfo()) {
             PendingSplitSelectInfo recoveryData = mActivity.getPendingSplitSelectInfo();
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 8facb0a..dbde4e9 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -954,6 +954,14 @@
         }
     }
 
+    @Override
+    public void onTaskIconChanged(int taskId) {
+        TaskView taskView = getTaskViewByTaskId(taskId);
+        if (taskView != null) {
+            taskView.refreshTaskThumbnailSplash();
+        }
+    }
+
     /**
      * Update the thumbnail of the task.
      * @param refreshNow Refresh immediately if it's true.
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index c71a74e..432eadc 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -342,10 +342,11 @@
 
         // Draw splash above thumbnail to hide inconsistencies in rotation and aspect ratios.
         if (shouldShowSplashView()) {
+            // Always draw background for hiding inconsistencies, even if splash view is not yet
+            // loaded (which can happen as task icons are loaded asynchronously in the background)
+            canvas.drawRoundRect(x, y, width + 1, height + 1, cornerRadius,
+                    cornerRadius, mSplashBackgroundPaint);
             if (mSplashView != null) {
-                canvas.drawRoundRect(x, y, width + 1, height + 1, cornerRadius,
-                        cornerRadius, mSplashBackgroundPaint);
-
                 mSplashView.layout((int) x, (int) (y + 1), (int) width, (int) height - 1);
                 mSplashView.draw(canvas);
             }
@@ -375,6 +376,13 @@
                 || isThumbnailRotationDifferentFromTask();
     }
 
+    protected void refreshSplashView() {
+        if (mTask != null) {
+            updateSplashView(mTask.icon);
+            invalidate();
+        }
+    }
+
     private void updateSplashView(Drawable icon) {
         if (icon == null || icon.getConstantState() == null) {
             mSplashViewDrawable = null;
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index aa37fdd..ea189a9 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -1184,6 +1184,10 @@
         mSnapshotView.setSplashAlpha(mTaskThumbnailSplashAlpha);
     }
 
+    protected void refreshTaskThumbnailSplash() {
+        mSnapshotView.refreshSplashView();
+    }
+
     private void setSplitSelectTranslationX(float x) {
         mSplitSelectTranslationX = x;
         applyTranslationX();