Giter Site home page Giter Site logo

reprint's Introduction

Deprecated

Use androidx.biometric instead, which supports other forms of biometric authentication such as iris scanning an facial recognition, and provides a UI that is consistent across applications.

A simple, unified fingerprint authentication library for Android with RxJava extensions.

  • Eliminates the need to deal with the different available Fingerprint APIs, including Imprint and Samsung Pass.
  • Fixes undocumented bugs and idiosyncrasies in the underlying APIs.
  • Supports more Imprint devices than FingerprintManagerCompat from the androidx library.
  • Comes with help messages translated in over 80 locales that work with all APIs.
  • Provides optional RxJava interfaces.

Usage

See the sample app for a complete example.

In your Application.onCreate, initialize Reprint with Reprint.initialize(this). This will load the Marshmallow module, and the Spass module if you included it.

Then, anywhere in your code, you can call Reprint.authenticate to turn on the fingerprint reader and listen for a fingerprint. You can call Reprint.cancelAuthentication to turn the reader off before it finishes normally.

There are two ways to be notified of authentication results: traditional callback, and a ReactiveX Observable.

RxJava interface

If you include the reactive reprint library, you can be notified of authentication results through an Observable (or Flowable with RxJava 2) by calling RxReprint.authenticate. In this case, the subscriber's onNext will be called after each failure and after success.

RxReprint.authenticate()
    .subscribe(result -> {
        switch (result.status) {
            case SUCCESS:
                showSuccess();
                break;
            case NONFATAL_FAILURE:
                showHelp(result.failureReason, result.errorMessage);
                break;
            case FATAL_FAILURE:
                showError(result.failureReason, result.errorMessage);
                break;
        }
    });

The failureReason is an enum value with general categories of reason that the authentication failed. This is useful for displaying custom help messages in your UI.

The errorMessage is a string that will contain some help text provided by the underlying SDK about the failure. You should show this text to the user, or some other message of your own based on the failureReason. This string will never be null from a failure, and will be localized into the current locale.

For detail on the other parameters, see the Javadocs.

One advantage that this interface has is that when the subscriber unsubscribes, the authentication request is automatically canceled. So you could, for example, use the RxLifecycle library to bind the observable, and the authentication will be canceled when your activity pauses.

Traditional Callbacks

If you want to use Reprint without RxJava, you can pass an AuthenticationListener to authenticate. The onFailure callback will be called repeatedly until the sensor is disabled or a fingerprint is authenticated correctly, at which point onSuccess will be called.

Reprint.authenticate(new AuthenticationListener() {
    public void onSuccess(int moduleTag) {
        showSuccess();
    }

    public void onFailure(AuthenticationFailureReason failureReason, boolean fatal,
                          CharSequence errorMessage, int moduleTag, int errorCode) {
        showError(failureReason, fatal, errorMessage, errorCode);
    }
});

Documentation

The javadocs for the Reprint modules are available online:

Installation

Reprint is distributed with jitpack and split up into several libraries, so you can include only the parts that you use.

First, add Jitpack to your gradle repositories.

repositories {
    maven { url "https://jitpack.io" }
}

Then add the core library and optionally the Samsung Pass interface and the ReactiveX interface. Reprint provides support for both RxJava 1 and 2; you should include the module that matches the version of RxJava that you use in your project.

dependencies {
   compile 'com.github.ajalt.reprint:core:3.3.2@aar' // required: supports marshmallow devices
   compile 'com.github.ajalt.reprint:reprint_spass:3.3.2@aar' // optional: deprecated support for pre-marshmallow Samsung devices
   compile 'com.github.ajalt.reprint:rxjava:3.3.2@aar' // optional: the RxJava 1 interface
   compile 'com.github.ajalt.reprint:rxjava2:3.3.2@aar' // optional: the RxJava 2 interface
}

Permissions

Reprint requires the following permissions be declared in your AndroidManifest.xml. As long as you use the aar artifacts, these permissions will be included automatically.

<!-- Marshmallow fingerprint permission-->
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>

<!-- Samsung fingerprint permission, only required if you include the Spass module -->
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

Spass SDK deprecation

Samsung has deprecated the Spass SDK in favor of the standard Android APIs. Although Reprint still provides a module that uses the the Spass SDK if the standard APIs aren't available, you should be aware that the Spass SDK has a known bug. If you don't need fingerprint support on devices running KitKat, you should not include the reprint_spass module.

License

Copyright 2015-2019 AJ Alt

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

reprint's People

Contributors

ajalt avatar benwicks avatar juanmacuevas avatar tacothedank avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reprint's Issues

Working only after resuming from standby

Turning phone off and on, and using the fingerprint, first to unlock the phone and then to unlock my app works fine.

Using it again fails every time. AuthenticationListener for the Reprint.authenticate seems like it is not listening. No messages.

Thanks for any clue.

Failed to transform file 'reprint_spass-3.2.1.aar'

i have migrated my project to android x
but while compiling "implementation 'com.github.ajalt.reprint:reprint_spass:3.2.1@aar'"
but core dependency working fine
i am getting this error

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'reprint_spass-3.2.1.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform

Reprint.initialize() is blocking, if fingerprint sensor has problems

I get following log messages when calling Reprint.initialize(MainApp.this); in my app class:

FingerprintManager: ensureServiceConnected: mService is null
FingerprintManager: waitForService: called
FingerprintManager: waitForService: Timeout

And whenever I want to start the fingerprint reader I get this exception as well... Any ideas why this is happening?

It's probably some software problem, because it worked before on my phone and all I changed is, that I installed a custom recovery on my phone (a Samsung Galaxy Alpha).

Still, this results in two common problem:

  • Reprint.initialize(MainApp.this); is blocking the app start extremely
  • any usage of Reprint is blocking again

Suggestions:

  • Reprint.initialize(MainApp.this); should be run asnychronously and any use of the Reprint API should block until the init function is finished
  • if Reprint.initialize(MainApp.this); fails, further calls to use Reprint should fail instantly instead of always checking the fingerprint hardware again

STATUS LOCKED OUT in samsung 5.0

hì guy, when i remove my finger print then i get error code 1003 and STATUS LOCKED OUT and error mess is null, please help me fix, thanks.

spass startIdentify or startIdentifyWithDialog

try to integrate this aar to my proj but i notice the dialogue is not appear for samsung pass devices, after dig into your codes and found out you are using startIdentify instead of startIdentifyWithDialog, any reason of this?

Return some info for auth

Is it possible to return some fingerprint hash or encrypt some value for external auth? onSuccess now return only moduleTag.

Samsung module

How can I add SpassReprintModule for Samsung?
thank you

FingerPrint not working on samsung devices

this library sometimes works Randomly but mostly it's not working on samsung devices
i have checked it on these android versions 5.1, 6.0, 7.0 on these samsung devices Galaxy S5 , S6, S7 Edge

i don't know what the issue exactly is but it should work all the time
i followed guide from the library same as its defined to integrate it

Fatal Exception: android.content.res.Resources$NotFoundException

I am seeing this crash on crashlytics logs report with Galaxy J7 Prime android version (8.1.0):

Fatal Exception: android.content.res.Resources$NotFoundException: String resource ID #0x7f110090 at android.content.res.Resources.getText + 354(Resources.java:354) at android.content.res.Resources.getString + 448(Resources.java:448) at android.content.Context.getString + 556(Context.java:556) at com.github.ajalt.reprint.module.marshmallow.MarshmallowReprintModule$AuthCallback.onAuthenticationFailed + 278(MarshmallowReprintModule.java:278) at android.hardware.fingerprint.FingerprintManager$MyHandler.sendAuthenticatedFailed + 1338(FingerprintManager.java:1338) at android.hardware.fingerprint.FingerprintManager$MyHandler.handleMessage + 1245(FingerprintManager.java:1245) at android.os.Handler.dispatchMessage + 106(Handler.java:106) at android.os.Looper.loop + 164(Looper.java:164) at android.app.ActivityThread.main + 7000(ActivityThread.java:7000) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 441(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main + 1408(ZygoteInit.java:1408)

It happens here. Somehow the string R.string.fingerprint_not_recognized is not found

onFailure immediately called on some devices

I read issue #4, however it gets called immediately onFailure only on some devices (in my case Meizu)? onFailure gets called with AuthenticationFailureReason SENSOR_FAILED with error code 1001. Is it possible to handle such cases?

No support fingerprint

Dear admin
i using device asus android 6.0 and have fingerprint and setting fingerprint in device. But when i active finger them get error
Reprint.isHardwarePresent() is false
Please help me.
Thanks ad.
im Duc

CryptoObject

I would like to pass a CryptoObject to the FingerprintManager and I am looking for the path of least resistance solution.

Is it better to build a brand new ReprintModule and call registerModule() with it?
Or should I try to modify the existing MarshmallowReprintModule

Also, if I created a new ReprintModule with Crypto, will I need to modify the RxJava2 library?
Unrelated question, but I noticed that the Samsung SPass module is ignored on API 23+ devices. Is this intended?

Proguard - missing rules

Following rules work but may be able to be improved:

-dontwarn com.samsung.**
-keep class com.samsung.** {*;}

You should add a proguard file to the project..

minsdk

hi, guy
my project have min sdk is 10. And your lib is 14. I get error when build is uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library [com.github.ajalt.reprint:core:2.7.1]
Please help me. Thanks.

Face authentication

hi i am trying to find if in this library exits too face auth and finger print?
as i can see now there is only finger print

onError() called immediately for RxReprint.authenticate() if previous scan failed

I'm creating a Subscription in an activities onResume() and unsubscribing in onPause(), and my onError finishes the activity and starts a new instance of the same activity. If the fingerprint fails, the activity is re-launched, causing onResume() to create a new Subscription for which onError() is called immediately. Here's the relevant reproduction of my code.

public class SecurityActivity {
    Subscription sub;

    @Override
    protected void onResume() {
        super.onResume();
        sub = subscribeFingerprintScanner();
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (sub != null) {
            sub.unsubscribe();
            sub = null;
    }

    private Subscription subscribeFingerprintScanner() {
        return RxReprint.authenticate()
                .retry(RxReprint.retryNonFatal(5))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable throwable) {
                        AuthenticationFailure e = (AuthenticationFailure) throwable;
                        new AlertDialog.Builder(SecurityActivity.this)
                                .setMessage(e.errorMessage)
                                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {
                                        Intent intent = new Intent(SecurityActivity.this, SecurityActivity.class);
                                        startActivity(intent);
                                        finish();
                                    }
                                })
                                .setCancelable(false)
                                .show();
                    }

                    @Override
                    public void onNext(Integer integer) {
                        // do something and finish()
                    }
                });
    }

broken files when building release and proguard

I'm getting following errors:

:app:lintVitalRelease_pro
Error processing ...\app\build\intermediates\exploded-aar\com.github.ajalt.reprint\reprint_spass\2.8.0\jars\libs\pass-v1.1.4.jar:com\samsung\android\sdk\pass\SpassFingerprint.class: broken class file?
Error processing ...\app\build\intermediates\exploded-aar\com.github.ajalt.reprint\reprint_spass\2.8.0\jars\libs\pass-v1.1.4.jar:com\samsung\android\sdk\pass\support\SdkSupporter.class: broken class file?
Error processing ...\app\build\intermediates\exploded-aar\com.github.ajalt.reprint\reprint_spass\2.8.0\jars\libs\pass-v1.1.4.jar:com\samsung\android\sdk\pass\support\v1\FingerprintManagerProxyFactory$a.class: broken class file?

Any ideas why this happens and how to solve that?

Lib doesn't seem to work without retrolamda

It seems that retry(RxReprint.retryNonFatal(5)) doesn't work when not using retrolamda.
After the first (non-fatal) error, the fingerprint reader no longer seems to be listening for any input, and it no longer emits any errors nor codes.

How to reproduce

I changed these lines in the sample app with the code below:

RxReprint.authenticate()
                .doOnError(new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        AuthenticationFailure e = (AuthenticationFailure) throwable;
                        showError(e.failureReason, e.fatal, e.errorMessage, e.errorCode);
                    }
                })
                .retry(RxReprint.retryNonFatal(5))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Integer integer) {
                        showSuccess();
                    }
                });

Tried this on a nexus 6p (running android 7.1.1) and on an emulator with the 7.1.1. image.

However! Adding plenty of breakpoints seemed to solve the issue..

AGP 3.2.0-alpha18 Error

error processing /Users/bwicks/.gradle/caches/transforms-1/files-1.1/reprint_spass-3.2.1.aar/cefecf9272366b1595138cd6fb920b26/jars/libs/pass-v1.1.4.jar
java.lang.ArrayIndexOutOfBoundsException: 5
	at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2310)
	at org.objectweb.asm.ClassReader.readFrame(ClassReader.java:2269)
	at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1448)
	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
	at com.android.builder.desugaring.DesugaringClassAnalyzer.analyze(DesugaringClassAnalyzer.java:144)
	at com.android.builder.desugaring.DesugaringClassAnalyzer.analyzeJar(DesugaringClassAnalyzer.java:92)
	at com.android.builder.desugaring.DesugaringClassAnalyzer.analyze(DesugaringClassAnalyzer.java:63)
	at com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.lambda$getInitalGraphData$4(DesugarIncrementalTransformHelper.java:150)
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

There are no errors when I build with AGP 3.1.3 stable.

Deliver errors in onError for Rx

The way the api is written errors come the same method as successes. It makes it difficult to write a chain of map, flatmap, debounce or other operations if you have to filter or check out errors first, and completely defeats the purposed design of going reactive.

Exception in Samsung Galaxy S5

Hi again,

I'm getting this error when I try a not-registered finger:

java.lang.NoSuchMethodError: com.samsung.android.fingerprint.FingerprintEvent.getImageQualityFeedback
      at com.samsung.android.sdk.pass.c.run(Unknown Source)
      at android.os.Handler.handleCallback(Handler.java:733)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5579)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
      at dalvik.system.NativeStart.main(Native Method)

RxReprint retry doesn't retry correct number of times

I found that if I use RxReprint.authenticate().retry(RxReprint.retryNonFatal(5)), onError() will usually be called on the 6th failure (but not always). Changing that to RxReprint.authenticate().retry(RxReprint.retryNonFatal(2)) results in the same behavior, as does RxReprint.authenticate().retry(RxReprint.retryNonFatal(1)).

What I'm trying to go if give the user 3 tries, and tell the user on the 2nd try that if they do not succeed they will be logged out.

Potential for memory leaks.

For my app, I have LeakCanary set up and it found that an activity was leaked because a dialog I had created implemented the AuthenticationListener interface which was passed to Reprint.authenticate(). According to the LeakCanary Dump, Reprint looks to be holding onto the listener it's given which in my case kept the dialog and activity that launched it in memory.

I have created a workaround for my app, but ideally Reprint would drop its references once authentication is complete.

If it matters, I'm running a Huawei Nexus 6P with Android 6.0.1.

Not able to import in android studio

Hello, I have tried a lot to import this to android studio and eclipse also but I am getting this error,

Error:Unable to load class 'org.gradle.internal.logging.LoggingManagerInternal'.
Possible causes for this unexpected error include:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Please help me,
Thank you in advance

NoClassDefFoundError CancellationSignal

On the migration of the lib to Android X core, there was a conflict of dependencies .

https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/os/CancellationSignal;
        at com.github.ajalt.reprint.core.ReprintInternal.authenticate(ReprintInternal.java:95)
        at com.github.ajalt.reprint.core.Reprint.authenticate(Reprint.java:109)
        at com.github.ajalt.reprint.core.Reprint.authenticate(Reprint.java:90)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.os.CancellationSignal" on path: DexPathList[[zip file "/data/app/...... "],nativeLibraryDirectories=[/data/app/.....==/lib/arm, /data/app/......==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.github.ajalt.reprint.core.ReprintInternal.authenticate(ReprintInternal.java:95) 
        at com.github.ajalt.reprint.core.Reprint.authenticate(Reprint.java:109) 
        at com.github.ajalt.reprint.core.Reprint.authenticate(Reprint.java:90) 

Reprint not recognising prints or HW

I am using the latest version of the library. My users are reporting that my app is no longer recognising fingerprints registered on device and sometimes not even the fingerprint hardware. Example devices - OnePlus 2 and Cubot cheetah 2. I personally tested on Android Emulator (running 7.1.1) and a Samsung J7 Prime and it worked, but not sure why it doesn't work on others.

Funny thing is, it used to work before (when using v2.5.6), but I updated the library to the latest version today in my app and it broke support for some devices.

Reprint.cancelAuthentication() Not Working in Service

Reprint working perfect on Activitys.
But in Service when new AuthenticationListener starts, it work only in first time that service started and when that service killed and start again, AuthenticationListener not working, untill app re install or clear data happen.
in my Service onDestroy:

public void onDestroy() {
        super.onDestroy();
        Reprint.cancelAuthentication();
}

I think problem is becouse of Reprint.cancelAuthentication(); not working in service.
I test it by calling Reprint.cancelAuthentication(); inside of onFailure callback and it stop listener on first onFailure in activity but not in service.

NO_HARDWARE with Galaxy Note 4

I'm getting failureReason = NO_HARDWARE in method onFailure(), after calling Reprint.authenticate() on a Samsung Galaxy Note 4. I have added the proper @aar declaration for Samsung Pass and fingerprint works fine in other apps. What can be wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.