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] Allow empty localizedReason for Android #8115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions packages/local_auth/local_auth_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.47

* Allowing empty localizedReason for Android

## 1.0.46

* Updates Java compatibility version to 11.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ interface AuthCompletionHandler {

BiometricPrompt.PromptInfo.Builder promptBuilder =
new BiometricPrompt.PromptInfo.Builder()
.setDescription(strings.getReason())
.setDescription(
strings.getReason().isEmpty()
? null
: strings.getReason())
.setTitle(strings.getSignInTitle())
.setSubtitle(strings.getBiometricHint())
.setConfirmationRequired(options.getSensitiveTransaction());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LocalAuthAndroid extends LocalAuthPlatform {
required Iterable<AuthMessages> authMessages,
AuthenticationOptions options = const AuthenticationOptions(),
}) async {
assert(localizedReason.isNotEmpty);
/// no empty check assertion because [localizedReason] can be empty for android
final AuthResult result = await _api.authenticate(
AuthOptions(
biometricOnly: options.biometricOnly,
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/local_auth_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_android
description: Android implementation of the local_auth plugin.
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.0.46
version: 1.0.47

environment:
sdk: ^3.5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ void main() {

group('authenticate', () {
group('strings', () {
test('With empty reason', () async {
when(api.authenticate(any, any))
.thenAnswer((_) async => AuthResult.success);

const String reason = '';
final bool result = await plugin.authenticate(
localizedReason: reason, authMessages: <AuthMessages>[]);

expect(result, true);
});
test('passes default values when nothing is provided', () async {
when(api.authenticate(any, any))
.thenAnswer((_) async => AuthResult.success);
Expand Down