LineageSettingsProvider: Fix migration of FORCE_SHOW_NAVBAR
* It was moved from Global to System but no migration was in place to handle upgrades from previous versions. Change-Id: If76243b0224dbc0138cf3c5dbc8aaeefa69f06a4
This commit is contained in:
committed by
Luca Stefani
parent
0cf297348d
commit
fab8bbfd32
@@ -51,7 +51,7 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
private static final String DATABASE_NAME = "lineagesettings.db";
|
||||
private static final int DATABASE_VERSION = 10;
|
||||
private static final int DATABASE_VERSION = 11;
|
||||
|
||||
private static final String DATABASE_NAME_OLD = "cmsettings.db";
|
||||
|
||||
@@ -362,6 +362,36 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
|
||||
}
|
||||
upgradeVersion = 10;
|
||||
}
|
||||
|
||||
if (upgradeVersion < 11) {
|
||||
// Move force_show_navbar to system
|
||||
if (mUserHandle == UserHandle.USER_OWNER) {
|
||||
db.beginTransaction();
|
||||
SQLiteStatement stmt = null;
|
||||
try {
|
||||
stmt = db.compileStatement("SELECT value FROM global WHERE name=?");
|
||||
stmt.bindString(1, LineageSettings.Global.DEV_FORCE_SHOW_NAVBAR);
|
||||
long value = stmt.simpleQueryForLong();
|
||||
|
||||
stmt = db.compileStatement("INSERT INTO system (name, value) VALUES (?, ?)");
|
||||
stmt.bindString(1, LineageSettings.System.FORCE_SHOW_NAVBAR);
|
||||
stmt.bindLong(2, value);
|
||||
stmt.execute();
|
||||
|
||||
stmt = db.compileStatement("DELETE FROM global WHERE name=?");
|
||||
stmt.bindString(1, LineageSettings.Global.DEV_FORCE_SHOW_NAVBAR);
|
||||
stmt.execute();
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} catch (SQLiteDoneException ex) {
|
||||
// LineageSettings.Global.DEV_FORCE_SHOW_NAVBAR is not set
|
||||
} finally {
|
||||
if (stmt != null) stmt.close();
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
upgradeVersion = 11;
|
||||
}
|
||||
// *** Remember to update DATABASE_VERSION above!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user