Mark all settings upgrade transactions as successful along the way

If you don't, then the upgrade gets rolled back by the open helper,
and Bad Stuff Happens.

Change-Id: I191263e5cceb21b96ef413d28e7ee00a924acfc2
This commit is contained in:
Christopher Tate
2012-09-06 22:17:43 -07:00
parent 8e21d4df21
commit 1a9c0dfdbb

View File

@@ -67,7 +67,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
// is properly propagated through your change. Not doing so will result in a loss of user
// settings.
private static final int DATABASE_VERSION = 84;
private static final int DATABASE_VERSION = 85;
private Context mContext;
private int mUserHandle;
@@ -1241,6 +1241,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
R.bool.def_accessibility_display_magnification_auto_update);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
@@ -1248,6 +1250,28 @@ public class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 84;
}
if (upgradeVersion == 84) {
db.beginTransaction();
SQLiteStatement stmt = null;
try {
// Patch up the slightly-wrong key migration from 82 -> 83
String[] settingsToMove = {
Settings.Secure.ADB_ENABLED,
Settings.Secure.BLUETOOTH_ON,
Settings.Secure.DATA_ROAMING,
Settings.Secure.DEVICE_PROVISIONED,
Settings.Secure.INSTALL_NON_MARKET_APPS,
Settings.Secure.USB_MASS_STORAGE_ENABLED
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null) stmt.close();
}
upgradeVersion = 85;
}
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != currentVersion) {