7
votes

I've recently released a new app which contains support for authentication via fingerprint.

This has worked fine on all of our test devices:
- OnePlus Three
- OnePlus Five
- Samsung S6 Edge
- Samsung S7
- Samsung S8

But when released, we began getting crashes from Fabric with this stack trace:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.our.app/com.our.app.ui.LoginActivity}: java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=30208, uid=10038 requires android.permission.INTERACT_ACROSS_USERS
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
       at android.app.ActivityThread.access$1100(ActivityThread.java:229)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7325)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=30208, uid=10038 requires android.permission.INTERACT_ACROSS_USERS
       at android.os.Parcel.readException(Parcel.java:1620)
       at android.os.Parcel.readException(Parcel.java:1573)
       at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints(IFingerprintService.java:503)
       at android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints(FingerprintManager.java:776)
       at com.our.app.fingerprint.handler.FingerprintHandler.canUseFingerprint(SourceFile:65)
       at com.our.app.Client.canUseFingerprint(SourceFile:335)
       at com.our.app.ui.LoginActivity.updateViewVisibilityBasedOnState(SourceFile:501)
       at com.our.app.ui.LoginActivity.updateViewVisibilityBasedOnState(SourceFile:472)
       at com.our.app.ui.LoginActivity.continueWithOnCreateLogic(SourceFile:399)
       at com.our.app.ui.LoginActivity.onCreate(SourceFile:321)
       at android.app.Activity.performCreate(Activity.java:6904)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
       at android.app.ActivityThread.access$1100(ActivityThread.java:229)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7325)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

According to Fabric, these devices are experiencing the crash:
- Galaxy A5
- Galaxy S5 Mini
- Galaxy A3(2016)

All of them are running Android 6.0.1.

Seeing as they're all Samsung devices, I began suspecting that Knox could be the issue, even though it isn't specifically listed anywhere in the stacktrace. But i have no idea on how to work around it, or fix it.

I found a similar issue posted on Samsung's own website, but without a fix:
https://seap.samsung.com/forum-topic/getting-javalangsecurityexception-permission-denial

The permission that's named in the stacktrace is a system permission, which no user apps can get. Only system apps can.

Does anyone have an idea on how to fix this?

2
- Galaxy A5 - Galaxy S5 Mini - Galaxy A3(2016) this device have fingerPrint touch?KuLdip PaTel
@KuLdipPaTel s5 mini and a3 have fingerprint scannerMilos Lulic
Did you figure this one out? We have the same problem...Jens Moser
I recall getting SecurityExceptions on a Galaxy S7 the first time I called hasEnrolledFingerprints after a device reboot. The exception would not occur if I called isHardwareDetected before hasEnrolledFingerprints. I can no longer reproduce the issue on that device, but it's now running Android 7.0 and I don't remember which Android version it was running when we got it.Michael

2 Answers

2
votes

Not sure if you were ever able to find a solution for this, as a workaround I simply wrapped our calls in a permission check.

inline val Activity.fingerprintManager: FingerprintManagerCompat?
  get() = (
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED) {
      FingerprintManagerCompat.from(this)
    } else { null }
  )
-1
votes

Yes, I’ve seen this crash.

Since INTERACT_WITH_USERS is a system permission, it’s no wonder it crashes for us.

Silly Samsung.

Wrap the code in a try/catch for a SecurityException.

-Ken