From e651a13980ed638521f8975b1eb56da18c5191fe Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 30 May 2017 08:18:56 -0400 Subject: [PATCH] compare with _lastNotificationUri --- src/Android/AutofillService.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 2d88d5f85..47ef24f55 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -56,7 +56,8 @@ namespace Bit.Android }.ToDictionary(n => n.PackageName); private readonly IAppSettingsService _appSettings; - private long _lastNotification = 0; + private long _lastNotificationTime = 0; + private string _lastNotificationUri = null; public AutofillService() { @@ -110,8 +111,18 @@ namespace Bit.Android } else if(_appSettings.AutofillPasswordField && AutofillActivity.LastCredentials == null) { - CancelNotification(notificationManager); - break; + if(string.IsNullOrWhiteSpace(_lastNotificationUri)) + { + CancelNotification(notificationManager); + break; + } + + var uri = GetUri(root); + if(uri != _lastNotificationUri) + { + CancelNotification(notificationManager); + break; + } } if(e.PackageName == BitwardenPackage) @@ -138,8 +149,8 @@ namespace Bit.Android allEditTexts.Dispose(); usernameEditText.Dispose(); - passwordNodes.Dispose(); } + passwordNodes.Dispose(); } if(!needToFill) @@ -211,11 +222,12 @@ namespace Bit.Android public void CancelNotification(NotificationManager notificationManager) { - if(Java.Lang.JavaSystem.CurrentTimeMillis() - _lastNotification < 250) + if(Java.Lang.JavaSystem.CurrentTimeMillis() - _lastNotificationTime < 250) { return; } + _lastNotificationUri = null; notificationManager?.Cancel(AutoFillNotificationId); } @@ -324,7 +336,8 @@ namespace Bit.Android builder.SetPriority(-1); } - _lastNotification = now; + _lastNotificationTime = now; + _lastNotificationUri = uri; notificationManager.Notify(AutoFillNotificationId, builder.Build()); builder.Dispose();