Also notify the user when a task view fails to launch.

Bug: 78660939

Change-Id: I8041d3bdd6da1caed72affb1e295c416214a92d4
diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
index 6fece31..228af8e 100644
--- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
@@ -27,7 +27,6 @@
 import android.os.UserHandle;
 import android.util.Log;
 import android.view.View;
-import android.view.ViewTreeObserver.OnPreDrawListener;
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.BaseDraggingActivity;
@@ -239,7 +238,7 @@
                             Log.w(TAG, "Failed to start screen pinning: ", e);
                         }
                     } else {
-                        Log.w(TAG, taskView.getLaunchTaskFailedMsg());
+                        taskView.notifyTaskLaunchFailed(TAG);
                     }
                 };
                 taskView.launchTask(true, resultCallback, mHandler);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f521b25..5139954 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1177,7 +1177,7 @@
             tv.setVisibility(VISIBLE);
             getOverlay().remove(drawable);
             if (!result) {
-                Log.w(TAG, tv.getLaunchTaskFailedMsg());
+                tv.notifyTaskLaunchFailed(TAG);
             }
         };
 
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 93bdab2..a7527a6 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -16,6 +16,7 @@
 
 package com.android.quickstep.views;
 
+import static android.widget.Toast.LENGTH_SHORT;
 import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;
 
 import android.animation.Animator;
@@ -36,6 +37,7 @@
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 
+import android.widget.Toast;
 import com.android.launcher3.BaseActivity;
 import com.android.launcher3.BaseDraggingActivity;
 import com.android.launcher3.R;
@@ -138,7 +140,7 @@
     public void launchTask(boolean animate) {
         launchTask(animate, (result) -> {
             if (!result) {
-                Log.w(TAG, getLaunchTaskFailedMsg());
+                notifyTaskLaunchFailed(TAG);
             }
         }, getHandler());
     }
@@ -312,11 +314,12 @@
         return super.performAccessibilityAction(action, arguments);
     }
 
-    public String getLaunchTaskFailedMsg() {
+    public void notifyTaskLaunchFailed(String tag) {
         String msg = "Failed to launch task";
         if (mTask != null) {
             msg += " (task=" + mTask.key.baseIntent + " userId=" + mTask.key.userId + ")";
         }
-        return msg;
+        Log.w(tag, msg);
+        Toast.makeText(getContext(), R.string.activity_not_available, LENGTH_SHORT).show();
     }
 }