2

Is there a way to detect if biometric authentication has been successfully passed recently by using any method from the biometric API or any security log flag ?

I can't find one that would allow an app to check whether the biometric security has passed or any other security phone unlocking methods such as password or pattern.

There must be an internal function that allows the system to check whether the phone is unlocked or not and store it in some variable, but I can't find any.

Do you know a way to achieve this?

1 Answers1

1

So if I'm getting it correct . You don't want to have a biometric check in your app but instead, want to know if a biometric check has been enabled in the system or not.

There is a way to check the security using Keyguard Manager (min API level 23).

public static boolean isDeviceSecure(Context context)
{        
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    {
        KeyguardManager manager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        return manager.isDeviceSecure();
    }
}

But if you want to check specifically for biometric or each of them individually this answer might help.

Narendra_Nath
  • 4,578
  • 3
  • 13
  • 31
  • thank you. The answer is leading me to the right path, I presume. What I would like is to know is the phone has been unlocked and count the times this has been done, independently of the type of biometric test passed. Does the function you provide, allow to know that the system biometric identification is enabled, or does it return if the system has approved the identification by the user. This last option is what I am looking for. – Ramón Puig Jan 17 '22 at 15:23