Initial changes to allow dragging external shortcuts to launcher using the same InstallShortcut intent.

Change-Id: I21b57115429ed37d604084ae01308d1d3f33ee7e
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 1e58ca0..179a5d5 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1513,14 +1513,25 @@
     ShortcutInfo addShortcut(Context context, Intent data,
             int screen, int cellX, int cellY, boolean notify) {
 
-        final ShortcutInfo info = infoFromShortcutIntent(context, data);
+        final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
         addItemToDatabase(context, info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
                 screen, cellX, cellY, notify);
 
         return info;
     }
 
-    private ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
+    /**
+     * Ensures that a given shortcut intent actually has all the fields that we need to create a
+     * proper ShortcutInfo.
+     */
+    boolean validateShortcutIntent(Intent data) {
+        // We don't require Intent.EXTRA_SHORTCUT_ICON, since we can pull a default fallback icon
+        return InstallShortcutReceiver.ACTION_INSTALL_SHORTCUT.equals(data.getAction()) &&
+                (data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT) != null) &&
+                (data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME) != null);
+    }
+
+    ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {
         Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
         String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
         Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
@@ -1553,8 +1564,12 @@
         final ShortcutInfo info = new ShortcutInfo();
 
         if (icon == null) {
-            icon = getFallbackIcon();
-            info.usingFallbackIcon = true;
+            if (fallbackIcon != null) {
+                icon = fallbackIcon;
+            } else {
+                icon = getFallbackIcon();
+                info.usingFallbackIcon = true;
+            }
         }
         info.setIcon(icon);