我有一个应用程序提供使用指纹进行身份验证。
在询问用户是否要启用它之前,我验证它是否可用并且通过以下方式完成:
FingerprintManager fingerprintManager = context.getSystemService(FingerprintManager.class);
return fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints();
两个FingerprintManager的方法都带有注释:
@RequiresPermission(USE_FINGERPRINT)
但是,USE_FINGERPRINT 权限是正常的,如http://developer.android.com/guide/topics/security/normal-permissions.html中所指定。这意味着,一旦您在AndroidManifest.xml文件中声明了该权限(我们这样做,该功能已经过测试并在测试设备上运行),您不必在运行时检查它。
正如 Fabric 崩溃报告所报告的那样,现在正在发生的事情是一些用户在指纹管理器.isHardwareDetected()调用上崩溃了:
java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10150 nor current process has android.permission.USE_FINGERPRINT.
到目前为止,有 2 个用户在 Marshmallow(Android 6.0)上发生了这种情况,但他们都没有植根(据 Fabric 报道),设备是 LG G4 Stylus(LG H635)和 Sony Xperia Z5 Premium(Sony E6853)。
关于这如何可能以及可能的解决方法的任何解释?
如果这些用户不使用普通 Android,我会说他们能够通过自定义 ROM 功能(如 CyanogenMod 的隐私保护)来操纵应用程序权限。但情况似乎并非如此。
堆栈跟踪是:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{MY.PACKAGE/MY.PACKAGE.MYACTIVITY}: java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10150 nor current process has android.permission.USE_FINGERPRINT.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10150 nor current process has android.permission.USE_FINGERPRINT.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.isHardwareDetected(IFingerprintService.java:367)
at android.hardware.fingerprint.FingerprintManager.isHardwareDetected(FingerprintManager.java:642)
at MY.PACKAGE.MYACTIVITY.isSupported(MYACTIVITY.java:54)
at MY.PACKAGE.MYACTIVITY.onCreate(MYACTIVITY.java:38)
at android.app.Activity.performCreate(Activity.java:6272)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)