Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore Android settings for Autofill, fixes #2449 #2494

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Kp2aAutofillParserTest/AutofillTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public void DetectsEmailAutofillHint()
var resourceName = "Kp2aAutofillParserTest.com-expressvpn-vpn-android13.json";
RunTestFromAutofillInput(resourceName, "com.expressvpn.vpn", null);
}
[Fact]
public void TestIgnoresAndroidSettings()
{
var resourceName = "Kp2aAutofillParserTest.android14-settings.json";
RunTestFromAutofillInput(resourceName, "com.android.settings", null);
}

private void RunTestFromAutofillInput(string resourceName, string expectedPackageName = null, string expectedWebDomain = null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>

<ItemGroup>
<None Remove="android14-settings.json" />
<None Remove="chrome-android10-amazon-it.json" />
<None Remove="com-expressvpn-vpn-android13.json" />
<None Remove="com-ifs-banking-fiid3364-android13.json" />
Expand Down Expand Up @@ -54,6 +55,9 @@
<EmbeddedResource Include="com-servicenet-mobile-no-focus.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="android14-settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="imdb.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
Expand Down
99 changes: 99 additions & 0 deletions src/Kp2aAutofillParserTest/android14-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"InputFields": [
{
"IdEntry": null,
"Hint": null,
"ClassName": "android.widget.FrameLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "content_parent",
"Hint": null,
"ClassName": "android.widget.LinearLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "content_frame",
"Hint": null,
"ClassName": "android.widget.FrameLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "main_content",
"Hint": null,
"ClassName": "android.widget.FrameLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "password_entry",
"Hint": null,
"ClassName": "android.widget.EditText",
"AutofillHints": [
"passwordAuto"
],
"IsFocused": true,
"InputType": 18,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null,
"ExpectedAssignedHints": [ "password" ]
},
{
"IdEntry": "checkbox",
"Hint": null,
"ClassName": "android.widget.CheckBox",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "button_bar",
"Hint": null,
"ClassName": "android.widget.RelativeLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "switch_bar",
"Hint": null,
"ClassName": "android.widget.LinearLayout",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
},
{
"IdEntry": "action_bar",
"Hint": null,
"ClassName": "android.view.ViewGroup",
"AutofillHints": null,
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null
}
],
"PackageId": "com.android.settings",
"WebDomain": null
}
22 changes: 21 additions & 1 deletion src/keepass2android/services/AutofillBase/AutofillServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ PendingIntent GetDisablePendingIntentForResponse(Context context, string query,

public abstract class AutofillServiceBase: AutofillService
{
private HashSet<string> _internal_blacklistedUris = null;

public HashSet<string> BlacklistedUris
{
get
{
if (_internal_blacklistedUris == null)
{
_internal_blacklistedUris = new HashSet<string>()
{
KeePass.AndroidAppScheme + "android",
KeePass.AndroidAppScheme + "com.android.settings",
KeePass.AndroidAppScheme + this.PackageName
};
}

return _internal_blacklistedUris;

}
}
protected override void AttachBaseContext(Context baseContext)
{
base.AttachBaseContext(LocaleManager.setLocale(baseContext));
Expand Down Expand Up @@ -386,7 +406,7 @@ private void AddDisableDataset(string query, AutofillId[] autofillIds, FillRespo

private bool CanAutofill(StructureParser.AutofillTargetId query, bool isManual)
{
if (query.PackageNameWithPseudoSchema == KeePass.AndroidAppScheme+"android" || query.PackageNameWithPseudoSchema == KeePass.AndroidAppScheme + this.PackageName)
if (BlacklistedUris.Contains(query.PackageNameWithPseudoSchema))
return false;
if (!isManual)
{
Expand Down
Loading