From 916ba22867bbbe05edc6ccc39622f0e569b00d58 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Mon, 10 Nov 2014 10:35:02 -0800 Subject: Fix L2 and old Trebuchet migration There can only be one original-package tag. Go with com.android.launcher3 for now, and move Trebuchet back to com.cyanogenmod.trebuchet. This will allow for workspace migrations from both CM10.2 Trebuchet and from CM11 Launcher3 Change-Id: I7743954bffc55f503851038f800607947e20015e --- src/com/android/launcher3/LauncherProvider.java | 58 ++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'src/com/android') diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index 8da3a2482..ecc1cdf75 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -853,7 +853,6 @@ public class LauncherProvider extends ContentProvider { } } - if (version < 16) { db.beginTransaction(); try { @@ -869,6 +868,63 @@ public class LauncherProvider extends ContentProvider { db.endTransaction(); } } + // This was the old L2-based Trebuchet's version. Do steps that come after version 12 + // (Launcher2's original version) so the new things get added, but skip the intermediate + // workspaceScreens updates (addWorkspacesTable() takes care of that) + + if (version == 16) { + Log.w(TAG, "Found pre-11 Trebuchet, preparing update"); + + // With the new shrink-wrapped and re-orderable workspaces, it makes sense + // to persist workspace screens and their relative order. + mMaxScreenId = 0; + + // This will never happen in the wild, but when we switch to using workspace + // screen ids, redo the import from old launcher. + sJustLoadedFromOldDb = true; + + addWorkspacesTable(db); + + Cursor c = null; + long screenId = -1; + try { + c = db.rawQuery("SELECT max(screen) FROM favorites", null); + if (c != null && c.moveToNext()) { + screenId = c.getLong(0); + } + if (c != null) { + c.close(); + } + } catch (SQLException ex) { + Log.e(TAG, ex.getMessage(), ex); + } + + + db.beginTransaction(); + try { + // Insert new column for holding widget provider name + db.execSQL("ALTER TABLE favorites " + + "ADD COLUMN appWidgetProvider TEXT;"); + db.execSQL("ALTER TABLE favorites " + + "ADD COLUMN modified INTEGER NOT NULL DEFAULT 0;"); + // Create workspaces for the migrated things + if (screenId > 0) { + for (int sId = 0; sId <= screenId; sId++) { + db.execSQL("INSERT INTO workspaceScreens (_id, screenRank) " + + "VALUES (" + (sId+1) + ", " + sId + ")"); + } + } + // Adjust hotseat format + db.execSQL("UPDATE favorites SET screen=cellX WHERE container=-101;"); + db.setTransactionSuccessful(); + version = 17; + } catch (SQLException ex) { + // Old version remains, which means we wipe old data + Log.e(TAG, ex.getMessage(), ex); + } finally { + db.endTransaction(); + } + } if (version < 17) { // We use the db version upgrade here to identify users who may not have seen -- cgit v1.2.3