From 200e3c6cb35111479870397b131d5341676446e7 Mon Sep 17 00:00:00 2001 From: Tarrin Neal Date: Wed, 30 Aug 2023 10:18:13 -0700 Subject: [PATCH] [local_auth] Update to pigeon 11 and remove enum wrappers (#4809) updates pigeon version to 11 to remove need for enum wrappers - removes enum wrappers. Some work toward https://github.com/flutter/flutter/issues/133455 --- .../local_auth_android/CHANGELOG.md | 4 + .../plugins/localauth/LocalAuthPlugin.java | 23 ++--- .../flutter/plugins/localauth/Messages.java | 86 ++++--------------- .../plugins/localauth/LocalAuthTest.java | 31 ++++--- .../lib/local_auth_android.dart | 15 ++-- .../lib/src/messages.g.dart | 49 +++-------- .../local_auth_android/pigeons/messages.dart | 9 +- .../local_auth_android/pubspec.yaml | 4 +- .../test/local_auth_test.dart | 62 ++++++------- .../test/local_auth_test.mocks.dart | 31 ++----- 10 files changed, 108 insertions(+), 206 deletions(-) diff --git a/packages/local_auth/local_auth_android/CHANGELOG.md b/packages/local_auth/local_auth_android/CHANGELOG.md index 2e54f712e72a..9c62c872ca8a 100644 --- a/packages/local_auth/local_auth_android/CHANGELOG.md +++ b/packages/local_auth/local_auth_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.34 + +* Updates pigeon to 11.0.0 and removes enum wrappers. + ## 1.0.33 * Adds pub topics to package metadata. diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java index ef492f5445cc..7ed2c04a8f6a 100644 --- a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -27,7 +27,6 @@ import io.flutter.plugins.localauth.Messages.AuthClassificationWrapper; import io.flutter.plugins.localauth.Messages.AuthOptions; import io.flutter.plugins.localauth.Messages.AuthResult; -import io.flutter.plugins.localauth.Messages.AuthResultWrapper; import io.flutter.plugins.localauth.Messages.AuthStrings; import io.flutter.plugins.localauth.Messages.LocalAuthApi; import io.flutter.plugins.localauth.Messages.Result; @@ -51,7 +50,7 @@ public class LocalAuthPlugin implements FlutterPlugin, ActivityAware, LocalAuthA private Lifecycle lifecycle; private BiometricManager biometricManager; private KeyguardManager keyguardManager; - Result lockRequestResult; + Result lockRequestResult; private final PluginRegistry.ActivityResultListener resultListener = new PluginRegistry.ActivityResultListener() { @Override @@ -132,28 +131,24 @@ public LocalAuthPlugin() {} public void authenticate( @NonNull AuthOptions options, @NonNull AuthStrings strings, - @NonNull Result result) { + @NonNull Result result) { if (authInProgress.get()) { - result.success( - new AuthResultWrapper.Builder().setValue(AuthResult.ERROR_ALREADY_IN_PROGRESS).build()); + result.success(AuthResult.ERROR_ALREADY_IN_PROGRESS); return; } if (activity == null || activity.isFinishing()) { - result.success( - new AuthResultWrapper.Builder().setValue(AuthResult.ERROR_NO_ACTIVITY).build()); + result.success(AuthResult.ERROR_NO_ACTIVITY); return; } if (!(activity instanceof FragmentActivity)) { - result.success( - new AuthResultWrapper.Builder().setValue(AuthResult.ERROR_NOT_FRAGMENT_ACTIVITY).build()); + result.success(AuthResult.ERROR_NOT_FRAGMENT_ACTIVITY); return; } if (!isDeviceSupported()) { - result.success( - new AuthResultWrapper.Builder().setValue(AuthResult.ERROR_NOT_AVAILABLE).build()); + result.success(AuthResult.ERROR_NOT_AVAILABLE); return; } @@ -167,7 +162,7 @@ public void authenticate( @VisibleForTesting public @NonNull AuthCompletionHandler createAuthCompletionHandler( - @NonNull final Result result) { + @NonNull final Result result) { return authResult -> onAuthenticationCompleted(result, authResult); } @@ -189,9 +184,9 @@ public void sendAuthenticationRequest( authHelper.authenticate(); } - void onAuthenticationCompleted(Result result, AuthResult value) { + void onAuthenticationCompleted(Result result, AuthResult value) { if (authInProgress.compareAndSet(true, false)) { - result.success(new AuthResultWrapper.Builder().setValue(value).build()); + result.success(value); } } diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/Messages.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/Messages.java index 8b5bc41e750d..e878c481c273 100644 --- a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/Messages.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/Messages.java @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v9.2.4), do not edit directly. +// Autogenerated from Pigeon (v11.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.localauth; @@ -489,55 +489,6 @@ ArrayList toList() { } } - /** Generated class from Pigeon that represents data sent in messages. */ - public static final class AuthResultWrapper { - private @NonNull AuthResult value; - - public @NonNull AuthResult getValue() { - return value; - } - - public void setValue(@NonNull AuthResult setterArg) { - if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"value\" is null."); - } - this.value = setterArg; - } - - /** Constructor is non-public to enforce null safety; use Builder. */ - AuthResultWrapper() {} - - public static final class Builder { - - private @Nullable AuthResult value; - - public @NonNull Builder setValue(@NonNull AuthResult setterArg) { - this.value = setterArg; - return this; - } - - public @NonNull AuthResultWrapper build() { - AuthResultWrapper pigeonReturn = new AuthResultWrapper(); - pigeonReturn.setValue(value); - return pigeonReturn; - } - } - - @NonNull - ArrayList toList() { - ArrayList toListResult = new ArrayList(1); - toListResult.add(value == null ? null : value.index); - return toListResult; - } - - static @NonNull AuthResultWrapper fromList(@NonNull ArrayList list) { - AuthResultWrapper pigeonResult = new AuthResultWrapper(); - Object value = list.get(0); - pigeonResult.setValue(value == null ? null : AuthResult.values()[(int) value]); - return pigeonResult; - } - } - /** Generated class from Pigeon that represents data sent in messages. */ public static final class AuthClassificationWrapper { private @NonNull AuthClassification value; @@ -582,7 +533,7 @@ ArrayList toList() { static @NonNull AuthClassificationWrapper fromList(@NonNull ArrayList list) { AuthClassificationWrapper pigeonResult = new AuthClassificationWrapper(); Object value = list.get(0); - pigeonResult.setValue(value == null ? null : AuthClassification.values()[(int) value]); + pigeonResult.setValue(AuthClassification.values()[(int) value]); return pigeonResult; } } @@ -607,8 +558,6 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 129: return AuthOptions.fromList((ArrayList) readValue(buffer)); case (byte) 130: - return AuthResultWrapper.fromList((ArrayList) readValue(buffer)); - case (byte) 131: return AuthStrings.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -623,11 +572,8 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof AuthOptions) { stream.write(129); writeValue(stream, ((AuthOptions) value).toList()); - } else if (value instanceof AuthResultWrapper) { - stream.write(130); - writeValue(stream, ((AuthResultWrapper) value).toList()); } else if (value instanceof AuthStrings) { - stream.write(131); + stream.write(130); writeValue(stream, ((AuthStrings) value).toList()); } else { super.writeValue(stream, value); @@ -665,7 +611,7 @@ public interface LocalAuthApi { void authenticate( @NonNull AuthOptions options, @NonNull AuthStrings strings, - @NonNull Result result); + @NonNull Result result); /** The codec used by LocalAuthApi. */ static @NonNull MessageCodec getCodec() { @@ -676,7 +622,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.LocalAuthApi.isDeviceSupported", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.local_auth_android.LocalAuthApi.isDeviceSupported", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -698,7 +646,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, - "dev.flutter.pigeon.LocalAuthApi.deviceCanSupportBiometrics", + "dev.flutter.pigeon.local_auth_android.LocalAuthApi.deviceCanSupportBiometrics", getCodec()); if (api != null) { channel.setMessageHandler( @@ -720,7 +668,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.LocalAuthApi.stopAuthentication", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.local_auth_android.LocalAuthApi.stopAuthentication", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -742,7 +692,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, - "dev.flutter.pigeon.LocalAuthApi.getEnrolledBiometrics", + "dev.flutter.pigeon.local_auth_android.LocalAuthApi.getEnrolledBiometrics", getCodec()); if (api != null) { channel.setMessageHandler( @@ -764,7 +714,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.LocalAuthApi.authenticate", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.local_auth_android.LocalAuthApi.authenticate", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -772,10 +724,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocalAuthA ArrayList args = (ArrayList) message; AuthOptions optionsArg = (AuthOptions) args.get(0); AuthStrings stringsArg = (AuthStrings) args.get(1); - Result resultCallback = - new Result() { - public void success(AuthResultWrapper result) { - wrapped.add(0, result); + Result resultCallback = + new Result() { + public void success(AuthResult result) { + wrapped.add(0, result.index); reply.reply(wrapped); } diff --git a/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java index 62b03f900597..5e7c14d68b20 100644 --- a/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java +++ b/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java @@ -33,7 +33,6 @@ import io.flutter.plugins.localauth.Messages.AuthClassificationWrapper; import io.flutter.plugins.localauth.Messages.AuthOptions; import io.flutter.plugins.localauth.Messages.AuthResult; -import io.flutter.plugins.localauth.Messages.AuthResultWrapper; import io.flutter.plugins.localauth.Messages.AuthStrings; import io.flutter.plugins.localauth.Messages.Result; import java.util.List; @@ -72,23 +71,23 @@ public void authenticate_returnsErrorWhenAuthInProgress() { final LocalAuthPlugin plugin = new LocalAuthPlugin(); plugin.authInProgress.set(true); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResultWrapper.class); + ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResult.class); verify(mockResult).success(captor.capture()); - assertEquals(AuthResult.ERROR_ALREADY_IN_PROGRESS, captor.getValue().getValue()); + assertEquals(AuthResult.ERROR_ALREADY_IN_PROGRESS, captor.getValue()); } @Test public void authenticate_returnsErrorWithNoForegroundActivity() { final LocalAuthPlugin plugin = new LocalAuthPlugin(); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResultWrapper.class); + ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResult.class); verify(mockResult).success(captor.capture()); - assertEquals(AuthResult.ERROR_NO_ACTIVITY, captor.getValue().getValue()); + assertEquals(AuthResult.ERROR_NO_ACTIVITY, captor.getValue()); } @Test @@ -96,11 +95,11 @@ public void authenticate_returnsErrorWhenActivityNotFragmentActivity() { final LocalAuthPlugin plugin = new LocalAuthPlugin(); setPluginActivity(plugin, buildMockActivityWithContext(mock(NativeActivity.class))); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResultWrapper.class); + ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResult.class); verify(mockResult).success(captor.capture()); - assertEquals(AuthResult.ERROR_NOT_FRAGMENT_ACTIVITY, captor.getValue().getValue()); + assertEquals(AuthResult.ERROR_NOT_FRAGMENT_ACTIVITY, captor.getValue()); } @Test @@ -108,12 +107,12 @@ public void authenticate_returnsErrorWhenDeviceNotSupported() { final LocalAuthPlugin plugin = new LocalAuthPlugin(); setPluginActivity(plugin, buildMockActivityWithContext(mock(FragmentActivity.class))); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); - ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResultWrapper.class); + ArgumentCaptor captor = ArgumentCaptor.forClass(AuthResult.class); verify(mockResult).success(captor.capture()); - assertEquals(AuthResult.ERROR_NOT_AVAILABLE, captor.getValue().getValue()); + assertEquals(AuthResult.ERROR_NOT_AVAILABLE, captor.getValue()); } @Test @@ -138,7 +137,7 @@ public void authenticate_properlyConfiguresBiometricOnlyAuthenticationRequest() allowCredentialsCaptor.capture(), any(AuthCompletionHandler.class)); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); final AuthOptions options = new AuthOptions.Builder() @@ -172,7 +171,7 @@ public void authenticate_properlyConfiguresBiometricAndDeviceCredentialAuthentic allowCredentialsCaptor.capture(), any(AuthCompletionHandler.class)); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); assertTrue(allowCredentialsCaptor.getValue()); @@ -201,7 +200,7 @@ public void authenticate_properlyConfiguresDeviceCredentialOnlyAuthenticationReq allowCredentialsCaptor.capture(), any(AuthCompletionHandler.class)); @SuppressWarnings("unchecked") - final Result mockResult = mock(Result.class); + final Result mockResult = mock(Result.class); plugin.authenticate(defaultOptions, dummyStrings, mockResult); assertTrue(allowCredentialsCaptor.getValue()); diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index 145c4681f013..338bba235b23 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -35,14 +35,13 @@ class LocalAuthAndroid extends LocalAuthPlatform { AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); - final AuthResult result = (await _api.authenticate( - AuthOptions( - biometricOnly: options.biometricOnly, - sensitiveTransaction: options.sensitiveTransaction, - sticky: options.stickyAuth, - useErrorDialgs: options.useErrorDialogs), - _pigeonStringsFromAuthMessages(localizedReason, authMessages))) - .value; + final AuthResult result = await _api.authenticate( + AuthOptions( + biometricOnly: options.biometricOnly, + sensitiveTransaction: options.sensitiveTransaction, + sticky: options.stickyAuth, + useErrorDialgs: options.useErrorDialogs), + _pigeonStringsFromAuthMessages(localizedReason, authMessages)); // TODO(stuartmorgan): Replace this with structured errors, coordinated // across all platform implementations, per // https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#platform-exception-handling diff --git a/packages/local_auth/local_auth_android/lib/src/messages.g.dart b/packages/local_auth/local_auth_android/lib/src/messages.g.dart index 3dead4f69fc2..77f5215596b7 100644 --- a/packages/local_auth/local_auth_android/lib/src/messages.g.dart +++ b/packages/local_auth/local_auth_android/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v9.2.4), do not edit directly. +// Autogenerated from Pigeon (v11.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import @@ -153,27 +153,6 @@ class AuthOptions { } } -class AuthResultWrapper { - AuthResultWrapper({ - required this.value, - }); - - AuthResult value; - - Object encode() { - return [ - value.index, - ]; - } - - static AuthResultWrapper decode(Object result) { - result as List; - return AuthResultWrapper( - value: AuthResult.values[result[0]! as int], - ); - } -} - class AuthClassificationWrapper { AuthClassificationWrapper({ required this.value, @@ -205,11 +184,8 @@ class _LocalAuthApiCodec extends StandardMessageCodec { } else if (value is AuthOptions) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is AuthResultWrapper) { - buffer.putUint8(130); - writeValue(buffer, value.encode()); } else if (value is AuthStrings) { - buffer.putUint8(131); + buffer.putUint8(130); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -224,8 +200,6 @@ class _LocalAuthApiCodec extends StandardMessageCodec { case 129: return AuthOptions.decode(readValue(buffer)!); case 130: - return AuthResultWrapper.decode(readValue(buffer)!); - case 131: return AuthStrings.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -246,7 +220,8 @@ class LocalAuthApi { /// Returns true if this device supports authentication. Future isDeviceSupported() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.LocalAuthApi.isDeviceSupported', codec, + 'dev.flutter.pigeon.local_auth_android.LocalAuthApi.isDeviceSupported', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; if (replyList == null) { @@ -274,7 +249,8 @@ class LocalAuthApi { /// any biometrics are enrolled or not. Future deviceCanSupportBiometrics() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.LocalAuthApi.deviceCanSupportBiometrics', codec, + 'dev.flutter.pigeon.local_auth_android.LocalAuthApi.deviceCanSupportBiometrics', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; if (replyList == null) { @@ -304,7 +280,8 @@ class LocalAuthApi { /// cancelled. Future stopAuthentication() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.LocalAuthApi.stopAuthentication', codec, + 'dev.flutter.pigeon.local_auth_android.LocalAuthApi.stopAuthentication', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; if (replyList == null) { @@ -332,7 +309,8 @@ class LocalAuthApi { /// without additional setup. Future> getEnrolledBiometrics() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.LocalAuthApi.getEnrolledBiometrics', codec, + 'dev.flutter.pigeon.local_auth_android.LocalAuthApi.getEnrolledBiometrics', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; if (replyList == null) { @@ -359,10 +337,11 @@ class LocalAuthApi { /// Attempts to authenticate the user with the provided [options], and using /// [strings] for any UI. - Future authenticate( + Future authenticate( AuthOptions arg_options, AuthStrings arg_strings) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.LocalAuthApi.authenticate', codec, + 'dev.flutter.pigeon.local_auth_android.LocalAuthApi.authenticate', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_options, arg_strings]) as List?; @@ -383,7 +362,7 @@ class LocalAuthApi { message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as AuthResultWrapper?)!; + return AuthResult.values[replyList[0]! as int]; } } } diff --git a/packages/local_auth/local_auth_android/pigeons/messages.dart b/packages/local_auth/local_auth_android/pigeons/messages.dart index 69d0157a34be..622c1657cd6a 100644 --- a/packages/local_auth/local_auth_android/pigeons/messages.dart +++ b/packages/local_auth/local_auth_android/pigeons/messages.dart @@ -84,13 +84,6 @@ class AuthOptions { final bool useErrorDialgs; } -// TODO(stuartmorgan): Remove this when -// https://github.com/flutter/flutter/issues/87307 is implemented. -class AuthResultWrapper { - AuthResultWrapper({required this.value}); - final AuthResult value; -} - /// Pigeon equivalent of the subset of BiometricType used by Android. enum AuthClassification { weak, strong } @@ -123,5 +116,5 @@ abstract class LocalAuthApi { /// Attempts to authenticate the user with the provided [options], and using /// [strings] for any UI. @async - AuthResultWrapper authenticate(AuthOptions options, AuthStrings strings); + AuthResult authenticate(AuthOptions options, AuthStrings strings); } diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index d880828d98ac..a11ad40194bf 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -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.33 +version: 1.0.34 environment: sdk: ">=3.0.0 <4.0.0" @@ -29,7 +29,7 @@ dev_dependencies: flutter_test: sdk: flutter mockito: 5.4.1 - pigeon: ^9.2.4 + pigeon: ^11.0.0 topics: - authentication diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart index 4e416fb72bc2..d37898105a4b 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -79,7 +79,7 @@ void main() { ]); }); - test('handles emtpy', () async { + test('handles empty', () async { when(api.getEnrolledBiometrics()) .thenAnswer((_) async => []); @@ -92,8 +92,8 @@ void main() { group('authenticate', () { group('strings', () { test('passes default values when nothing is provided', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); const String reason = 'test reason'; await plugin.authenticate( @@ -120,8 +120,8 @@ void main() { test('passes default values when only other platform values are provided', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); const String reason = 'test reason'; await plugin.authenticate( @@ -148,8 +148,8 @@ void main() { }); test('passes all non-default values correctly', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); // These are arbitrary values; all that matters is that: // - they are different from the defaults, and @@ -196,8 +196,8 @@ void main() { }); test('passes provided messages with default fallbacks', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); // These are arbitrary values; all that matters is that: // - they are different from the defaults, and @@ -240,8 +240,8 @@ void main() { group('options', () { test('passes default values', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); await plugin.authenticate( localizedReason: 'reason', authMessages: []); @@ -256,8 +256,8 @@ void main() { }); test('passes provided non-default values', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); await plugin.authenticate( localizedReason: 'reason', @@ -281,8 +281,8 @@ void main() { group('return values', () { test('handles success', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.success)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.success); final bool result = await plugin.authenticate( localizedReason: 'reason', authMessages: []); @@ -291,8 +291,8 @@ void main() { }); test('handles failure', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.failure)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.failure); final bool result = await plugin.authenticate( localizedReason: 'reason', authMessages: []); @@ -302,8 +302,8 @@ void main() { test('converts errorAlreadyInProgress to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer((_) async => - AuthResultWrapper(value: AuthResult.errorAlreadyInProgress)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorAlreadyInProgress); expect( () async => plugin.authenticate( @@ -316,8 +316,8 @@ void main() { }); test('converts errorNoActivity to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.errorNoActivity)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorNoActivity); expect( () async => plugin.authenticate( @@ -330,8 +330,8 @@ void main() { test('converts errorNotFragmentActivity to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer((_) async => - AuthResultWrapper(value: AuthResult.errorNotFragmentActivity)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorNotFragmentActivity); expect( () async => plugin.authenticate( @@ -344,8 +344,8 @@ void main() { }); test('converts errorNotAvailable to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer((_) async => - AuthResultWrapper(value: AuthResult.errorNotAvailable)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorNotAvailable); expect( () async => plugin.authenticate( @@ -357,8 +357,8 @@ void main() { }); test('converts errorNotEnrolled to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer( - (_) async => AuthResultWrapper(value: AuthResult.errorNotEnrolled)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorNotEnrolled); expect( () async => plugin.authenticate( @@ -371,8 +371,8 @@ void main() { test('converts errorLockedOutTemporarily to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer((_) async => - AuthResultWrapper(value: AuthResult.errorLockedOutTemporarily)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorLockedOutTemporarily); expect( () async => plugin.authenticate( @@ -389,8 +389,8 @@ void main() { test('converts errorLockedOutPermanently to legacy PlatformException', () async { - when(api.authenticate(any, any)).thenAnswer((_) async => - AuthResultWrapper(value: AuthResult.errorLockedOutPermanently)); + when(api.authenticate(any, any)) + .thenAnswer((_) async => AuthResult.errorLockedOutPermanently); expect( () async => plugin.authenticate( diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.mocks.dart b/packages/local_auth/local_auth_android/test/local_auth_test.mocks.dart index 7a4325ef6431..7ae4fe383aa7 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.mocks.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.mocks.dart @@ -1,7 +1,9 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.1 from annotations // in local_auth_android/test/local_auth_test.dart. // Do not manually edit this file. +// @dart=2.19 + // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i3; @@ -19,17 +21,6 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeAuthResultWrapper_0 extends _i1.SmartFake - implements _i2.AuthResultWrapper { - _FakeAuthResultWrapper_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [LocalAuthApi]. /// /// See the documentation for Mockito's code generation for more information. @@ -73,7 +64,7 @@ class MockLocalAuthApi extends _i1.Mock implements _i2.LocalAuthApi { <_i2.AuthClassificationWrapper?>[]), ) as _i3.Future>); @override - _i3.Future<_i2.AuthResultWrapper> authenticate( + _i3.Future<_i2.AuthResult> authenticate( _i2.AuthOptions? arg_options, _i2.AuthStrings? arg_strings, ) => @@ -85,16 +76,6 @@ class MockLocalAuthApi extends _i1.Mock implements _i2.LocalAuthApi { arg_strings, ], ), - returnValue: - _i3.Future<_i2.AuthResultWrapper>.value(_FakeAuthResultWrapper_0( - this, - Invocation.method( - #authenticate, - [ - arg_options, - arg_strings, - ], - ), - )), - ) as _i3.Future<_i2.AuthResultWrapper>); + returnValue: _i3.Future<_i2.AuthResult>.value(_i2.AuthResult.success), + ) as _i3.Future<_i2.AuthResult>); }