diff options
3 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java index d04ff8e361b3..115894f586f2 100644 --- a/core/java/android/service/autofill/Dataset.java +++ b/core/java/android/service/autofill/Dataset.java @@ -115,6 +115,8 @@ import java.util.regex.Pattern; * with the lower case value of the view's text are shown. * <li>All other datasets are hidden. * </ol> + * <p>Note: If user enters four or more characters, all datasets will be hidden</p> + * */ public final class Dataset implements Parcelable { /** diff --git a/services/autofill/java/com/android/server/autofill/ui/FillUi.java b/services/autofill/java/com/android/server/autofill/ui/FillUi.java index cdd9ef4e1a76..0a8fe62a6617 100644 --- a/services/autofill/java/com/android/server/autofill/ui/FillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/FillUi.java @@ -426,12 +426,18 @@ final class FillUi { if (mDestroyed) { return; } + final int size = mFilterText == null ? 0 : mFilterText.length(); if (count <= 0) { if (sDebug) { - final int size = mFilterText == null ? 0 : mFilterText.length(); Slog.d(TAG, "No dataset matches filter with " + size + " chars"); } mCallback.requestHideFillUi(); + } else if (size > 3) { + // Do not show suggestion if user entered four or more characters + if (sDebug) { + Slog.d(TAG, "Not showing fill UI because user entered more than 3 characters"); + } + mCallback.requestHideFillUi(); } else { if (updateContentSize()) { requestShowFillUi(); diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java b/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java index ac8d962c8eaa..24eab0b78c86 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java @@ -216,6 +216,16 @@ public final class InlineFillUi { } return new InlineSuggestionsResponse(inlineSuggestions); } + + // Do not show suggestion if user entered four or more characters + if (!TextUtils.isEmpty(mFilterText) && mFilterText.length() > 3) { + if (sVerbose) { + Slog.v(TAG, "Not showing inline suggestion because user entered more than 3 " + + "characters"); + } + return new InlineSuggestionsResponse(inlineSuggestions); + } + for (int i = 0; i < size; i++) { final Dataset dataset = mDatasets.get(i); final int fieldIndex = dataset.getFieldIds().indexOf(mAutofillId); |