Homescreen migration from a larger grid to a smaller grid.

Adding support for restoring from a larger device, if the grid size
difference is not more that 1.
During restore add all the items in the DB, and run a one-time migration
the next time launcher starts.

The migration strategy is defined in ShrinkWorkspaceTask.java which involves
resizing, moving and removing some items.

Change-Id: I6ee411f6db5bf0152b527e16146a88c56dec2d97
diff --git a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
index 85af92f..9ba7853 100644
--- a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
@@ -5,6 +5,7 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.graphics.Point;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.os.Parcel;
@@ -110,4 +111,15 @@
             mMinSpanY = minResizeSpan[1];
         }
     }
+
+    public Point getMinSpans(InvariantDeviceProfile idp, Context context) {
+        // Calculate the spans corresponding to any one of the orientations as it should not change
+        // based on orientation.
+        // TODO: Use the max of both profiles
+        int[] minSpans = CellLayout.rectToCell(
+                idp.portraitProfile, context, minResizeWidth, minResizeHeight, null);
+        return new Point(
+                (resizeMode & RESIZE_HORIZONTAL) != 0 ? minSpans[0] : -1,
+                        (resizeMode & RESIZE_VERTICAL) != 0 ? minSpans[1] : -1);
+    }
  }