From 67fa653d060edc366bbf733e623db3171ab098ce Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 16 Jul 2018 10:07:22 -0400 Subject: [PATCH] prevent multiple main activities from autofill --- src/Android/AutofillActivity.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Android/AutofillActivity.cs b/src/Android/AutofillActivity.cs index 0c4a6c062..92e090ce7 100644 --- a/src/Android/AutofillActivity.cs +++ b/src/Android/AutofillActivity.cs @@ -3,12 +3,16 @@ using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; +using System; namespace Bit.Android { [Activity(Theme = "@style/BitwardenTheme.Splash", WindowSoftInputMode = SoftInput.StateHidden)] public class AutofillActivity : Activity { + private static TimeSpan _retrySpan = TimeSpan.FromSeconds(2); + + private DateTime? _lastLaunch = null; private string _lastQueriedUri; public static AutofillCredentials LastCredentials { get; set; } @@ -83,6 +87,13 @@ namespace Bit.Android private void LaunchMainActivity(Intent callingIntent, int requestCode) { + var now = DateTime.UtcNow; + if(_lastLaunch.HasValue && (now - _lastLaunch.Value <= _retrySpan)) + { + return; + } + + _lastLaunch = now; _lastQueriedUri = callingIntent?.GetStringExtra("uri"); if(_lastQueriedUri == null) {