Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Improved fingerprint support #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Improved fingerprint support #246

wants to merge 2 commits into from

Conversation

sorz
Copy link
Contributor

@sorz sorz commented Mar 22, 2017

As per discussion in #242,

  • Catch SecurityException in FingerprintManager.hasEnrolledFingerprints()
  • Display error message on AuthenticationError.

@@ -60,11 +60,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
if (fingerprintManager.hasEnrolledFingerprints()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method might make the code clean.

@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean hasEnrolledFingerprints(FingerprintManager fp) {
    try {
        return (fp != null) && fp.hasEnrolledFingerprints();
    } catch (SecurityException e) {
        // Some Samsung devices throw this on hasEnrolledFingerprints().
        return false;
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants