mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
auth activity for locked vaults when autofilling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Android;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Service.Autofill;
|
||||
@@ -18,6 +19,7 @@ namespace Bit.Android.Autofill
|
||||
public class AutofillService : global::Android.Service.Autofill.AutofillService
|
||||
{
|
||||
private ICipherService _cipherService;
|
||||
private ILockService _lockService;
|
||||
|
||||
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback)
|
||||
{
|
||||
@@ -27,8 +29,6 @@ namespace Bit.Android.Autofill
|
||||
return;
|
||||
}
|
||||
|
||||
var clientState = request.ClientState;
|
||||
|
||||
var parser = new Parser(structure);
|
||||
parser.ParseForFill();
|
||||
|
||||
@@ -37,30 +37,31 @@ namespace Bit.Android.Autofill
|
||||
return;
|
||||
}
|
||||
|
||||
if(_lockService == null)
|
||||
{
|
||||
_lockService = Resolver.Resolve<ILockService>();
|
||||
}
|
||||
|
||||
if(true) // if locked
|
||||
{
|
||||
var authResponse = AutofillHelpers.BuildAuthResponse(this, parser.FieldCollection);
|
||||
callback.OnSuccess(authResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
if(_cipherService == null)
|
||||
{
|
||||
_cipherService = Resolver.Resolve<ICipherService>();
|
||||
}
|
||||
|
||||
// build response
|
||||
var items = new Dictionary<string, IFilledItem>();
|
||||
var ciphers = await _cipherService.GetAllAsync(parser.Uri);
|
||||
if(ciphers.Item1.Any() || ciphers.Item2.Any())
|
||||
{
|
||||
var allCiphers = ciphers.Item1.ToList();
|
||||
allCiphers.AddRange(ciphers.Item2.ToList());
|
||||
foreach(var cipher in allCiphers)
|
||||
{
|
||||
items.Add(cipher.Id, new CipherFilledItem(cipher));
|
||||
}
|
||||
}
|
||||
|
||||
var items = await AutofillHelpers.GetFillItemsAsync(_cipherService, parser.Uri);
|
||||
if(!items.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var response = AutofillHelpers.BuildFillResponse(this, false, parser.FieldCollection, items);
|
||||
var response = AutofillHelpers.BuildFillResponse(this, parser.FieldCollection, items);
|
||||
callback.OnSuccess(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user