Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify if device has in-display Biometric fingerprint support?

I'm writing a application feature to authenticate user using Biometric fingerprint authentication API. And it worked as expected with combination of BiometricPrompt API.

In general it display own UI dialog so it can be unified across Android device.(Improvement from Fingerprint Manager API)

In one of device testing scenario I come across in-display(on screen, e.g. Oneplus 6T device) fingerprint support instead rear biometric hardware option.

When I run application on it, on call of biometricPrompt.authenticate(..) instead of dialog it display in-display fingerprint authentication option. Which is ok, and manage by internal API of BiometricPrompt.

But it create some inconsistency to manage for developer.

  1. When it provide in-build authentication dialog, all fallback error displayed in dialog itself.
  2. But in case of in-display authentication I didn't found a way where it manage to display error message it-self. And I have to handle this fallback and display in a custom way.

Now question is

  1. Is there a way to manage/display message by in-display authentication view component.
  2. How can identify if device is support in-device biometric authentication.

Edit: Code reference I'm using:

import android.content.Context
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.FragmentActivity
import java.lang.Exception
import java.util.concurrent.Executors
import javax.crypto.Cipher

class BiometricAuthenticationManager(private val context: Context) :
        BiometricPrompt.AuthenticationCallback() {

    private var biometricPrompt: BiometricPrompt? = null

    override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
        super.onAuthenticationError(errorCode, errString)
        biometricPrompt?.cancelAuthentication()
    }

    override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
        super.onAuthenticationSucceeded(result)

    }

    override fun onAuthenticationFailed() {
        super.onAuthenticationFailed()
    }

    fun init(cipher: Cipher, promptInfo: BiometricPrompt.PromptInfo) {
        if (context is FragmentActivity) {
            val executor = Executors.newSingleThreadExecutor()

            biometricPrompt = BiometricPrompt(context, executor, this)
            biometricPrompt?.authenticate(promptInfo, BiometricPrompt.CryptoObject(cipher))
        } else {
            throw Exception(
                    "Check for FragmentActivity context.")
        }
    }
}

For further reference about how it look like, please find following attachment.

enter image description here

I try to check same scenario for lock screen, where I guess it uses custom implementation using FingerPrintManager class and display message.

enter image description here

like image 988
CoDe Avatar asked Aug 14 '19 11:08

CoDe


People also ask

How can you tell if a device is biometric?

to Start >> run and type NFD and then press enter. This will open device diagnostic utility. Under Device tab click on device scan button, click init button then place finger on sensor and click capture. Just check if image appear on left window or not.

How do I find biometrics on my phone?

Turn on biometrics in the Android device settingsOpen your phone's Settings and locate the security or biometrics menu. From this menu, set your biometrics preferences to fingerprint.

How do I enable biometrics on Android?

Tap the icon for your account or collection at the top right and choose Settings > Security. If you're using a tablet, tap your account or collection at the top of the sidebar. Tap to turn on biometric unlock, then place your finger on the fingerprint sensor, or let your device scan your face or eyes.

What is biometric fingerprint identification?

A biometric fingerprint reader records the impressions left by the patterns of the ridges of the finger pads of a human being. A fingerprint is entirely unique to a certain person.


1 Answers

Faced with the same problem some time ago - OnePlus 6T has no Biometric UI, at the same time Samsung A51 - has its own (custom) UI for Fingerprint API and another for BiometricPrompt API. I tried to watch for Activity window focus loss (For OnePlus - activity do not lose focus, at the same time BiometricPrompt UI leads to focus loss), but appear a problem with the Samsung device.

The only solution that I found, and it works for now:

  1. Need to get the correct device name (for OnePlus for example, it should be not ONEPLUS A6003, but One Plus 6 instead)
  2. Need to perform request to https://m.gsmarena.com/res.php3?sSearch=Device+Name, you should get the list with matches, usually, first one is needed
  3. Parse HTML (from previews step) to get the link for device specification (like https://m.gsmarena.com/oneplus_6t-9350.php)
  4. Now you need to perform a request to this link and again parse HTML and get the "Sensors" section. You should get a string like "Fingerprint (under display, optical), accelerometer, gyro, proximity, compass"
  5. Split this string to get the list with sensors
  6. Now when you need to check if an in-display scanner is present on the device, just check for "fingerprint" and "under display" for the same sensor.

Link with impl. that can be used as an example

like image 60
Serhii.Komlach Avatar answered Sep 21 '22 15:09

Serhii.Komlach