首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >检测装置是用针锁还是面部锁的指纹锁?

检测装置是用针锁还是面部锁的指纹锁?
EN

Stack Overflow用户
提问于 2020-12-28 08:06:33
回答 1查看 933关注 0票数 4

我的应用程序包含登录的用户身份验证(包括引脚/图案、指纹解锁),这取决于设备的安全性。我使用生物识别管理器来检测设备是否具有使用BiometricManager的指纹支持,并检查设备是否使用isDeviceSecure().进行安全保护。我需要检测哪种模式的移动设备是用引脚/图案、带指纹的引脚/图案、带面部解锁的引脚/图案还是这三种模式(针/图案、脸解锁、指纹)。

EN

回答 1

Stack Overflow用户

发布于 2020-12-30 06:33:34

下面是用来检测设置了什么锁类型的代码

build.gradle添加库

代码语言:javascript
运行
复制
implementation 'androidx.biometric:biometric:1.0.0-beta01'

这段代码用于你的活动

代码语言:javascript
运行
复制
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean keyguardSecure = keyguardManager.isKeyguardSecure();
Log.e("---", "checkSecurityTypes: keyguardLocked - " + keyguardSecure);//true = pin/pattern

int i = BiometricManager.from(this).canAuthenticate();
Log.e("---", "checkSecurityTypes: " + i);//true 0 = pin/pattern with finger print

switch (i) {
    case BiometricManager.BIOMETRIC_SUCCESS:
        Log.d("MY_APP_TAG", "App can authenticate using biometrics.");
        break;
    case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
        Log.e("MY_APP_TAG", "No biometric features available on this device.");
        break;
    case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
        Log.e("MY_APP_TAG", "Biometric features are currently unavailable.");
        break;
    case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
        // Prompts the user to create credentials that your app accepts.
        break;
}

if (i == 0 && keyguardSecure) {
    //fingerprint is always with pin/pattern/password
    Log.e("---", "checkSecurityTypes: fingerprint is set with pin/pattern");
} else if (keyguardSecure) {
    //true if pin/pattern/password is set
    Log.e("---", "checkSecurityTypes: pin/pattern is set");
}

我们找不到脸的类型。有关更多信息,请参见此link

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65474598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档