Fix FINGERPRINT_WAKE_UNLOCK migration for devices not supporting it

Change-Id: I81469da5a1696f7ff92ff11216ba0b98459a9bde
This commit is contained in:
Michael Bestas
2023-03-20 02:37:31 +02:00
parent dc0c1d8a5c
commit 9f63a522db

View File

@@ -430,8 +430,7 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
}
if (upgradeVersion < 18) {
// Default config_requireScreenOnToAuthEnabled value is false
Integer oldSetting = 0;
Integer oldSetting;
db.beginTransaction();
SQLiteStatement stmt = null;
try {
@@ -440,14 +439,17 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
stmt.bindString(1, "fingerprint_wake_unlock");
oldSetting = Integer.parseInt(stmt.simpleQueryForString());
// Reverse 0/1 values, leave 2 as-is
if (oldSetting.equals(0)) {
// 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 is not set
// LineageSettings.System.FINGERPRINT_WAKE_UNLOCK was not set,
// default to config_requireScreenOnToAuthEnabled value
oldSetting = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_requireScreenOnToAuthEnabled) ? 1 : 0;
} finally {
if (stmt != null) stmt.close();
db.endTransaction();