ajalt / reprint

A unified fingerprint library for android.
Apache License 2.0
468 stars 89 forks source link

BiometricPRompt support and Spass version 1.2.6 #40

Closed kenshin171 closed 5 years ago

kenshin171 commented 5 years ago

Hi, great library. 2 Questions.

1) Is there any intention to support the new upcoming BiometricPrompt api from google? 2) Does the new version of Spass, version 1.2.6 resolve https://github.com/ajalt/reprint/issues/6?

ajalt commented 5 years ago
  1. It's not out of the question. What would you like to see in terms of an api?
  2. Unfortunately no, although Reprint now only uses the Spass module on KitKat devices, so the impact of the bug is reduced. If support for the small number of Samsung devices with fingerprint readers running KitKat is not a high priority, you can remove the reprint_spass module, and all newer devices should continue to work.
kenshin171 commented 5 years ago

1) In terms of API, should be the same with a little more generic support of all biometrics which i guess Google is planning for the future where multiple forms of biometric authentication is possible e.g. face, voice? in addition to fingerprint. Maybe an enum to select which form of biometric to use? But this maybe in the future as even biometricprompt api does not support anything more than fingerprint at the moment. Another point is the fingerprintManager is marked for deprecation in api 28 onwards, so biometricPrompt api is the way to go as it is also a compat library https://mvnrepository.com/artifact/androidx.biometric/biometric

2) Unfortunately for my project i need to continue support for phones with fingerprint sensors that only support spass e.g. Samsung Galaxy s5 and note 4. So can i still use the Spass module even with Reprint version 3.3.0?

ajalt commented 5 years ago

Yes, you can continue to use Reprint 3.3.0, but you may run into the mentioned issue. If you don't need androidx support, you may want to remain on the previous version.

kenshin171 commented 5 years ago

Yes, you can continue to use Reprint 3.3.0, but you may run into the mentioned issue. If you don't need androidx support, you may want to remain on the previous version.

by Issue do u mean https://github.com/ajalt/reprint/issues/6 ? I thought the sPass Module uses spass sdk version 1.1.4 to avoid https://github.com/ajalt/reprint/issues/6? or did i misunderstand something

ajalt commented 5 years ago

You are correct, but Spass 1.1.4 doesn't work with androidx. Reprint 3.3.0 converted to androidx, so it has to use the latest Spass version, which contains the bug.

kenshin171 commented 5 years ago

juz a random thought, to avoid the infamous https://github.com/ajalt/reprint/issues/6. Would it be able to just continue to use 1.1.4 version of spass sdk but jetifiy it for androidX support? https://developer.android.com/studio/command-line/jetifier states that it support jar files.

e.g. jetifier-standalone -i pass-v1.1.4.jar -o pass-v1.1.4-jetified.jar

ajalt commented 5 years ago

That's a good idea, but unfortunately it fails as discussed here.

kenshin171 commented 5 years ago

ok i converted my project to androidx and using reprint version 3.3.0. Do i have to manually register spass module or is it still automatically registered as long as i include the spass module dependency.

The behaviour i see is when i did not manually register spass module when using samsung galaxy s5, which can only use spass for fingerprint, i get a "no fingerprint hardware found" message.

update: ahh i get it now according to the code

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            try {
                final Class<?> spassModuleClass = Class.forName(REPRINT_SPASS_MODULE);
                final Constructor<?> constructor = spassModuleClass.getConstructor(Context.class, Reprint.Logger.class);
                ReprintModule module = (ReprintModule) constructor.newInstance(context, logger);
                registerModule(module);
            } catch (Exception ignored) {
            }
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            registerModule(new MarshmallowReprintModule(context, logger));
        }

Spass will only be registered when the device has api level smaller than 23. However my Samsung galaxy s5 is api level 23 (Marshmellow) and it cannot use fingerprintManager only Spass works. Manually registering Spass module works.

for me i am doing this check before registering the Spass Module.

private fun isNativeTouchLoginSupported(application: Application) : Boolean {
            val fingerprintManagerCompat = FingerprintManagerCompat.from(application)
            return fingerprintManagerCompat.isHardwareDetected && fingerprintManagerCompat.hasEnrolledFingerprints()
        }

        fun isSamsungTouchLoginSupported(application: Application?): Boolean {

            return try {
                if(application != null) {

                    if(HardwareUtil.isNativeTouchLoginSupported(application))
                        false
                    else {
                        val mSpass = Spass()
                        mSpass.initialize(application)
                        mSpass.isFeatureEnabled(Spass.DEVICE_FINGERPRINT)
                    }
                }
                else
                    false
            } catch (e: SsdkUnsupportedException) {
                Timber.e( "Error = SsdkUnsupportedException, ${e.message}")
                false
            } catch (e: UnsupportedOperationException) {
                Timber.e( "Error = UnsupportedOperationException, ${e.message}")
                false
            }
        }
ajalt commented 5 years ago

Ok, I added a check to make sure that the marshmallow module works and falls back to spass if possible. Can you try the snapshot build and let me know if it works? You can just change your reprint version number to -SNAPSHOT. e.g. compile 'com.github.ajalt.reprint:core:-SNAPSHOT@aar'

kenshin171 commented 5 years ago

@ajalt Unfortunately the -SNAPSHOT is not working, i am getting Fingerprint hardware not available due to the fact that marshmallowModule.fingerprintManager() == null, fingerprint manager is NOT null, just that fingerprintManager.isHardwareDetected() is false.

kenshin171 commented 5 years ago

@ajalt would you like me to make PR for this?

@ajalt Unfortunately the -SNAPSHOT is not working, i am getting Fingerprint hardware not available due to the fact that marshmallowModule.fingerprintManager() == null, fingerprint manager is NOT null, just that fingerprintManager.isHardwareDetected() is false.

ajalt commented 5 years ago

Ok, I updated the logic in 21c69de, give the snapshot a try again.

kenshin171 commented 5 years ago

@ajalt Awesome!

I tested on both Spass phone and a fingerPrintManager phone. Both works as expected.

ajalt commented 5 years ago

Thanks for testing! I released version 3.3.1 with the fix, let me know if you find any more issues.