Search code examples
androidaccessibilityserviceandroid-fingerprint-apiaccessibilityaccessibility-api

BiometricPrompt and AccessibilityService


Previously, FingerprintManager could be used to handle fingerprint authentication, and did not depend on an Activity in order to go through a system dialog. It could be used from anywhere, as any of the sensor managers.

Now, Google have released the support library version in https://developer.android.com/reference/androidx/biometrics/BiometricPrompt and deprecated FingerprintManager. They wish all apps to go through the same unified system dialog.

Big problem is - the whole thing is strongly coupled to FragmentActivity.

I wish to use this fingerprint authentication in an AccessibilityService (display over other apps).

What can be done?

Some options I'm considering:

  1. Go back to the old FingerprintManager despite becoming deprecated.
  2. Implement some transparent Activity that will somehow pop up above other apps, just to satisfy the API's requirement for FragmentActivity.

UPDATE

Accepted commonsware's answer below. I am able to succesfully launch an Activity on top of apps when getting accessibility events, and start using BiometricPrompt. BiometricPrompt has other problems though, and it seems like a very half-baked API that never went through stress testing - but that's beyond the scope of this question.


Solution

  • Go back to the old FingerprintManager despite becoming deprecated

    That may not work well on newer devices. I suspect that it also will not work well on devices whose biometric security is not a fingerprint.

    Implement some transparent Activity that will somehow pop up above other apps, just to satisfy the API's requirement for FragmentActivity.

    If I were in your shoes, I would go this route. Use Theme.Translucent.NoTitleBar for this.

    Note that I cannot guarantee that this will work from an AccessibilityService, and displaying any form of UI will result in new accessibility events that you would need to filter out.