-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Description
local_auth plugin throws a platform exception with the message "Security credentials not available" on android 10 device that doesn't have any biometric hardware.
I faced this issue when using local_auth on a zebra device (android phone). the phone doesn't have any biometric hardware. it neither has a fingerprint scanner nor Face ID. but it has a pin set for local auth. in this case, shouldn't the local auth plugin open the pin entry screen?
I am running the example app project that is provided along with local auth android.
The check biometrics button returns false.
The get enrolled biometrics button returns an empty list.
The authenticate button throws the exception - PlatformException(NotAvailable, Security credentials not available., null, null)
I checked the source code for local_auth_android. The issue happens when control goes into this bloc
LocalAuthPlugin.java - Line 187
// API 29 and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
authHelper =
new AuthenticationHelper(
lifecycle, (FragmentActivity) activity, call, completionHandler, true);
authHelper.authenticate();
return;
}
This calls causes an error to be thrown in the completionHandler when run.
Is this block of code required? if biometric is not required then when why should authentication be tried again? can't it just fall over to invoking the keyguardManager.createConfirmDeviceCredentialIntent intent?
If it I comment the above code then it behaves correctly by invoking the deviceCredential intent and showing the pin screen.
Steps to Reproduce
- Install and run the example app of local_auth_android on a android phone without fingerprint or Face ID or any biometric and running android 10. Make sure a PIN is set on the phone.
- Click the authenticate button in the example app
- An exception gets thrown.
Expected results:
The Pin entry screen should be displayed.
Actual results:
An exception gets thrown - PlatformException(NotAvailable, Security credentials not available., null, null)
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.2 21D49 darwin-x64, locale en-SA)
• Flutter version 3.0.1 at /Users/hmdmobility/Documents/sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (11 days ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/hmdmobility/Library/Android/sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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.8+10-b944.6916264)
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.2 21D49 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!