Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检测设备是否用pin锁或指纹锁(人脸锁)固定?_Android_Android Fingerprint Api_Android Biometric Prompt_Android Biometric - Fatal编程技术网

Android 检测设备是否用pin锁或指纹锁(人脸锁)固定?

Android 检测设备是否用pin锁或指纹锁(人脸锁)固定?,android,android-fingerprint-api,android-biometric-prompt,android-biometric,Android,Android Fingerprint Api,Android Biometric Prompt,Android Biometric,我的应用程序包含登录的用户身份验证(包括pin/模式、指纹解锁),这取决于设备安全性。我正在使用Biometric manager使用Biometric manager检测设备是否具有指纹支持,并使用IsDeviceSecurity()检查设备是否安全。我需要检测移动设备在哪种模式下安全,是pin/图案带指纹、pin/图案带面部解锁还是所有三种模式(pin/图案、面部解锁、指纹)。以下是检测设置了何种锁定类型的代码 将库添加到build.gradle implementation 'androi

我的应用程序包含登录的用户身份验证(包括pin/模式、指纹解锁),这取决于设备安全性。我正在使用Biometric manager使用Biometric manager检测设备是否具有指纹支持,并使用IsDeviceSecurity()检查设备是否安全。我需要检测移动设备在哪种模式下安全,是pin/图案带指纹、pin/图案带面部解锁还是所有三种模式(pin/图案、面部解锁、指纹)。

以下是检测设置了何种锁定类型的代码

将库添加到
build.gradle

implementation 'androidx.biometric:biometric:1.0.0-beta01'
并将此代码添加到您的活动中

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");
}

我们无法检测脸型。有关更多信息,请参见此

也许您可以从这里@Priyankagb获得答案。提供的解决方案是检查指纹是否已注册。我需要检查设备的安全模式。我已测试了您的解决方案的工作情况,但即使指纹被禁用以确保设备安全,我在三星galaxy设备中收到“I=0(BIOMETRIC Manager.BIOMETRIC_SUCCESS)”。由于禁用指纹作为设备安全,指纹数据未从设备中清除(使用BiometricManager.BIOMETRIC_SUCCESS时会触发BiometricManager.from(this.canAuthenticate())。此外,我需要设备当前的锁定模式(pin/模式、面部解锁、指纹)。我们无法获得当前设置的特定锁定类型。我有这样一种情况,如果用户从设备安全性禁用指纹,应用程序需要检测它,使用生物识别提示仅询问其他身份验证模式,如pin/模式,而不是指纹。此方法
createConfirmDeviceCredentialIntent()
来自
KeyguardManager
可能会帮助您。尝试并检查返回的内容。不,无法获取所需信息。