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

Commit e711b327 authored by Joshua Mccloskey's avatar Joshua Mccloskey
Browse files

Disable setting if sensor is convenience.

This change disables the FaceSettings Confirmation setting if a
sensor is convenience. This is due to the fact that convenience strength
sensors can't be used by BiometricPrompt (so this setting has no
effect.)

Test: Verified this setting shows depending on whether or not the sensor
is convenience or not.
Fixes: 204137656

Change-Id: I88daf9f12b76d06697275161385f463fb88e0f3a
parent 6f6149c7
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -19,13 +19,17 @@ package com.android.settings.biometrics.face;
import static android.provider.Settings.Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION;

import android.content.Context;
import android.hardware.biometrics.SensorProperties;
import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorProperties;
import android.provider.Settings;

import androidx.preference.Preference;

import com.android.settings.Utils;

import java.util.List;

/**
 * Preference controller giving the user an option to always require confirmation.
 */
@@ -75,6 +79,14 @@ public class FaceSettingsConfirmPreferenceController extends FaceSettingsPrefere

    @Override
    public int getAvailabilityStatus() {
        List<FaceSensorProperties> properties = mFaceManager.getSensorProperties();
        // If a sensor is convenience, it is possible that it becomes weak or strong with
        // an update. For this reason, the sensor is conditionally unavailable.
        if (!properties.isEmpty()
                && properties.get(0).getSensorStrength() == SensorProperties.STRENGTH_CONVENIENCE) {
            return CONDITIONALLY_UNAVAILABLE;
        } else {
            return AVAILABLE;
        }
    }
}