diff --git a/src/co/aospa/systemui/biometrics/FingerprintInteractiveToAuthProviderImpl.kt b/src/co/aospa/systemui/biometrics/FingerprintInteractiveToAuthProviderImpl.kt new file mode 100644 index 0000000..b5a787c --- /dev/null +++ b/src/co/aospa/systemui/biometrics/FingerprintInteractiveToAuthProviderImpl.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 ArrowOS + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package co.aospa.systemui.biometrics + +import android.content.Context +import android.provider.Settings + +import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider + +import javax.inject.Inject + +class FingerprintInteractiveToAuthProviderImpl @Inject constructor(private val context: Context) : FingerprintInteractiveToAuthProvider { + + private val defaultValue = if (context.getResources().getBoolean( + com.android.internal.R.bool.config_performantAuthDefault)) 1 else 0 + + override fun isEnabled(userId: Int): Boolean { + var value = Settings.Secure.getIntForUser(context.contentResolver, + Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, -1, userId) + if (value == -1) { + value = defaultValue + Settings.Secure.putIntForUser(context.contentResolver, + Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, value, userId) + } + return value == 0 + } +} diff --git a/src/co/aospa/systemui/dagger/ParanoidSystemUIModule.java b/src/co/aospa/systemui/dagger/ParanoidSystemUIModule.java index 13d229d..a6a5f48 100644 --- a/src/co/aospa/systemui/dagger/ParanoidSystemUIModule.java +++ b/src/co/aospa/systemui/dagger/ParanoidSystemUIModule.java @@ -27,6 +27,7 @@ import android.os.Handler; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardViewController; import com.android.systemui.battery.BatterySaverModule; +import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider; import com.android.systemui.controls.controller.ControlsTileResourceConfiguration; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; @@ -73,6 +74,7 @@ import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; import javax.inject.Named; +import co.aospa.systemui.biometrics.FingerprintInteractiveToAuthProviderImpl; import co.aospa.systemui.controls.AospaControlsTileResourceConfigurationImpl; import co.aospa.systemui.qs.tileimpl.ParanoidQSFactoryImpl; import co.aospa.systemui.qs.tileimpl.ParanoidQSModule; @@ -208,4 +210,7 @@ public abstract class ParanoidSystemUIModule { @Binds abstract ControlsTileResourceConfiguration bindControlsTileResourceConfiguration(AospaControlsTileResourceConfigurationImpl configuration); + + @Binds + abstract FingerprintInteractiveToAuthProvider bindFingerprintInteractiveToAuthProviderImpl(FingerprintInteractiveToAuthProviderImpl impl); }