Skip to content

Commit

Permalink
[local_auth] Convert Android to Pigeon (flutter#3748)
Browse files Browse the repository at this point in the history
Updates the platform communication to use Pigeon. This includes some changes to the API boundary:
- Collected authentication options into an options object; this avoids having a lot of positional boolean arguments (since Pigeon doesn't currently support named arguments).
- Collected strings into a strings object, since having them as individual parameters would have been extremely messy.
- Changes the `authenticate` return from a bool+exceptions to an enum that encompasses all of the explicitly known failure modes. To avoid a breaking change for clients, the Dart code creates `PlatformException`s that match the old ones, but this will make it much easier to someday make a (cross-platform) breaking change to replace them with better errors per the best practices we have documented on the wiki. Using an enum rather than throwing errors avoids the need to do string matching when we want to eventually translate them into something other than `PlatformException`.

This removes all Java warnings from the baseline file; the remaining issues in code I wasn't already changing were easy enough to fix opportunistically. There are still XML-based warnings, but fixing those was well out of scope so I left them.

Part of flutter/flutter#117912
  • Loading branch information
stuartmorgan authored and nploi committed Jul 16, 2023
1 parent 4a24af2 commit 9d7db6f
Show file tree
Hide file tree
Showing 16 changed files with 2,051 additions and 861 deletions.
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.23

* Switches internals to Pigeon and fixes Java warnings.

## 1.0.22

* Sets an explicit Java compatibility version.
Expand Down
319 changes: 0 additions & 319 deletions packages/local_auth/local_auth_android/android/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (7.3.1)" variant="all" version="7.3.1">

<issue
id="NewApi"
message="`@android:style/Theme.Material.Dialog.Alert` requires API level 21 (current min is 16)"
errorLine1=" &lt;style name=&quot;AlertDialogCustom&quot; parent=&quot;@android:style/Theme.Material.Dialog.Alert&quot;>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/styles.xml"
line="3"
column="35"/>
</issue>

<issue
id="NewApi"
message="`android:colorAccent` requires API level 21 (current min is 16)"
errorLine1=" &lt;item name=&quot;android:colorAccent&quot;>#FF009688&lt;/item>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/styles.xml"
line="7"
column="11"/>
</issue>

<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the `android.os.Build.VERSION_CODES` javadoc for details."
errorLine1=" &lt;uses-sdk android:targetSdkVersion=&quot;29&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="3"
column="15"/>
</issue>

<issue
id="GradleOverrides"
message="This `targetSdkVersion` value (`29`) is not used; it is always overridden by the value specified in the Gradle build script (`16`)"
errorLine1=" &lt;uses-sdk android:targetSdkVersion=&quot;29&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="3"
column="15"/>
</issue>

<issue
id="UseCompoundDrawables"
message="This tag and its children can be replaced by one `&lt;TextView/>` and a compound drawable"
Expand Down Expand Up @@ -177,171 +133,6 @@
column="1"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` member of class `UiThreadExecutor` requires synthetic accessor"
errorLine1=" this.uiThreadExecutor = new UiThreadExecutor();"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="84"
column="29"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `promptInfo` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" prompt.authenticate(promptInfo);"
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="219"
column="35"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `completionHandler` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" completionHandler.onFailure();"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="248"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `stop` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" stop();"
errorLine2=" ~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="249"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `activity` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" activity.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="250"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `completionHandler` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" completionHandler.onFailure();"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="257"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `stop` of class `AuthenticationHelper` requires synthetic accessor"
errorLine1=" stop();"
errorLine2=" ~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java"
line="258"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `lockRequestResult` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" if (resultCode == RESULT_OK &amp;&amp; lockRequestResult != null) {"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="58"
column="44"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `lockRequestResult` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateSuccess(lockRequestResult);"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="59"
column="35"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `authenticateSuccess` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateSuccess(lockRequestResult);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="59"
column="15"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `lockRequestResult` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateFail(lockRequestResult);"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="61"
column="32"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `authenticateFail` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateFail(lockRequestResult);"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="61"
column="15"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` field `lockRequestResult` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" lockRequestResult = null;"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="63"
column="13"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `authenticateSuccess` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateSuccess(result);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="162"
column="9"/>
</issue>

<issue
id="SyntheticAccessor"
message="Access to `private` method `authenticateFail` of class `LocalAuthPlugin` requires synthetic accessor"
errorLine1=" authenticateFail(result);"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="167"
column="9"/>
</issue>

<issue
id="UnusedIds"
message="The resource `R.id.fingerprint_signin` appears to be unused"
Expand Down Expand Up @@ -452,114 +243,4 @@
column="6"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public static void registerWith(PluginRegistry.Registrar registrar) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="80"
column="35"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public void onMethodCall(MethodCall call, @NonNull final Result result) {"
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="96"
column="28"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public AuthCompletionHandler createAuthCompletionHandler(final Result result) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="158"
column="10"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public AuthCompletionHandler createAuthCompletionHandler(final Result result) {"
errorLine2=" ~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="158"
column="66"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" MethodCall call, AuthCompletionHandler completionHandler, boolean allowCredentials) {"
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="181"
column="7"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" MethodCall call, AuthCompletionHandler completionHandler, boolean allowCredentials) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="181"
column="24"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public ArrayList&lt;String> getEnrolledBiometrics() {"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="238"
column="10"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public void onAttachedToEngine(FlutterPluginBinding binding) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="296"
column="34"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public void onAttachedToActivity(ActivityPluginBinding binding) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="313"
column="36"/>
</issue>

<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations"
errorLine1=" public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java"
line="327"
column="54"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.localauth">
<uses-sdk android:targetSdkVersion="29"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
</manifest>
Loading

0 comments on commit 9d7db6f

Please sign in to comment.