Adding app widget restore support in Launcher3 for android L

When the app is restored, it displays placeholders for all pending widgets.
These placeholders can be moved and removed similar to a widget (size is fixed
to what defined in backup). Once the system notifies the launcher of the new
widget ids, the place holders are replaced with actual widgets.

issue: 10779035

Change-Id: I68cbe4da01e9ca2978cb4471a7c645d2aa592055
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index bec1f9e..b3ac12b 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -28,6 +28,18 @@
  */
 public class LauncherAppWidgetInfo extends ItemInfo {
 
+    public static final int RESTORE_COMPLETED = 0;
+
+    /**
+     * This is set during the package backup creation.
+     */
+    public static final int RESTORE_REMAP_PENDING = 1;
+
+    /**
+     * Widget provider is not yet installed.
+     */
+    public static final int RESTORE_PROVIDER_PENDING = 2;
+
     /**
      * Indicates that the widget hasn't been instantiated yet.
      */
@@ -45,6 +57,11 @@
     int minWidth = -1;
     int minHeight = -1;
 
+    /**
+     * Indicates the restore status of the widget.
+     */
+    int restoreStatus;
+
     private boolean mHasNotifiedInitialWidgetSizeChanged;
 
     /**
@@ -64,6 +81,7 @@
         spanY = -1;
         // We only support app widgets on current user.
         user = UserHandleCompat.myUserHandle();
+        restoreStatus = RESTORE_COMPLETED;
     }
 
     @Override
@@ -101,4 +119,8 @@
         super.unbind();
         hostView = null;
     }
+
+    public final boolean isWidgetIdValid() {
+        return restoreStatus != RESTORE_REMAP_PENDING;
+    }
 }