1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-19 17:03:21 +00:00
Files
mobile/src/Core/Services/BaseBiometricService.cs
2023-09-29 11:02:19 -03:00

43 lines
1.5 KiB
C#

using System.Threading.Tasks;
using Bit.Core.Abstractions;
namespace Bit.App.Services
{
public abstract class BaseBiometricService : IBiometricService
{
protected readonly IStateService _stateService;
protected readonly ICryptoService _cryptoService;
protected BaseBiometricService(IStateService stateService, ICryptoService cryptoService)
{
_stateService = stateService;
_cryptoService = cryptoService;
}
public async Task<bool> CanUseBiometricsUnlockAsync()
{
#pragma warning disable CS0618 // Type or member is obsolete
return await _cryptoService.GetBiometricUnlockKeyAsync() != null || await _stateService.GetKeyEncryptedAsync() != null;
#pragma warning restore CS0618 // Type or member is obsolete
}
public async Task SetCanUnlockWithBiometricsAsync(bool canUnlockWithBiometrics)
{
if (canUnlockWithBiometrics)
{
await SetupBiometricAsync();
await _stateService.SetBiometricUnlockAsync(true);
}
else
{
await _stateService.SetBiometricUnlockAsync(null);
}
await _stateService.SetBiometricLockedAsync(false);
await _cryptoService.RefreshKeysAsync();
}
public abstract Task<bool> IsSystemBiometricIntegrityValidAsync(string bioIntegritySrcKey = null);
public abstract Task<bool> SetupBiometricAsync(string bioIntegritySrcKey = null);
}
}