1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-10-27 07:29:42 +01:00

Skip event if no package name

This commit is contained in:
Kyle Spearrin 2017-02-08 18:19:59 -05:00
parent a418fc810a
commit 0131031ac4

View File

@ -53,31 +53,29 @@ namespace Bit.Android
public override void OnAccessibilityEvent(AccessibilityEvent e) public override void OnAccessibilityEvent(AccessibilityEvent e)
{ {
Enabled = true; Enabled = true;
var root = RootInActiveWindow;
var eventType = e.EventType; if(string.IsNullOrWhiteSpace(e.PackageName) || e.PackageName == SystemUiPackage ||
var packageName = e.PackageName; root?.PackageName != e.PackageName)
if(packageName == SystemUiPackage)
{ {
return; return;
} }
switch(eventType) switch(e.EventType)
{ {
case EventTypes.WindowContentChanged: case EventTypes.WindowContentChanged:
case EventTypes.WindowStateChanged: case EventTypes.WindowStateChanged:
if(packageName == BitwardenPackage) var cancelNotification = true;
if(e.PackageName == BitwardenPackage)
{ {
CancelNotification(); CancelNotification();
break; break;
} }
var cancelNotification = true; var passwordNodes = GetWindowNodes(root, e, n => n.Password);
var passwordNodes = GetWindowNodes(RootInActiveWindow, e, n => n.Password);
if(passwordNodes.Any()) if(passwordNodes.Any())
{ {
var uri = GetUri(RootInActiveWindow); var uri = GetUri(root);
if(uri.Contains(BitwardenWebsite)) if(uri.Contains(BitwardenWebsite))
{ {
break; break;
@ -85,7 +83,7 @@ namespace Bit.Android
if(NeedToAutofill(AutofillActivity.LastCredentials, uri)) if(NeedToAutofill(AutofillActivity.LastCredentials, uri))
{ {
var allEditTexts = GetWindowNodes(RootInActiveWindow, e, n => EditText(n)); var allEditTexts = GetWindowNodes(root, e, n => EditText(n));
var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault(); var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
FillCredentials(usernameEditText, passwordNodes); FillCredentials(usernameEditText, passwordNodes);
} }