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

Unverified Commit 3295311e authored by LuK1337's avatar LuK1337 Committed by Michael Bestas
Browse files

AuthService: Add support for workaround side fps props

HIDL fingerprint implementations have no way of providing this info.

Change-Id: I1eeda59c84868715338b6707247a9c7eecca1af3
parent 65952fe3
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line 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.BiometricConstants.BIOMETRIC_ERROR_CANCELED;
import static android.hardware.biometrics.BiometricManager.Authenticators;
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.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.AppOpsManager;
@@ -802,6 +804,10 @@ public class AuthService extends SystemService {
        final int[] udfpsProps = getContext().getResources().getIntArray(
        final int[] udfpsProps = getContext().getResources().getIntArray(
                com.android.internal.R.array.config_udfps_sensor_props);
                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);
        final boolean isUdfps = !ArrayUtils.isEmpty(udfpsProps);


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


    private static final String TAG = "FingerprintProvider";

    private boolean mTestHalEnabled;
    private boolean mTestHalEnabled;


    @NonNull
    @NonNull
@@ -234,7 +236,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
    }
    }


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


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


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


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