gpt4 book ai didi

android - FingerprintManager.isHardwareDetected() 抛出 java.lang.SecurityException?

转载 作者:太空宇宙 更新时间:2023-11-03 10:39:52 27 4
gpt4 key购买 nike

我有一个应用程序可以使用指纹进行身份验证。

在询问用户是否要启用它之前,我会验证它是否可用并通过以下方式完成:

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 崩溃报告所报告的,现在正在发生的事情是一些用户在 fingerprintManager.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)上,他们都没有 root(据 Fabric 报道),设备是 LG G4 Stylus (LG H635) 和 Sony Xperia Z5 Premium (Sony E6853) ).

关于这如何可能的任何解释以及可能的修复方法?

如果这些用户不使用 vanilla 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)

最佳答案

看起来像是构建过程中的错误。清理/重建使问题消失

关于android - FingerprintManager.isHardwareDetected() 抛出 java.lang.SecurityException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36031092/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com