set package and website independently

This commit is contained in:
Kyle Spearrin 2018-01-26 12:15:54 -05:00
parent 8847991bba
commit 4dd6df5bbe

View file

@ -17,6 +17,11 @@ namespace Bit.Android.Autofill
"com.amazon.cloud9","org.mozilla.klar", "com.duckduckgo.mobile.android" "com.amazon.cloud9","org.mozilla.klar", "com.duckduckgo.mobile.android"
}; };
public static HashSet<string> ExcludedPackageIds = new HashSet<string>
{
"android"
};
private readonly AssistStructure _structure; private readonly AssistStructure _structure;
private string _uri; private string _uri;
private string _packageName; private string _packageName;
@ -96,28 +101,15 @@ namespace Bit.Android.Autofill
private void ParseNode(ViewNode node) private void ParseNode(ViewNode node)
{ {
SetPackageAndDomain(node);
var hints = node.GetAutofillHints(); var hints = node.GetAutofillHints();
var isEditText = node.ClassName == "android.widget.EditText" || node?.HtmlInfo?.Tag == "input"; var isEditText = node.ClassName == "android.widget.EditText" || node?.HtmlInfo?.Tag == "input";
if(isEditText || (hints?.Length ?? 0) > 0) if(isEditText || (hints?.Length ?? 0) > 0)
{ {
if(string.IsNullOrWhiteSpace(PackageName))
{
PackageName = node.IdPackage;
}
if(string.IsNullOrWhiteSpace(WebDomain))
{
WebDomain = node.WebDomain;
}
FieldCollection.Add(new Field(node)); FieldCollection.Add(new Field(node));
} }
else else
{ {
if(string.IsNullOrWhiteSpace(WebDomain))
{
WebDomain = node.WebDomain;
}
FieldCollection.IgnoreAutofillIds.Add(node.AutofillId); FieldCollection.IgnoreAutofillIds.Add(node.AutofillId);
} }
@ -126,5 +118,18 @@ namespace Bit.Android.Autofill
ParseNode(node.GetChildAt(i)); ParseNode(node.GetChildAt(i));
} }
} }
private void SetPackageAndDomain(ViewNode node)
{
if(string.IsNullOrWhiteSpace(PackageName) && !string.IsNullOrWhiteSpace(node.IdPackage) &&
!ExcludedPackageIds.Contains(node.IdPackage))
{
PackageName = node.IdPackage;
}
if(string.IsNullOrWhiteSpace(WebDomain) && !string.IsNullOrWhiteSpace(node.WebDomain))
{
WebDomain = node.WebDomain;
}
}
} }
} }