Supporting custom widgets provided by launcher

-> This change provides integration for widgets provided by
   the launcher package which can run arbitrary code.

Change-Id: I6052da5c4afed7ee72e3b44d045b9c46f2d84c42
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index 5c6535a..aad18b5 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -56,6 +56,11 @@
     static final int NO_ID = -1;
 
     /**
+     * Indicates that this is a locally defined widget and hence has no system allocated id.
+     */
+    static final int CUSTOM_WIDGET_ID = -100;
+
+    /**
      * Identifier for this widget when talking with
      * {@link android.appwidget.AppWidgetManager} for updates.
      */
@@ -86,7 +91,12 @@
     AppWidgetHostView hostView = null;
 
     LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) {
-        itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
+        if (appWidgetId == CUSTOM_WIDGET_ID) {
+            itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
+        } else {
+            itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
+        }
+
         this.appWidgetId = appWidgetId;
         this.providerName = providerName;
 
@@ -99,6 +109,10 @@
         restoreStatus = RESTORE_COMPLETED;
     }
 
+    public boolean isCustomWidget() {
+        return appWidgetId == CUSTOM_WIDGET_ID;
+    }
+
     @Override
     void onAddToDatabase(Context context, ContentValues values) {
         super.onAddToDatabase(context, values);