summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-03-15 23:07:53 (GMT)
committercretin45 <cretin45@gmail.com>2016-03-15 23:09:45 (GMT)
commit0991d315c4c23cde02b7c8c70761f694beedfa87 (patch)
tree75faaff1056e67032f9dee18ce238b930212b38b
parent772f61de9ad6a86dcccbab308c7202e770975ce6 (diff)
downloadandroid_packages_apps_Trebuchet-0991d315c4c23cde02b7c8c70761f694beedfa87.zip
android_packages_apps_Trebuchet-0991d315c4c23cde02b7c8c70761f694beedfa87.tar.gz
android_packages_apps_Trebuchet-0991d315c4c23cde02b7c8c70761f694beedfa87.tar.bz2
Trebuchet: Fix some issues with the DB upgrade path
Issue-id: CYNGNOS-2249 Change-Id: If124a9ac51c665c869cf5a745390374658b87156
-rw-r--r--src/com/android/launcher3/LauncherProvider.java35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 022ccac..8047e7c 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -746,7 +746,8 @@ public class LauncherProvider extends ContentProvider {
if (!recreateWorkspaceTable(db)) {
break;
}
- case 22: {
+ case 22:
+ case 23:
if (!addIntegerColumn(db, Favorites.OPTIONS, 0)) {
// Old version remains, which means we wipe old data
break;
@@ -755,9 +756,6 @@ public class LauncherProvider extends ContentProvider {
// Old version remains, which means we wipe old data
break;
}
- }
- case 23:
- // No-op
case 24:
ManagedProfileHeuristic.markExistingUsersForNoFolderCreation(mContext);
case 25:
@@ -782,18 +780,11 @@ public class LauncherProvider extends ContentProvider {
"com.android.camera.CameraLauncher");
}
case 28: {
- db.beginTransaction();
- try {
- db.execSQL("ALTER TABLE favorites " +
- "ADD COLUMN subType INTEGER DEFAULT 0;");
- db.setTransactionSuccessful();
- db.endTransaction();
- return;
- } catch (SQLException ex) {
+ if (!ensureSubTypeColumn(db)) {
// Old version remains, which means we wipe old data
- Log.e(TAG, ex.getMessage(), ex);
- db.endTransaction();
+ break;
}
+ return;
}
}
@@ -986,6 +977,22 @@ public class LauncherProvider extends ContentProvider {
return true;
}
+ @Thunk boolean ensureSubTypeColumn(SQLiteDatabase db) {
+ Cursor c = null;
+ try {
+ // Make sure subType exists
+ c = db.rawQuery("SELECT subType FROM favorites;", null);
+ } catch (SQLException ex) {
+ Log.e(TAG, ex.getMessage(), ex);
+ return addIntegerColumn(db, "subType", 0);
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ }
+ return true;
+ }
+
private boolean addProfileColumn(SQLiteDatabase db) {
UserManagerCompat userManager = UserManagerCompat.getInstance(mContext);
// Default to the serial number of this user, for older