summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-07-27 14:36:07 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-07-31 12:03:33 -0700
commite5bb705fb79f18df8680958dcf2c5460e16c90b6 (patch)
tree33c20c832cf07556ca8d0d3c114489c95190a3f0 /src/com/android/launcher3/LauncherModel.java
parente40e77b34f6521d3caaa8eb49b9e073258e91f56 (diff)
downloadandroid_packages_apps_Trebuchet-e5bb705fb79f18df8680958dcf2c5460e16c90b6.tar.gz
android_packages_apps_Trebuchet-e5bb705fb79f18df8680958dcf2c5460e16c90b6.tar.bz2
android_packages_apps_Trebuchet-e5bb705fb79f18df8680958dcf2c5460e16c90b6.zip
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
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0b67310fa..7e75f9793 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
@@ -55,6 +56,7 @@ import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.model.MigrateFromRestoreTask;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.CursorIconInfo;
@@ -1133,7 +1135,7 @@ public class LauncherModel extends BroadcastReceiver
* Update the order of the workspace screens in the database. The array list contains
* a list of screen ids in the order that they should appear.
*/
- void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
+ public void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
final ContentResolver cr = context.getContentResolver();
final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -1411,7 +1413,7 @@ public class LauncherModel extends BroadcastReceiver
/**
* Loads the workspace screen ids in an ordered list.
*/
- @Thunk static ArrayList<Long> loadWorkspaceScreensDb(Context context) {
+ public static ArrayList<Long> loadWorkspaceScreensDb(Context context) {
final ContentResolver contentResolver = context.getContentResolver();
final Uri screensUri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -1757,6 +1759,22 @@ public class LauncherModel extends BroadcastReceiver
int countX = (int) profile.numColumns;
int countY = (int) profile.numRows;
+
+ if (MigrateFromRestoreTask.shouldRunTask(mContext)) {
+ try {
+ MigrateFromRestoreTask task = new MigrateFromRestoreTask(mContext);
+ // Clear the flags before starting the task, so that we do not run the task
+ // again, in case there was an uncaught error.
+ MigrateFromRestoreTask.clearFlags(mContext);
+ task.execute();
+ } catch (Exception e) {
+ Log.e(TAG, "Error during grid migration", e);
+
+ // Clear workspace.
+ mFlags = mFlags | LOADER_FLAG_CLEAR_WORKSPACE;
+ }
+ }
+
if ((mFlags & LOADER_FLAG_CLEAR_WORKSPACE) != 0) {
Launcher.addDumpLog(TAG, "loadWorkspace: resetting launcher database", true);
LauncherAppState.getLauncherProvider().deleteDatabase();