1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-07 09:20:04 +01:00
This commit is contained in:
Kyle Spearrin 2018-02-08 17:27:56 -05:00
parent c71608824b
commit bcd210d504

View File

@ -156,31 +156,40 @@ namespace Bit.Android
}
else if(_appSettings.AutofillPasswordField && AutofillActivity.LastCredentials == null)
{
LogInfo("1");
if(string.IsNullOrWhiteSpace(_lastNotificationUri))
{
LogInfo("2");
CancelNotification(notificationManager);
break;
}
LogInfo("3");
var uri = GetUri(root);
LogInfo("4");
if(uri != _lastNotificationUri)
{
LogInfo("5");
CancelNotification(notificationManager);
}
else if(uri.StartsWith(App.Constants.AndroidAppProtocol))
{
LogInfo("6");
CancelNotification(notificationManager, 30000);
}
break;
}
LogInfo("7");
if(e.PackageName == BitwardenPackage)
{
LogInfo("8");
CancelNotification(notificationManager);
break;
}
LogInfo("9");
if(_appSettings.AutofillPersistNotification)
{
var uri = GetUri(root);
@ -214,11 +223,13 @@ namespace Bit.Android
}
else
{
LogInfo("10");
cancelNotification = ScanAndAutofill(root, e, notificationManager, cancelNotification);
}
if(cancelNotification)
{
LogInfo("11");
CancelNotification(notificationManager);
}
break;
@ -226,6 +237,7 @@ namespace Bit.Android
break;
}
LogInfo("12");
notificationManager?.Dispose();
root.Dispose();
e.Dispose();
@ -256,6 +268,7 @@ namespace Bit.Android
public bool ScanAndAutofill(AccessibilityNodeInfo root, AccessibilityEvent e,
NotificationManager notificationManager, bool cancelNotification)
{
LogInfo("13");
var passwordNodes = GetWindowNodes(root, e, n => n.Password, false);
if(passwordNodes.Count > 0)
{
@ -264,15 +277,18 @@ namespace Bit.Android
{
if(NeedToAutofill(AutofillActivity.LastCredentials, uri))
{
LogInfo("14");
var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false);
var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
FillCredentials(usernameEditText, passwordNodes);
LogInfo("15");
allEditTexts.Dispose();
usernameEditText.Dispose();
}
else
{
LogInfo("16");
NotifyToAutofill(uri, notificationManager);
cancelNotification = false;
}
@ -282,13 +298,17 @@ namespace Bit.Android
}
else if(AutofillActivity.LastCredentials != null)
{
LogInfo("17");
System.Threading.Tasks.Task.Run(async () =>
{
LogInfo("18");
await System.Threading.Tasks.Task.Delay(1000);
LogInfo("19");
AutofillActivity.LastCredentials = null;
});
}
LogInfo("20");
passwordNodes.Dispose();
return cancelNotification;
}