fix 2542590 add more logging when launching app fails

Change-Id: I5a1fa261c6e67eb7afb661de39e35ce43e2caa59
diff --git a/src/com/android/launcher2/AllApps2D.java b/src/com/android/launcher2/AllApps2D.java
index 6674480..90c87fb 100644
--- a/src/com/android/launcher2/AllApps2D.java
+++ b/src/com/android/launcher2/AllApps2D.java
@@ -165,7 +165,7 @@
 
     public void onItemClick(AdapterView parent, View v, int position, long id) {
         ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
-        mLauncher.startActivitySafely(app.intent);
+        mLauncher.startActivitySafely(app.intent, app);
     }
 
     public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index d81b442..35e4cfc 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -392,7 +392,7 @@
                     int whichApp = sRollo.mState.selectedIconIndex;
                     if (whichApp >= 0) {
                         ApplicationInfo app = mAllAppsList.get(whichApp);
-                        mLauncher.startActivitySafely(app.intent);
+                        mLauncher.startActivitySafely(app.intent, app);
                         handled = true;
                     }
                 }
@@ -720,7 +720,7 @@
                 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
             reallyPlaySoundEffect(SoundEffectConstants.CLICK);
             ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
-            mLauncher.startActivitySafely(app.intent);
+            mLauncher.startActivitySafely(app.intent, app);
         }
     }
 
diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/android/launcher2/ApplicationInfo.java
index f50b889..5bb5037 100644
--- a/src/com/android/launcher2/ApplicationInfo.java
+++ b/src/com/android/launcher2/ApplicationInfo.java
@@ -98,7 +98,7 @@
 
     @Override
     public String toString() {
-        return title.toString();
+        return "ApplicationInfo(title=" + title.toString() + ")";
     }
 
     public static void dumpApplicationInfoList(String tag, String label,
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index cd3eae8..7ff8328 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -81,7 +81,7 @@
         v.getLocationOnScreen(pos);
         app.intent.setSourceBounds(new Rect(pos[0], pos[1],
                 pos[0] + v.getWidth(), pos[1] + v.getHeight()));
-        mLauncher.startActivitySafely(app.intent);
+        mLauncher.startActivitySafely(app.intent, app);
     }
 
     public void onClick(View v) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 1f48f5f..e4c7dea 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1262,7 +1262,7 @@
             v.getLocationOnScreen(pos);
             intent.setSourceBounds(new Rect(pos[0], pos[1],
                     pos[0] + v.getWidth(), pos[1] + v.getHeight()));
-            startActivitySafely(intent);
+            startActivitySafely(intent, tag);
         } else if (tag instanceof FolderInfo) {
             handleFolderClick((FolderInfo) tag);
         } else if (v == mHandleView) {
@@ -1274,17 +1274,19 @@
         }
     }
 
-    void startActivitySafely(Intent intent) {
+    void startActivitySafely(Intent intent, Object tag) {
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         try {
             startActivity(intent);
         } catch (ActivityNotFoundException e) {
             Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+            Log.e(TAG, "Unable to launch. tag=" + tag + " intent=" + intent);
         } catch (SecurityException e) {
             Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
             Log.e(TAG, "Launcher does not have the permission to launch " + intent +
                     ". Make sure to create a MAIN intent-filter for the corresponding activity " +
-                    "or use the exported attribute for this activity.", e);
+                    "or use the exported attribute for this activity. "
+                    + "tag="+ tag + " intent=" + intent, e);
         }
     }
     
diff --git a/src/com/android/launcher2/LiveFolder.java b/src/com/android/launcher2/LiveFolder.java
index c85a844..07a295f 100644
--- a/src/com/android/launcher2/LiveFolder.java
+++ b/src/com/android/launcher2/LiveFolder.java
@@ -60,10 +60,11 @@
                 Uri uri = baseIntent.getData();
                 uri = uri.buildUpon().appendPath(Long.toString(holder.id)).build();
                 intent.setData(uri);
-                mLauncher.startActivitySafely(intent);
+                mLauncher.startActivitySafely(intent, "(position=" + position + ", id=" + id + ")");
             }
         } else if (holder.intent != null) {
-            mLauncher.startActivitySafely(holder.intent);
+            mLauncher.startActivitySafely(holder.intent,
+                    "(position=" + position + ", id=" + id + ")");
         }
     }
 
diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/android/launcher2/ShortcutInfo.java
index 6e2d767..5c322ba 100644
--- a/src/com/android/launcher2/ShortcutInfo.java
+++ b/src/com/android/launcher2/ShortcutInfo.java
@@ -151,7 +151,7 @@
 
     @Override
     public String toString() {
-        return title.toString();
+        return "ShortcutInfo(title=" + title.toString() + ")";
     }
 
     @Override