diff options
| -rw-r--r-- | core/java/android/view/autofill/AutofillFeatureFlags.java | 19 | ||||
| -rw-r--r-- | core/java/android/view/autofill/AutofillManager.java | 27 |
2 files changed, 44 insertions, 2 deletions
diff --git a/core/java/android/view/autofill/AutofillFeatureFlags.java b/core/java/android/view/autofill/AutofillFeatureFlags.java index 4aa612c526fe..951eeccf4d8a 100644 --- a/core/java/android/view/autofill/AutofillFeatureFlags.java +++ b/core/java/android/view/autofill/AutofillFeatureFlags.java @@ -194,6 +194,14 @@ public class AutofillFeatureFlags { "should_enable_autofill_on_all_view_types"; /** + * Whether to enable multi-line filter when checking if view is autofillable + * + * @hide + */ + public static final String DEVICE_CONFIG_MULTILINE_FILTER_ENABLED = + "multiline_filter_enabled"; + + /** * Whether include all autofill type not none views in assist structure * * @hide @@ -439,6 +447,17 @@ public class AutofillFeatureFlags { } + /** + * Whether should enable multi-line filter + * + * @hide + */ + public static boolean shouldEnableMultilineFilter() { + return DeviceConfig.getBoolean( + DeviceConfig.NAMESPACE_AUTOFILL, + DEVICE_CONFIG_MULTILINE_FILTER_ENABLED, false); + } + // START AUTOFILL PCC CLASSIFICATION FUNCTIONS /** diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index 801b13a2c69c..f7b7d3387938 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -707,6 +707,9 @@ public final class AutofillManager { // An allowed activity set read from device config private Set<String> mAllowedActivitySet = new ArraySet<>(); + // Whether to enable multi-line check when checking whether view is autofillable + private boolean mShouldEnableMultilineFilter; + // Indicate whether should include all view with autofill type not none in assist structure private boolean mShouldIncludeAllViewsWithAutofillTypeNotNoneInAssistStructure; @@ -889,6 +892,9 @@ public final class AutofillManager { mNonAutofillableImeActionIdSet = AutofillFeatureFlags.getNonAutofillableImeActionIdSetFromFlag(); + mShouldEnableMultilineFilter = + AutofillFeatureFlags.shouldEnableMultilineFilter(); + final String denyListString = AutofillFeatureFlags.getDenylistStringFromFlag(); final String allowlistString = AutofillFeatureFlags.getAllowlistStringFromFlag(); @@ -948,9 +954,8 @@ public final class AutofillManager { /** * Whether view passes the imeAction check * - * @hide */ - public boolean isPassingImeActionCheck(EditText editText) { + private boolean isPassingImeActionCheck(EditText editText) { final int actionId = editText.getImeOptions(); if (mNonAutofillableImeActionIdSet.contains(String.valueOf(actionId))) { Log.d(TAG, "view not autofillable - not passing ime action check"); @@ -959,6 +964,21 @@ public final class AutofillManager { return true; } + /** + * Checks whether the view passed in is not multiline text + * + * @param editText the view that passed to this check + * @return true if the view input is not multiline, false otherwise + */ + private boolean isPassingMultilineCheck(EditText editText) { + // check if min line is set to be greater than 1 + if (editText.getMinLines() > 1) { + Log.d(TAG, "view not autofillable - has multiline input type"); + return false; + } + return true; + } + private boolean isPackageFullyAllowedOrDeniedForAutofill( @NonNull String listString, @NonNull String packageName) { // If "PackageName:;" is in the string, then it the package is fully denied or allowed for @@ -1103,6 +1123,9 @@ public final class AutofillManager { } if (view instanceof EditText) { + if (mShouldEnableMultilineFilter && !isPassingMultilineCheck((EditText) view)) { + return false; + } return isPassingImeActionCheck((EditText) view); } |