Skip to content

Commit 1a9c0df

Browse files
author
Christopher Tate
committed
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
1 parent 8e21d4d commit 1a9c0df

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6767
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6868
// is properly propagated through your change. Not doing so will result in a loss of user
6969
// settings.
70-
private static final int DATABASE_VERSION = 84;
70+
private static final int DATABASE_VERSION = 85;
7171

7272
private Context mContext;
7373
private int mUserHandle;
@@ -1241,13 +1241,37 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
12411241
loadBooleanSetting(stmt,
12421242
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
12431243
R.bool.def_accessibility_display_magnification_auto_update);
1244+
1245+
db.setTransactionSuccessful();
12441246
} finally {
12451247
db.endTransaction();
12461248
if (stmt != null) stmt.close();
12471249
}
12481250
upgradeVersion = 84;
12491251
}
12501252

1253+
if (upgradeVersion == 84) {
1254+
db.beginTransaction();
1255+
SQLiteStatement stmt = null;
1256+
try {
1257+
// Patch up the slightly-wrong key migration from 82 -> 83
1258+
String[] settingsToMove = {
1259+
Settings.Secure.ADB_ENABLED,
1260+
Settings.Secure.BLUETOOTH_ON,
1261+
Settings.Secure.DATA_ROAMING,
1262+
Settings.Secure.DEVICE_PROVISIONED,
1263+
Settings.Secure.INSTALL_NON_MARKET_APPS,
1264+
Settings.Secure.USB_MASS_STORAGE_ENABLED
1265+
};
1266+
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove);
1267+
db.setTransactionSuccessful();
1268+
} finally {
1269+
db.endTransaction();
1270+
if (stmt != null) stmt.close();
1271+
}
1272+
upgradeVersion = 85;
1273+
}
1274+
12511275
// *** Remember to update DATABASE_VERSION above!
12521276

12531277
if (upgradeVersion != currentVersion) {

0 commit comments

Comments
 (0)