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