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

Commit 21986c0b authored by LuK1337's avatar LuK1337 Committed by Bruno Martins
Browse files

AuthService: Add support for workaround side fps props

HIDL fingerprint implementations have no way of providing this info.

Change-Id: I1eeda59c84868715338b6707247a9c7eecca1af3
parent 469347b2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE;
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED;
import static android.hardware.biometrics.BiometricManager.Authenticators;

import static com.android.server.biometrics.sensors.fingerprint.aidl.FingerprintProvider.getWorkaroundSensorProps;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
@@ -742,6 +744,10 @@ public class AuthService extends SystemService {
        final int[] udfpsProps = getContext().getResources().getIntArray(
                com.android.internal.R.array.config_udfps_sensor_props);

        // Non-empty workaroundLocations indicates that the sensor is SFPS.
        final List<SensorLocationInternal> workaroundLocations =
                getWorkaroundSensorProps(getContext());

        final boolean isUdfps = !ArrayUtils.isEmpty(udfpsProps);

        // config_is_powerbutton_fps indicates whether device has a power button fingerprint sensor.
@@ -770,6 +776,11 @@ public class AuthService extends SystemService {
                    componentInfo, sensorType, resetLockoutRequiresHardwareAuthToken,
                    List.of(new SensorLocationInternal("" /* display */,
                            udfpsProps[0], udfpsProps[1], udfpsProps[2])));
        } else if (!workaroundLocations.isEmpty()) {
            return new FingerprintSensorPropertiesInternal(sensorId,
                    Utils.authenticatorStrengthToPropertyStrength(strength), maxEnrollmentsPerUser,
                    componentInfo, sensorType, resetLockoutRequiresHardwareAuthToken,
                    workaroundLocations);
        } else {
            return new FingerprintSensorPropertiesInternal(sensorId,
                    Utils.authenticatorStrengthToPropertyStrength(strength), maxEnrollmentsPerUser,
+6 −4
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ import java.util.concurrent.atomic.AtomicLong;
@SuppressWarnings("deprecation")
public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvider {

    private static final String TAG = "FingerprintProvider";

    private boolean mTestHalEnabled;

    @NonNull private final Context mContext;
@@ -183,7 +185,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
    }

    private String getTag() {
        return "FingerprintProvider/" + mHalInstanceName;
        return TAG + "/" + mHalInstanceName;
    }

    boolean hasHalInstance() {
@@ -658,7 +660,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
    // TODO(b/174868353): workaround for gaps in HAL interface (remove and get directly from HAL)
    // reads values via an overlay instead of querying the HAL
    @NonNull
    private List<SensorLocationInternal> getWorkaroundSensorProps(@NonNull Context context) {
    public static List<SensorLocationInternal> getWorkaroundSensorProps(@NonNull Context context) {
        final List<SensorLocationInternal> sensorLocations = new ArrayList<>();

        final TypedArray sfpsProps = context.getResources().obtainTypedArray(
@@ -679,7 +681,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
    }

    @Nullable
    private SensorLocationInternal parseSensorLocation(@Nullable TypedArray array) {
    private static SensorLocationInternal parseSensorLocation(@Nullable TypedArray array) {
        if (array == null) {
            return null;
        }
@@ -691,7 +693,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
                    array.getInt(2, 0),
                    array.getInt(3, 0));
        } catch (Exception e) {
            Slog.w(getTag(), "malformed sensor location", e);
            Slog.w(TAG, "malformed sensor location", e);
        }
        return null;
    }