8000 [local_auth] Add native Android implementation of platform interface by BeMacized · Pull Request #4700 · flutter/plugins · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[local_auth] Add native Android implementation of platform interface #4700

Merged
merged 52 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
94c4904
Add platform interface for local_auth plugin to prepare for federated…
BeMacized Jan 26, 2022
414d74b
Fix format
BeMacized Jan 26, 2022
c35fd92
Fix analysis issues
BeMacized Jan 26, 2022
2c6a9a9
Fix format
BeMacized Jan 26, 2022
bd35a9f
Move local_auth plugin into a subfolder in preparation for federation…
BeMacized Jan 27, 2022
e10bbb8
Process PR Feedback
BeMacized Jan 27, 2022
86f7ac5
Merge branch 'local_auth/federation_initial_move' into local_auth/fed…
BeMacized Jan 27, 2022
164abaa
Merge remote-tracking branch 'upstream/master' into local_auth/federa…
BeMacized Jan 27, 2022
c3d5a1b
Fix typo in file name
BeMacized Jan 27, 2022
f7d2d85
Merge remote-tracking branch 'upstream/master' into local_auth/federa…
BeMacized Jan 27, 2022
cdf2cfe
Add Android implementation of platform interface
BeMacized Jan 27, 2022
af311cc
Adjust to changes in platform interface
BeMacized Jan 27, 2022
4266130
Added missing implements field in pubspec
BeMacized Jan 27, 2022
24765b2
Update doc in default method channel platform
BeMacized Jan 31, 2022
81ba7e8
Implement PR feedback
BeMacized Jan 31, 2022
7de1528
Merge branch 'local_auth/federation_interface' into local_auth/federa…
BeMacized Feb 7, 2022
a371a87
Move string to Android package
BeMacized Feb 7, 2022
c4086e8
Remove auth strings from platform interface
BeMacized Feb 7, 2022
c7a662f
Merge branch 'local_auth/federation_interface' into local_auth/federa…
BeMacized Feb 7, 2022
c0a867e
Change interface for handing platform specific messages
BeMacized Feb 7, 2022
af77551
Merge branch 'local_auth/federation_interface' into local_auth/federa…
BeMacized Feb 7, 2022
939d3b3
Implement platform interface changes
BeMacized Feb 7, 2022
61bd127
Add equality for AndroidAuthMessages
BeMacized Feb 7, 2022
083689f
Add equality for AuthenticationOptions
BeMacized Feb 7, 2022
eaa9e69
Merge branch 'local_auth/federation_interface' into local_auth/federa…
BeMacized Feb 7, 2022
ae34800
Format
BeMacized Feb 7, 2022
3b1915b
Add current implementation for canCheckBiometrics
BeMacized Feb 7, 2022
92ec8bc
Process PR feedback
BeMacized Feb 11, 2022
afd11f3
Merge branch 'local_auth/federation_interface' into local_auth/federa…
BeMacized Feb 11, 2022
2652857
Adjust to platform interface changes
BeMacized Feb 11, 2022
6d205e5
Adjust to platform interface changes
BeMacized Feb 11, 2022
b499c48
Merge branch 'master' into local_auth/federation_android
BeMacized Feb 14, 2022
116c795
Update platform interface dependency
BeMacized Feb 14, 2022
7c97e48
Fixed order of keys in pubspec
BeMacized Feb 14, 2022
6a49858
Merge branch 'main' into local_auth/federation_android
BeMacized Mar 10, 2022
222253f
Implement PR feedback (from iOS PR)
BeMacized Mar 10, 2022
42f41f4
Partially process PR feedback
BeMacized Mar 28, 2022
7d93686
Only add authentication messages for the current platform
BeMacized Mar 28, 2022
ce6bb97
Update min flutter version
BeMacized Apr 7, 2022
bc24cf5
Switch over app facing package to use default method channel implemen…
BeMacized Apr 7, 2022
d8e3942
Remove accidental deprecation
BeMacized Apr 7, 2022
57cb84c
Export externally used types from local_auth_platform_interface.dart …
BeMacized Apr 7, 2022
1d63701
Merge branch 'local_auth/federation_interface_export' into local_auth…
BeMacized Apr 7, 2022
78214fe
Add missing license header
BeMacized Apr 7, 2022
82a9bb6
Merge branch 'local_auth/federation_interface_export' into local_auth…
BeMacized Apr 7, 2022
d0fd4c1
Update imports of types from platform interface package.
BeMacized Apr 7, 2022
f54719a
Update dependency on platform interface package
BeMacized Apr 8, 2022
3d0f154
Merge branch 'master' into local_auth/federation_native_precursor
BeMacized Apr 8, 2022
c77dc21
Fix analysis issues
BeMacized Apr 8, 2022
12bbc08
Merge branch 'local_auth/federation_native_precursor' into local_auth…
BeMacized Apr 8, 2022
3634b2b
Merge branch 'main' into local_auth/federation_android
BeMacized Apr 11, 2022
54eadc5
Merge branch 'main' into local_auth/federation_android
BeMacized Apr 11, 2022
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
7 changes: 4 additions & 3 deletions packages/local_auth/local_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ flutter:
plugin:
platforms:
android:
package: io.flutter.plugins.localauth
pluginClass: LocalAuthPlugin
default_package: local_auth_android
ios:
default_package: local_auth_ios

Expand All @@ -27,7 +26,9 @@ dependencies:
sdk: flutter
flutter_plugin_android_lifecycle: ^2.0.1
intl: ^0.17.0
# Temporary path dependencies to allow moving Android and iOS implementations.
# Temporary path dependencies to allow moving Android and iOS implementations.
local_auth_android:
path: ../local_auth_android
local_auth_ios:
path: ../local_auth_ios
local_auth_platform_interface: ^1.0.1
Expand Down
67 changes: 67 additions & 0 deletions packages/local_auth/local_auth_android/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Below is a list of people and organizations that have contributed
# to the Flutter project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
The Chromium Authors
German Saprykin <saprykin.h@gmail.com>
Benjamin Sauer <sauer.benjamin@gmail.com>
larsenthomasj@gmail.com
Ali Bitek <alibitek@protonmail.ch>
Pol Batlló <pol.batllo@gmail.com>
Anatoly Pulyaevskiy
Hayden Flinner <haydenflinner@gmail.com>
Stefano Rodriguez <hlsroddy@gmail.com>
Salvatore Giordano <salvatoregiordanoo@gmail.com>
Brian Armstrong <brian@flutter.institute>
Paul DeMarco <paulmdemarco@gmail.com>
Fabricio Nogueira <feufeu@gmail.com>
Simon Lightfoot <simon@devangels.london>
Ashton Thomas <ashton@acrinta.com>
Thomas Danner <thmsdnnr@gmail.com>
Diego Velásquez <diego.velasquez.lopez@gmail.com>
Hajime Nakamura <nkmrhj@gmail.com>
Tuyển Vũ Xuân <netsoft1985@gmail.com>
Miguel Ruivo <miguel@miguelruivo.com>
Sarthak Verma <sarthak@artiosys.com>
Mike Diarmid <mike@invertase.io>
Invertase <oss@invertase.io>
Elliot Hesp <elliot@invertase.io>
Vince Varga <vince.varga@smaho.com>
Aawaz Gyawali <awazgyawali@gmail.com>
EUI Limited <ian.evans3@admiralgroup.co.uk>
Katarina Sheremet <katarina@sheremet.ch>
Thomas Stockx <thomas@stockxit.com>
Sarbagya Dhaubanjar <sarbagyastha@gmail.com>
Ozkan Eksi <ozeksi@gmail.com>
Rishab Nayak <rishab@bu.edu>
ko2ic <ko2ic.dev@gmail.com>
Jonathan Younger <jonathan@daikini.com>
Jose Sanchez <josesm82@gmail.com>
Debkanchan Samadder <debu.samadder@gmail.com>
Audrius Karosevicius <audrius.karosevicius@gmail.com>
Lukasz Piliszczuk <lukasz@intheloup.io>
SoundReply Solutions GmbH <ch@soundreply.com>
Rafal Wachol <rwachol@gmail.com>
Pau Picas <pau.picas@gmail.com>
Christian Weder <chrstian.weder@yapeal.ch>
Alexandru Tuca <salexandru.tuca@outlook.com>
Christian Weder <chrstian.weder@yapeal.ch>
Rhodes Davis Jr. <rody.davis.jr@gmail.com>
Luigi Agosti <luigi@tengio.com>
Quentin Le Guennec <quentin@tengio.com>
Koushik Ravikumar <koushik@tengio.com>
Nissim Dsilva <nissim@tengio.com>
Giancarlo Rocha <giancarloiff@gmail.com>
Ryo Miyake <ryo@miyake.id>
Théo Champion <contact.theochampion@gmail.com>
Kazuki Yamaguchi <y.kazuki0614n@gmail.com>
Eitan Schwartz <eshvartz@gmail.com>
Chris Rutkowski <chrisrutkowski89@gmail.com>
Juan Alvarez <juan.alvarez@resideo.com>
Aleksandr Yurkovskiy <sanekyy@gmail.com>
Anton Borries <mail@antonborri.es>
Alex Li <google@alexv525.com>
Rahul Raj <64.rahulraj@gmail.com>
Bodhi Mulders <info@bemacized.net>
3 changes: 3 additions & 0 deletions packages/local_auth/local_auth_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release from migration to federated architecture.
25 changes: 25 additions & 0 deletions packages/local_auth/local_auth_android/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 11 additions & 0 deletions packages/local_auth/local_auth_android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# local\_auth\_android

The Android implementation of [`local_auth`][1].

## Usage

This package is [endorsed][2], which means you can simply use `local_auth`
normally. This package will be automatically included in your app when you do.

[1]: https://pub.dev/packages/local_auth
[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
@SuppressWarnings("deprecation")
public class LocalAuthPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware {
private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth";
private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth_android";
private static final int LOCK_REQUEST_CODE = 221;
private Activity activity;
private final AtomicBoolean authInProgress = new AtomicBoolean(false);
Expand Down
8 changes: 8 additions & 0 deletions packages/local_auth/local_auth_android/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# local_auth_example

Demonstrates how to use the local_auth plugin.

## Getting Started

For help getting started with Flutter, view our online
[documentation](https://flutter.dev/).
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId "io.flutter.plugins.localauthexample"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

package io.flutter.plugins;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DartIntegrationTest {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

package io.flutter.plugins.localauth;

import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.integration_test.FlutterTestRunner;
import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.plugins.DartIntegrationTest;
import org.junit.Rule;
import org.junit.runner.RunWith;

@DartIntegrationTest
@RunWith(FlutterTestRunner.class)
public class FlutterFragmentActivityTest {
@Rule
public ActivityTestRule<FlutterFragmentActivity> rule =
new ActivityTestRule<>(FlutterFragmentActivity.class);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.localauthexample">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>

<application android:label="local_auth_example" android:icon="@mipmap/ic_launcher">
<activity android:name="io.flutter.embedding.android.FlutterFragmentActivity"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat.Light"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2"/>
</application>
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1024m
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sun Jan 03 14:07:08 CST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withInputStream { stream -> plugins.load(stream) }
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'package:local_auth_android/local_auth_android.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('canCheckBiometrics', (WidgetTester tester) async {
expect(
LocalAuthAndroid().getEnrolledBiometrics(),
completion(isList),
);
});
}
Loading
0