summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan <adnan@cyngn.com>2014-11-10 18:35:02 (GMT)
committerAdnan <adnan@cyngn.com>2014-11-19 23:53:59 (GMT)
commitfc7b78a2af84012af65f36735ebcee4f24a22bc7 (patch)
tree0c6fad22c3ad610eebcf9b5318295fffe30e2df2
parent916ba22867bbbe05edc6ccc39622f0e569b00d58 (diff)
downloadandroid_packages_apps_Trebuchet-fc7b78a2af84012af65f36735ebcee4f24a22bc7.zip
android_packages_apps_Trebuchet-fc7b78a2af84012af65f36735ebcee4f24a22bc7.tar.gz
android_packages_apps_Trebuchet-fc7b78a2af84012af65f36735ebcee4f24a22bc7.tar.bz2
Trebuchet: Handle migrate from Launcher3/Trebuchet
Change-Id: I3d12c134a64afa855d803bce27e0de2915306ad2
-rw-r--r--src/com/android/launcher3/LauncherProvider.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index ecc1cdf..419505e 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -496,7 +496,7 @@ public class LauncherProvider extends ContentProvider {
"modified INTEGER NOT NULL DEFAULT 0," +
"restored INTEGER NOT NULL DEFAULT 0," +
"profileId INTEGER DEFAULT " + userSerialNumber +
- "hidden INTEGER DEFAULT 0" +
+ ",hidden INTEGER DEFAULT 0" +
");");
addWorkspacesTable(db);
@@ -959,7 +959,25 @@ public class LauncherProvider extends ContentProvider {
}
if (oldVersion < 21) {
- db.execSQL("ALTER TABLE favorites ADD hidden INTEGER DEFAULT 0");
+ //Check for column's existence, hackish way to make sure
+ //we can upgrade from Trebuchet and from Launcher3(new)
+ Cursor c = null;
+ try {
+ c = db.rawQuery("SELECT hidden FROM favorites", null);
+ //if we have don't have hidden, add it
+ if (c == null || (c != null && !c.moveToNext())) {
+ db.execSQL("ALTER TABLE favorites ADD hidden INTEGER DEFAULT 0");
+ } else {
+ //otherwise, we don't have profiles
+ addProfileColumn(db);
+ }
+ } catch (SQLException e) {
+ Log.e(TAG, e.getMessage(), e);
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ }
version = 21;
}