mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
Check for disable save prompt option before sending fill request in Android Autofill (#1722)
* Check for disable save prompt option before sending fill request - ignore save request payload if true * Add exception handling to Autofill Service * move System reference outside of FDROID
This commit is contained in:
parent
6f3999016f
commit
52024109f7
2 changed files with 127 additions and 101 deletions
|
@ -160,7 +160,7 @@ namespace Bit.Droid.Autofill
|
|||
return new List<FilledItem>();
|
||||
}
|
||||
|
||||
public static FillResponse BuildFillResponse(Parser parser, List<FilledItem> items, bool locked,
|
||||
public static FillResponse.Builder CreateFillResponse(Parser parser, List<FilledItem> items, bool locked,
|
||||
bool inlineAutofillEnabled, FillRequest fillRequest = null)
|
||||
{
|
||||
// Acquire inline presentation specs on Android 11+
|
||||
|
@ -211,9 +211,8 @@ namespace Bit.Droid.Autofill
|
|||
}
|
||||
responseBuilder.AddDataset(BuildVaultDataset(parser.ApplicationContext, parser.FieldCollection,
|
||||
parser.Uri, locked, inlinePresentationSpecs));
|
||||
AddSaveInfo(parser, fillRequest, responseBuilder, parser.FieldCollection);
|
||||
responseBuilder.SetIgnoredIds(parser.FieldCollection.IgnoreAutofillIds.ToArray());
|
||||
return responseBuilder.Build();
|
||||
return responseBuilder;
|
||||
}
|
||||
|
||||
public static Dataset BuildDataset(Context context, FieldCollection fields, FilledItem filledItem,
|
||||
|
|
|
@ -9,6 +9,10 @@ using Bit.Core;
|
|||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
#if !FDROID
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
#endif
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -28,6 +32,8 @@ namespace Bit.Droid.Autofill
|
|||
|
||||
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal,
|
||||
FillCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var structure = request.FillContexts?.LastOrDefault()?.Structure;
|
||||
if (structure == null)
|
||||
|
@ -69,11 +75,25 @@ namespace Bit.Droid.Autofill
|
|||
}
|
||||
|
||||
// build response
|
||||
var response = AutofillHelpers.BuildFillResponse(parser, items, locked, inlineAutofillEnabled, request);
|
||||
callback.OnSuccess(response);
|
||||
var response = AutofillHelpers.CreateFillResponse(parser, items, locked, inlineAutofillEnabled, request);
|
||||
var disableSavePrompt = await _storageService.GetAsync<bool?>(Constants.AutofillDisableSavePromptKey);
|
||||
if (!disableSavePrompt.GetValueOrDefault())
|
||||
{
|
||||
AutofillHelpers.AddSaveInfo(parser, request, response, parser.FieldCollection);
|
||||
}
|
||||
callback.OnSuccess(response.Build());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !FDROID
|
||||
Crashes.TrackError(e);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public async override void OnSaveRequest(SaveRequest request, SaveCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var structure = request.FillContexts?.LastOrDefault()?.Structure;
|
||||
if (structure == null)
|
||||
|
@ -139,5 +159,12 @@ namespace Bit.Droid.Autofill
|
|||
}
|
||||
StartActivity(intent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !FDROID
|
||||
Crashes.TrackError(e);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue