Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[local_auth_darwin] Handle when FaceID hardware is available but permissions have been denied for the app #8348

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/local_auth/local_auth_darwin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.4.3

* Handles when biometry hardware is available but permissions have been denied for the app.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 1.4.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class FLALocalAuthPluginTests: XCTestCase {
XCTAssertNil(error)
}

func testDeviceSupportsBiometrics_withNoBiometricHardware() {
func testDeviceSupportsBiometrics_withBiometryNotAvailable() {
let stubAuthContext = StubAuthContext()
let alertFactory = StubAlertFactory()
let viewProvider = StubViewProvider()
Expand All @@ -456,14 +456,34 @@ class FLALocalAuthPluginTests: XCTestCase {
alertFactory: alertFactory, viewProvider: viewProvider)

stubAuthContext.expectBiometrics = true
stubAuthContext.canEvaluateError = NSError(domain: "error", code: 0)
stubAuthContext.canEvaluateError = NSError(
domain: "error", code: LAError.biometryNotAvailable.rawValue)

var error: FlutterError?
let result = plugin.deviceCanSupportBiometricsWithError(&error)
XCTAssertFalse(result!.boolValue)
XCTAssertNil(error)
}

func testDeviceSupportsBiometrics_withBiometryNotAvailableLoadedBiometryType() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not super clear to me what "loadedBiometryType" means in this context
maybe testDeviceSupportsBiometrics_withBiometryNotAvailableWhenPermissionsDenied?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this comment somehow.
#8499

let stubAuthContext = StubAuthContext()
let alertFactory = StubAlertFactory()
let viewProvider = StubViewProvider()
let plugin = FLALocalAuthPlugin(
contextFactory: StubAuthContextFactory(contexts: [stubAuthContext]),
alertFactory: alertFactory, viewProvider: viewProvider)

stubAuthContext.expectBiometrics = true
stubAuthContext.biometryType = LABiometryType.touchID
stubAuthContext.canEvaluateError = NSError(
domain: "error", code: LAError.biometryNotAvailable.rawValue)

var error: FlutterError?
let result = plugin.deviceCanSupportBiometricsWithError(&error)
XCTAssertTrue(result!.boolValue)
XCTAssertNil(error)
}

func testGetEnrolledBiometricsWithFaceID() {
let stubAuthContext = StubAuthContext()
let alertFactory = StubAlertFactory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ - (nullable NSNumber *)deviceCanSupportBiometricsWithError:
if (authError.code == LAErrorBiometryNotEnrolled) {
return @YES;
}
// Biometry hardware is available, but possibly permissions were denied.
if (authError.code == LAErrorBiometryNotAvailable &&
context.biometryType != LABiometryTypeNone) {
return @YES;
}
}

return @NO;
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/local_auth_darwin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_darwin
description: iOS implementation of the local_auth plugin.
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_darwin
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.4.2
version: 1.4.3

environment:
sdk: ^3.4.0
Expand Down
Loading