10

I need to integrate Biometric authentication using Fingerprint and Face authentication. Fingerprint authentication works perfectly but when I set only Face authentication I am getting Biometric not enrolled response from BiometricManager.from(context) method as follows,

val biometricManager = BiometricManager.from(context)
    when(biometricManager.canAuthenticate()){
        BiometricManager.BIOMETRIC_SUCCESS ->{
            Log.e(TAG, "App can authenticate using biometrics.")
        }
        BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->{
            Log.d(TAG, "Hardware not available")
        }
        BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ->{
            Log.d(TAG, "Biometric features are currently unavailable.")
        }
        BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED ->{
            Log.d(TAG, "The user hasn't associated any biometric credentials with their account.")
        }
        else ->{
            Log.d(TAG, "Nothing supported")
        }
    }
D. McDermott
  • 100
  • 7
Vijay Patole
  • 355
  • 3
  • 17

4 Answers4

7

Android Biometric APIs would only work on the devices which have their biometric features (face,fingerprint, iris) compatible with Android Biometric stack. I have a set of devices with Face feature support, among them only few support Android Biometrics.

Shanker
  • 864
  • 6
  • 24
  • 1
    i am using Samsung S10. I can able to authenticate Fingerprint/FaceId. My tablet have only on faceId unable ti show biometric alert it shown hardware not available - error code 12. Code:val authFlag = DEVICE_CREDENTIAL or BIOMETRIC_STRONG promptInfo = BiometricPrompt.PromptInfo.Builder() .setTitle(title).setSubtitle(subtitle).setDescription(description).setAllowedAuthenticators(authFlag).build() I am using this code to shown biometric dialog. if i have only faceId what should i do? – Shobana Velmurugan May 19 '22 at 11:59
3

After looking at all the hurdles implementing the biometric for Android, I have chosen not to use BiometricManager.from(context) method to check if Biometric authentication is enabled, instead of that checked if KEYGUARD_SERVICE is enabled and used following prompt info

BiometricPrompt.PromptInfo.Builder().apply {
            setTitle(getString(R.string.title))
            setSubtitle(getString(R.string.sub_title))
            setConfirmationRequired(true)
            setDeviceCredentialAllowed(true)
        }.build()

through which even if only face ID is set and is not supporting the current callbacks, application fallbacks to devices PIN authentication method.

Ganesh Tikone
  • 1,047
  • 1
  • 8
  • 15
Vijay Patole
  • 355
  • 3
  • 17
  • Did this work, when there are no biometrics( face and fingerprint ) enrolled in device ? – Shanker Sep 07 '20 at 06:12
  • Yes, it is working need to add validation keyguardManager.isKeyguardSecure – Vijay Patole Sep 07 '20 at 06:30
  • What is being shown in system prompt when you call authenticate() and there are no biometrics enrolled in device and KEYGUARD_SERVICE is enabled. On which device did you test this ? I suggest you to test in multiple devices – Shanker Sep 07 '20 at 06:49
  • 1
    yes, if no biometrics enrolled in the device but KEYGUARD_SERVICE is enabled then app asks for PIN/Pattern lock to authenticate. I have tested the same on Oneplus 6, LG, Samsung J7 which does not have biometric hardware, redmi device as well. – Vijay Patole Sep 07 '20 at 07:13
  • @VijayPatole Can you please share your code? I'm stuck at some point. – Maulik Dodia Jan 19 '21 at 11:11
2

I face the same issue while integrating it into my app When I use

biometricManager.canAuthenticate(BIOMETRIC_STRONG)

to check biometric is available in the device it return BIOMETRIC_ERROR_NONE_ENROLLED and as soon as I change the authentication mode to BIOMETRIC_WEEKit work well I test on Samsung S9 and a few Other devices. Currently is use this biometeric dependency hope it works for you

implementation "androidx.biometric:biometric-ktx:1.2.0-alpha03"
Abdul Wahab
  • 411
  • 6
  • 15
0

Some of the facts I have found while I was working with it. This is based on Biometric API "implementation 'androidx.biometric:biometric:1.0.1'".

  1. Samsung device doesn't support face recognition as it doesn't have a 3D face unlock refer here. The issue is open on the Samsung side, as Samsung had face unlock developed by Samsung itself and not from google OS. But it does support fingerprint scans using biometric manager API.
  2. True face unlocks will only work with Pixel 4(This is based on my testing, not sure other device support but I have tested top-notch device is Samsung including the Note series and Galaxy series, and Motorola series) I only able to use face unlock in Pixel 4.
  3. Samsung is working on it and will be available soon(Not sure when).
  4. Very few application support face unlock as of now as most Android base devices are not from google and 3d based unlock is not available on the manufacturing side.

I have created reference POC for the community to help. The documentation hasn't provided good documentation on biometric change detection. This is pure kotlin code and also detects the biometric change and many functions such as does user enrolled in Bio, does device enroll in Bio, what type of biometric, is the user previously enrolled. Please take a look at this link.

K P
  • 182
  • 9
  • Hope you have not validated on Samsung S10 device, Samsung S10 is compatible with Android Biometric stack. Statement "IRIS does not handle by Biometrics" is wrong. If a device has IRIS feature compatible with Android Biometric stack, then it would work. In my devices repo, I have Samsung S10, MI and Pixel 4 device which are compatible with Android Biometrics . – Shanker Sep 05 '20 at 07:45
  • Please go through Android Biometric CDD doc https://source.android.com/compatibility/android-cdd#7_3_10_biometric_sensors – Shanker Sep 05 '20 at 07:51
  • Please read my answer I mention Face recognition. All devices are biometric compatible. There are three different versions in S10 if you carefully work. I have work with s10e and still not support, the reason is the patch has been not released by Samsung itself and it as on the waiting list. I have edited my answer which was IRIS related and IRIS is not pure Biometric. – K P Sep 05 '20 at 14:36
  • Can you explain me why IRIS is not pure Biometric ? I was referring to your statement "Samsung device doesn't support face recognition as it doesn't have a 3D face unlock." I am also trying to understand, what is the dependence of "Face Authentication on 3D face unlock" – Shanker Sep 05 '20 at 14:40
  • Face, IRIS and Fingerprint are part of biometrics.You can refer https://source.android.com/compatibility/android-cdd#7_3_10_biometric_sensors. Question is about face authentication using Android Biometrics . A device fingerprint sensors may compatible with Android Biometrics, It doesnt mean its face sensors too would be supporting Andrid Biometrics. – Shanker Sep 05 '20 at 14:50
  • Yes, all three are biometric. Samsung device doesn't support face unlock even with the biometric manager. Can you confirm your s10 support face unlock with biometrics manager API implementation? Please provide me link for your code. – K P Sep 05 '20 at 14:53
  • There is nothing to do with the code. Yes I confirm Samsung S10 device supports Android Biometrics implementation. It might be you are having older version of Samsung S10 device which dont support Android Biometrics. – Shanker Sep 05 '20 at 15:02
  • I am asking face unlock, not biometric support. – K P Sep 05 '20 at 15:05
  • Yes dude, Face unlock is supported. You can trust me, I have personally tested it. I strongly feel stackoverflow is a platform to help each other and I am just trying to explain you. – Shanker Sep 05 '20 at 15:09
  • Please go through this stack https://stackoverflow.com/questions/55634812/biometricprompt-crashes-on-samsung-s9-with-face-unlock – K P Sep 05 '20 at 15:16
  • I have gone through it, its a older post. Wait until monday, I wil try to share you video, so that it clears your doubt. – Shanker Sep 05 '20 at 15:48
  • Please find image in https://ibb.co/F8LTBpp, which shows both Face and Fingerprint authentication in Biometric System prompt. Note : zoom in more in the image to observe fingerprint icon. – Shanker Sep 08 '20 at 07:24
  • @Shanker: on which device you run the code and is it supporting all the devices having the face and fingerprint authentication?...What in case if the only Face is set for authentication? – Vijay Patole Sep 16 '20 at 04:13