Evgeniy Mishustin
Evgeniy Mishustin

Reputation: 3804

Android fingerprint API - migrating from Samsung Spass

Suppose I have an application which uses fingerprints to authenticate users. On Android 5 I used the Samsung Spass library only for Samsung devices. With Android M release I add support to many devices. First of all I check if I'm Android M, then if I have a manager instance, if I have a hardware and if I have enrolled fingerprints:

 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
        if (manager != null) {
            logger.info("Android native fingerprint manager exists");
            if (manager.isHardwareDetected()) {
                logger.info("Android native fingerprint manager detected hardware");
                if (manager.hasEnrolledFingerprints()) {
                    logger.info("Android native fingerprint manager has enrolled fingerprints");
                }
            }
            return new AndroidFingerprintHelper(context);
        }
    }

If I fail here I fallback to check if Android is Samsung and it has Spass library installed. Now the question is: if a user had Lollipop on Samsung with Spass and has enrolled fingerprints. After that he upgraded to Android M without enrolling new fingerprints. Will manager.hasEnrolledFingerprints() return true? In other words, does Samsung Spass library share its data with Android OS? Thanks.

Upvotes: 0

Views: 1651

Answers (2)

karim
karim

Reputation: 15589

If Samsung device supports Android native biometric lib then use it otherwise use Samsung's own Spass lib. Without this, I have a problem with S9+ with Android Pie. This solved the issue.

if (Build.BRAND.equals("samsung")) {
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
            FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
            if (fingerprintManager != null && fingerprintManager.isHardwareDetected()) {
                return new FingerprintHelperNative(context);
            }
        }
        Log.d(TAG, "Using Samsung fingerprint library. ");
        return new FingerprintHelperSamsung(context);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
        return new FingerprintHelperNative(context);
    } else return null;

Upvotes: 0

Evgeniy Mishustin
Evgeniy Mishustin

Reputation: 3804

Well after a lot of research and tests I've found out that: On Samsung with Android M FingerPrintManager will never null, but if the fingerprints were registered using Spass Library (Samsung Native SDK), trying to call manager.isHardwareDetected() will return false for Native Android FingerPrint Manager.

Upvotes: 1

Related Questions