Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 823cde81 authored by Adithya R's avatar Adithya R Committed by Michael Bestas
Browse files

SystemUI: Add FingerprintInteractiveToAuthProvider implementation

This is required for the "touch to unlock anytime" setting on devices
with side mounted fingerprint sensor.

Ref: 66a048d6

Change-Id: If3308860a428d9966f2b0a0024764df95f8f9a8b
parent f62987ed
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
/*
 * 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 com.android.systemui.biometrics;

import android.content.Context;
import android.provider.Settings;

import javax.inject.Inject;

public class FingerprintInteractiveToAuthProviderImpl implements
        FingerprintInteractiveToAuthProvider {

    private final Context mContext;
    private final int mDefaultValue;

    @Inject
    public FingerprintInteractiveToAuthProviderImpl(Context context) {
        mContext = context;
        mDefaultValue = context.getResources().getBoolean(
                org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock) ? 1 : 0;
    }

    public boolean isEnabled(int userId) {
        int value = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, -1, userId);
        if (value == -1) {
            value = mDefaultValue;
            Settings.Secure.putIntForUser(mContext.getContentResolver(),
                    Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, value, userId);
        }
        return value == 0;
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.biometrics.dagger

import android.content.Context

import com.android.settingslib.udfps.UdfpsUtils
import com.android.systemui.biometrics.data.repository.FacePropertyRepository
import com.android.systemui.biometrics.data.repository.FacePropertyRepositoryImpl
@@ -38,6 +40,8 @@ import com.android.systemui.biometrics.domain.interactor.SideFpsOverlayInteracto
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractorImpl
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider
import com.android.systemui.biometrics.FingerprintInteractiveToAuthProviderImpl
import com.android.systemui.util.concurrency.ThreadFactory
import dagger.Binds
import dagger.Module
@@ -103,6 +107,10 @@ interface BiometricsModule {

        @Provides
        fun providesUdfpsUtils(): UdfpsUtils = UdfpsUtils()

        @Provides
        fun providesFingerprintInteractiveToAuth(ctx: Context): FingerprintInteractiveToAuthProvider =
            FingerprintInteractiveToAuthProviderImpl(ctx);
    }
}