Change existing migrations to use new helper methods
* We usually shouldn't touch existing migrations, they would have already ran for most (if not all) users, and don't run for existing users since they start at the latest version. * However, we've recently discovered many issues with these migrations, and past reported issues are now starting to make sense (they can be explained by migration running over and over again) * As such, let's fix this once and for all to make things clearer. * We also tend to copy older migrations when writing soemthing new so it should help having these done :) Change-Id: Ic45efc823da7ea8a137e79b3769a9ca53c2f8667
This commit is contained in:
committed by
Michael Bestas
parent
1c5a5dd010
commit
7e5dade283
@@ -431,29 +431,21 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
|
||||
}
|
||||
|
||||
if (upgradeVersion < 18) {
|
||||
Integer oldSetting;
|
||||
SQLiteStatement stmt = null;
|
||||
try {
|
||||
stmt = db.compileStatement("SELECT value FROM system WHERE name=?");
|
||||
// Used to be LineageSettings.System.FINGERPRINT_WAKE_UNLOCK
|
||||
stmt.bindString(1, "fingerprint_wake_unlock");
|
||||
oldSetting = Integer.parseInt(stmt.simpleQueryForString());
|
||||
Integer defaultValue = mContext.getResources().getBoolean(
|
||||
org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock)
|
||||
? 1 : 0; // Reversed since they're reversed again below
|
||||
|
||||
// Reverse 0/1 values, migrate 2 to 1
|
||||
if (oldSetting.equals(0) || oldSetting.equals(2)) {
|
||||
oldSetting = 1;
|
||||
} else if (oldSetting.equals(1)) {
|
||||
oldSetting = 0;
|
||||
}
|
||||
} catch (SQLiteDoneException ex) {
|
||||
// LineageSettings.System.FINGERPRINT_WAKE_UNLOCK was not set,
|
||||
// set default value based on config_fingerprintWakeAndUnlock
|
||||
oldSetting = mContext.getResources().getBoolean(
|
||||
org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock)
|
||||
? 0 : 1;
|
||||
} finally {
|
||||
if (stmt != null) stmt.close();
|
||||
// Used to be LineageSettings.System.FINGERPRINT_WAKE_UNLOCK
|
||||
Integer oldSetting = readIntegerSetting(db, LineageTableNames.TABLE_SYSTEM,
|
||||
"fingerprint_wake_unlock", defaultValue);
|
||||
|
||||
// Reverse 0/1 values, migrate 2 to 1
|
||||
if (oldSetting.equals(0) || oldSetting.equals(2)) {
|
||||
oldSetting = 1;
|
||||
} else if (oldSetting.equals(1)) {
|
||||
oldSetting = 0;
|
||||
}
|
||||
|
||||
// Previously Settings.Secure.SFPS_REQUIRE_SCREEN_ON_TO_AUTH_ENABLED
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
"sfps_require_screen_on_to_auth_enabled",
|
||||
|
||||
Reference in New Issue
Block a user