1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-15 07:43:37 +00:00

use native biomatrics on Android

This commit is contained in:
Kyle Spearrin
2019-10-23 09:11:48 -04:00
parent aed3ec5474
commit 4b989b01e9
11 changed files with 199 additions and 52 deletions

View File

@@ -15,6 +15,7 @@ using Foundation;
using LocalAuthentication;
using MobileCoreServices;
using Photos;
using Plugin.Fingerprint;
using UIKit;
using Xamarin.Forms;
@@ -243,18 +244,47 @@ namespace Bit.iOS.Core.Services
Device.OpenUri(new Uri(uri));
}
public bool SupportsFaceId()
public bool SupportsFaceBiometric()
{
if(SystemMajorVersion() < 11)
{
return false;
}
var context = new LAContext();
if(!context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError e))
using(var context = new LAContext())
{
if(!context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var e))
{
return false;
}
return context.BiometryType == LABiometryType.FaceId;
}
}
public Task<bool> SupportsFaceBiometricAsync()
{
return Task.FromResult(SupportsFaceBiometric());
}
public async Task<bool> BiometricAvailableAsync()
{
try
{
return await CrossFingerprint.Current.IsAvailableAsync();
}
catch
{
return false;
}
return context.BiometryType == LABiometryType.FaceId;
}
public bool UseNativeBiometric()
{
return false;
}
public Task<bool> AuthenticateBiometricAsync(string text = null)
{
throw new NotSupportedException();
}
public bool SupportsNfc()