diff --git a/src/Kp2aAutofillParserTest/AutofillTest.cs b/src/Kp2aAutofillParserTest/AutofillTest.cs index 80c15003c..2c9c2a7e8 100644 --- a/src/Kp2aAutofillParserTest/AutofillTest.cs +++ b/src/Kp2aAutofillParserTest/AutofillTest.cs @@ -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) { diff --git a/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj b/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj index d702da419..d68279ffb 100644 --- a/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj +++ b/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj @@ -9,6 +9,7 @@ + @@ -54,6 +55,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/Kp2aAutofillParserTest/android14-settings.json b/src/Kp2aAutofillParserTest/android14-settings.json new file mode 100644 index 000000000..038c0c555 --- /dev/null +++ b/src/Kp2aAutofillParserTest/android14-settings.json @@ -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 +} \ No newline at end of file diff --git a/src/keepass2android/services/AutofillBase/AutofillServiceBase.cs b/src/keepass2android/services/AutofillBase/AutofillServiceBase.cs index ccdb86d8b..0eaf278cb 100644 --- a/src/keepass2android/services/AutofillBase/AutofillServiceBase.cs +++ b/src/keepass2android/services/AutofillBase/AutofillServiceBase.cs @@ -40,6 +40,26 @@ PendingIntent GetDisablePendingIntentForResponse(Context context, string query, public abstract class AutofillServiceBase: AutofillService { + private HashSet _internal_blacklistedUris = null; + + public HashSet BlacklistedUris + { + get + { + if (_internal_blacklistedUris == null) + { + _internal_blacklistedUris = new HashSet() + { + 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)); @@ -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) {