Android Fingerprints: hasEnrolledFingerprints triggers exception on some Samsungs

橙三吉。 提交于 2020-01-01 04:08:07

问题


I'm seeing a lot of exceptions in our production app when enabling fingerprints coming from Android 6 users, which I cannot reproduce on any of my local Samsung devices. The stacktrace is:

Message: SecurityException: Permission Denial: getCurrentUser() from pid=24365, uid=10229 requires android.permission.INTERACT_ACROSS_USERS
android.os.Parcel.readException in Parcel.java::1620
android.os.Parcel.readException in Parcel.java::1573
android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints in IFingerprintService.java::503
android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints in FingerprintManager.java::762
android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23.a in SourceFile::39
android.support.v4.hardware.fingerprint.FingerprintManagerCompat$Api23FingerprintManagerCompatImpl.a in SourceFile::239
android.support.v4.hardware.fingerprint.FingerprintManagerCompat.a in SourceFile::66

This is just using the standard FingerprintManagerCompat class from the support library, and the check works correctly on other devices.

I don't want to add this permission to my app - it seems to have nothing to do with fingerprints.

Has anyone encountered anything like this?


回答1:


I came across the same problem on a Samsung Galaxy S6, running Android 6.0.1

The Problem was caused by calling

fingerprintManager.hasEnrolledFingerprints()

I fixed it by adding a call to check for hardware before:

fingerprintManager.isHardwareDetected()
    && mFingerprintManager.hasEnrolledFingerprints()

Checking for fingerprints without the hardware available seems to cause this exception on some devices.



来源:https://stackoverflow.com/questions/37780080/android-fingerprints-hasenrolledfingerprints-triggers-exception-on-some-samsung

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!