flutter
flutter copied to clipboard
[local_auth][ANDROID] getAvailableBiometrics doesn't return some enrolled biometric options
Steps to Reproduce
- Have a device supporting face (weak) and fingerprint (strong) for security checks.
- Disable fingerprint in the device's options and leave the face recognition enabled for app authentication and phone unlock.
- Call
await LocalAuthentication().getAvailableBiometrics();
- Check the result where the list of available biometrics is empty.
NOTE: if the fingerprint is enabled in the phone settings, the result contains a list of both types: BiometricType.weak
& BiometricType.strong
. The devices I tested this on were Samsung Galaxy A8 2018, Pixel 7 Pro, Samsung Galaxy Note20, Xiaomi 11 Lite - all of them had this issue reproducible.
Expected results: The result contains weak or other indication of having face recognition as a biometric possibility (when enrolled).
Actual results: The result is empty.
Code sample
void main() {
final availableBiometrics = await LocalAuthentication().getAvailableBiometrics();
BiometricType? biometricTypeForLogin;
if (availableBiometrics.isNotEmpty) {
// If device has strong use strong otherwise use weak. If null
// do not show the option.
if(availableBiometrics.contains(BiometricType.strong)) {
biometricTypeForLogin = BiometricType.strong;
} else if(availableBiometrics.contains(BiometricType.weak)) {
biometricTypeForLogin = BiometricType.weak;
}
}
}
Flutter doctor
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.22000.1219], locale en-150)
• Flutter version 2.10.5 at <path here>
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (8 months ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at <path here>
• Platform android-33, build-tools 33.0.0
• Java binary at: <path here>
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at <path here>
[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.5)
• Visual Studio at <path here>
• Visual Studio Community 2022 version 17.1.32414.318
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 2021.3)
• Android Studio at <path here>
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at <path here>
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
[√] VS Code (version 1.71.0)
• VS Code at <path here>
• Flutter extension version 3.48.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.1219]
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
• Edge (web) • edge • web-javascript • Microsoft Edge 108.0.1462.54
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Expected results: The result contains weak or other indication of having face recognition as a biometric possibility (when enrolled).
@Kerrely Check this comment and see if it helps in your case.
4. Check the result where the list of available biometrics is empty.
I think it sounds similar to https://github.com/flutter/flutter/issues/46227
Hi @darshankawar. Thank you for your response.
I know that Android from some particular API returns weak/strong definitions. However, the problem is that even though the device has face recognition enrolled, it is not returned as a part of the getAvailableBiometrics()
.
I checked the fork you mentioned but the version they used is too old and we cannot use it in our project.
Thanks for the update @Kerrely
I checked the fork you mentioned but the version they used is too old and we cannot use it in our project.
I actually just wanted to share the similar issue and not the fork mentioned in one of those comments :), because that issue describes similar issue that you pointed that getAvailableBiometrics()
returns an empty list and not the enrolled methods.
Also see if this proposal would help your case too.
Thank you for your suggestions @darshankawar
I actually just wanted to share the similar issue and not the fork mentioned in one of those comments :), because that issue describes similar issue that you pointed that getAvailableBiometrics() returns an empty list and not the enrolled methods.
I see... yeah it seems to be a similar issue to what I have reported. Unfortunately, the mentioned fork is the only conclusion in the thread and there is no activity since 21st September 2021.
Also see if https://github.com/flutter/flutter/issues/81169 proposal would help your case too.
Yup, I already checked this as well. Even though this feature would be very nice and we will probably need it in the future as well, it does not solve the problem we have there. It seems there is some bug in the plugin causing face recognition (weak) not being detected/returned from the getAvailableBiometrics()
Thanks for the feedback @Kerrely
I think its best to follow-up in https://github.com/flutter/flutter/issues/81169 since a PR is already open to implement the change which adds a strongBiometricsOnly
flag to the AuthenticationOptions on Android, to enable authenticating with strong biometrics only and also in https://github.com/flutter/flutter/issues/46227. Although it has P4
priority assigned, it'll be fixed per Flutter team's issue fixing policy that you can read here.
I will close this in favor of linked issue above which you can subscribe to for latest updates. If you disagree, write in comments and I'll reopen it.
Hi @darshankawar,
Thank you for your suggestion to follow the mentioned issue with the opened PR. However, as I mentioned earlier, it is only nice to have kind of thing for us and it does not solve the problem I have described. What I am trying to accomplish is that I would like to see enrolled face recognition (weak type) to be returned from getAvailableBiometrics()
as per its description:
https://pub.dev/documentation/local_auth/latest/local_auth/LocalAuthentication-class.html
getAvailableBiometrics() → Future<List<BiometricType>> Returns a list of enrolled biometrics.
Thanks for feedback. Reopening.
I am wondering if not detecting face in #116083 is actually this bug.
Hi!
I got this problem with Motorola Edge 20(android 12) device. The getAvailableBiometrics() method is always empty. The device has fingerprint configured.
Flutter doctor
[✓] Flutter (Channel stable, 3.7.1, on Fedora Linux 37 (KDE Plasma) 6.1.10-200.fc37.x86_64, locale pt_BR.UTF-8)
• Flutter version 3.7.1 on channel stable at /mnt/dev/develop/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7048ed95a5 (2 weeks ago), 2023-02-01 09:07:31 -0800
• Engine revision 800594f1f4
• Dart version 2.19.1
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /mnt/dev/develop/android/sdk/
• Platform android-33, build-tools 33.0.2
• ANDROID_HOME = /mnt/dev/develop/android/sdk
• ANDROID_SDK_ROOT = /mnt/dev/develop/android/sdk
• Java binary at: /mnt/dev/develop/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 15.0.7 (Fedora 15.0.7-1.fc37)
• cmake version 3.25.2
• ninja version 1.10.2
• pkg-config version 1.8.0
[✓] Android Studio (version 2021.3)
• Android Studio at /mnt/dev/develop/android-studio
• Flutter plugin version 71.0.3
• Dart plugin version 213.7433
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] Android Studio
• Android Studio at /mnt/dev/develop/android-studio/
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /mnt/dev/develop/android-studio/
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.75.1)
• VS Code at /usr/share/code
• Flutter extension version 3.40.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Fedora Linux 37 (KDE Plasma) 6.1.10-200.fc37.x86_64
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.96
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Code sample
https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth/exampleprint screen
I have a Pixel 4 that reproduces this, and I've verified that BiometricManager
is returning the wrong result, so the issue is in the library, not the plugin. I'll try testing with an alpha of 1.2 to see if it's resolved there.
Hello, I use a Redmi k60 (android 13) device, which can recognize faces. When the fingerprint is off, getAvailableBiometrics cannot detect face recognition.
Hello, I use a Redmi K60 (Android 13) device, which can recognize faces. When the fingerprint is off, getAvailableBiometrics cannot detect face recognition.
I am also facing this issue for Android devices recently, has this been fixed
Does anyone have found a fix for why getAvailableBiometrics is returning only strong and weak, BiometricType (face and fingerprint) is not returning from the list
That's not a bug, it's the intended behavior. Modern Android biometrics APIs aren't method-specific.
I am facing an issue in detecting available biometrics on samsung mobile (device model A03)I am facing an issue in detection of available biometrics. I am using samsung mobile device model A03 and this mobile device is only provides the face authentication, pin, pattern, password. Fingerprint is not supported in this mobile device.
@darshankawar I am Facing the same issue on Samsung A10s , redmi note12, samsung A03 etc on these mobile devices.
in motorola edge 30 getAvailableBiometrics() does not returns BiometricType.face and BiometricType.fingerprint, does anyone has fixed this how can i solve this?
any news on this ?
This still happens on Pixel 7 devices. Any plans to fix this?
@ioanniskouts That would be a question for the Android team; as I noted above the bug here is not in the plugin; the plugin is simply reporting the responses returned by the Andrdoid BiometricManager
.
Anyone interested in the status of this could follow/vote for https://issuetracker.google.com/issues/286675167, which describes the underlying problem. https://issuetracker.google.com/issues/143695442 may also be the same underlying issue.
@ioanniskouts That would be a question for the Android team; as I noted above the bug here is not in the plugin; the plugin is simply reporting the responses returned by the Andrdoid
BiometricManager
.Anyone interested in the status of this could follow/vote for https://b.corp.google.com/issues/286675167, which describes the underlying problem. https://b.corp.google.com/issues/143695442 may also be the same underlying issue.
@darshankawar Are those links legit ?
@UnluckyY1 Apologies, I've fixed the links. I didn't notice that they had redirected for me.
hello , started using local auth
but there are certain issues with it iam facing difficulty for the devices who supports facial recognition only in that devices local auth doesnt work as it returns enum of type supported but when checked for available biometrics it returns null
then in the device with both fingerprint and facial recognition only fingerprints works as when fingerprint is registered we get avaialable biometric list but as soon as you remove fingerpint you get null in teh list even though face is registered and you can only authorized through fingerprint
and what if the device doesnt support any thing like fingerprint or facial then can it be opened using only pin or pattern ?
this issues are only tested in android
Same problem on my phone Xiaomi 12 Android 13
local_auth: ^2.2.0
flutter doctor
[✓] Flutter (Channel stable, 3.22.0, on Ubuntu 22.04.4 LTS 5.15.0-106-generic, locale ru_RU.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.3)
[✓] Connected device (3 available)
[✓] Network resources