I am currently developing a Biometrics library for a project and can't seem to make facial recognition work.
The BiometricManager works correctly for fingerprints in all devices i've tried, however it doesn't detect any enrolled face biometrics for my Huawei P30 ELE-L29 (EMUI version 10.0.0 - Android version 10) and return BIOMETRIC_ERROR_NONE_ENROLLED when I call BiometricManager#canAuthenticate(). This is the only device with API version 29 I have available since Android Studio emulator doesn't have facial recognition implemented and other emulators (Bluestacks, Nox, etc.) can't be configured to run on Android 10 on my macbook.
I would appreciate any light on the subject since facial recognition is new for native android and I couldn't find any similar issue out there. I'm not sure if it's a problem with this particular phone or if I have an error in my code.
My minSdkVersion is 23 (Android 6.0 Marshmallow) and my targetSdkVersion is 29 (Android 10 Q).
My (partial) implementation:
fun isBiometricsSupported(@NonNull context: Context): Boolean {
val biometricManager = BiometricManager.from(context)
var isBiometricsSupported = false
when (biometricManager.canAuthenticate()) {
BiometricManager.BIOMETRIC_SUCCESS -> {
isBiometricsSupported = true
}
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> {
Log.println(Log.INFO, "a", "Logger: BIOMETRIC_ERROR_NO_HARDWARE")
}
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> {
Log.println(Log.INFO, "a", "Logger: BIOMETRIC_ERROR_NONE_ENROLLED")
//It always goes here if I don't have any fingerprints enrolled,
//ignoring all other biometric data I may have.
}
BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> {
Log.println(Log.ERROR, "a", "Logger: BIOMETRIC_ERROR_HW_UNAVAILABLE")
}
}
return isBiometricsSupported
}