Migrate side FPS settings

* Really shouldn't have touched an existing migration before
* Anywho, let's change it back to what it was but make it compile
* Then, let's migrate that old setting to the new AOSP setting,
  but flip it since it works differently.

Change-Id: I342d8c78aa8faeda5dcaafe9199deb51c570efd0
diff --git a/lineage/res/res/values/config.xml b/lineage/res/res/values/config.xml
index de59ce5..da1e594 100644
--- a/lineage/res/res/values/config.xml
+++ b/lineage/res/res/values/config.xml
@@ -288,6 +288,12 @@
          (needed for some older vendor fingerprint HAL implementations) -->
     <bool name="config_fingerprintPostResetRunnableForAllClients">false</bool>
 
+    <!-- Should we listen for fingerprints when the screen is off?  Devices
+         with a rear-mounted sensor want this, but certain devices have
+         the sensor embedded in the power key and listening all the time
+         causes a poor experience. -->
+    <bool name="config_fingerprintWakeAndUnlock">true</bool>
+
     <!-- The list of components which should be automatically disabled for a specific device.
          Note: this MUST not be used to randomly disable components, ask for approval first! -->
     <string-array name="config_deviceDisabledComponents" translatable="false" />
diff --git a/lineage/res/res/values/symbols.xml b/lineage/res/res/values/symbols.xml
index 52904de..0499710 100644
--- a/lineage/res/res/values/symbols.xml
+++ b/lineage/res/res/values/symbols.xml
@@ -173,6 +173,12 @@
          (needed for some older vendor fingerprint HAL implementations) -->
     <java-symbol type="bool" name="config_fingerprintPostResetRunnableForAllClients" />
 
+    <!-- Should we listen for fingerprints when the screen is off?  Devices
+         with a rear-mounted sensor want this, but certain devices have
+         the sensor embedded in the power key and listening all the time
+         causes a poor experience. -->
+    <java-symbol type="bool" name="config_fingerprintWakeAndUnlock" />
+
     <!-- Package Manager -->
     <java-symbol type="array" name="config_deviceDisabledComponents" />
     <java-symbol type="array" name="config_globallyDisabledComponents" />
diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
index 3e468f2..ec931f2 100644
--- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
+++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
@@ -60,7 +60,7 @@
     private static final boolean LOCAL_LOGV = false;
 
     private static final String DATABASE_NAME = "lineagesettings.db";
-    private static final int DATABASE_VERSION = 18;
+    private static final int DATABASE_VERSION = 19;
 
     private static final String DATABASE_NAME_OLD = "cmsettings.db";
 
@@ -447,18 +447,33 @@
                 }
             } catch (SQLiteDoneException ex) {
                 // LineageSettings.System.FINGERPRINT_WAKE_UNLOCK was not set,
-                // default to config_performantAuthDefault value
+                // set default value based on config_fingerprintWakeAndUnlock
                 oldSetting = mContext.getResources().getBoolean(
-                        com.android.internal.R.bool.config_performantAuthDefault) ? 1 : 0;
+                        org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock)
+                        ? 0 : 1;
             } finally {
                 if (stmt != null) stmt.close();
                 db.endTransaction();
             }
+            // Previously Settings.Secure.SFPS_REQUIRE_SCREEN_ON_TO_AUTH_ENABLED
             Settings.Secure.putInt(mContext.getContentResolver(),
-                    Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED,
+                    "sfps_require_screen_on_to_auth_enabled",
                     oldSetting);
             upgradeVersion = 18;
         }
+
+        if (upgradeVersion < 19) {
+            // Set default value based on config_fingerprintWakeAndUnlock
+            boolean fingerprintWakeAndUnlock = mContext.getResources().getBoolean(
+                    org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock);
+            // Previously Settings.Secure.SFPS_REQUIRE_SCREEN_ON_TO_AUTH_ENABLED
+            Integer oldSetting = Settings.Secure.getInt(mContext.getContentResolver(),
+                    "sfps_require_screen_on_to_auth_enabled", fingerprintWakeAndUnlock ? 0 : 1);
+            // Flip value
+            Settings.Secure.putInt(mContext.getContentResolver(),
+                    Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, oldSetting.equals(1) ? 0 : 1);
+            upgradeVersion = 19;
+        }
         // *** Remember to update DATABASE_VERSION above!
         if (upgradeVersion != newVersion) {
             Log.wtf(TAG, "warning: upgrading settings database to version "