Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2aedac13 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Do not filter non text values.

Test: Ran CTS autofill tests
Bug: 36123241
Change-Id: I747b516c3ec924487523756f075989ff94d97ab4
parent 9b31b4ea
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -89,11 +89,6 @@ public final class AutoFillValue implements Parcelable {
        return mRealValue.equals(other.mRealValue);
    }

    /** @hide */
    public String coerceToString() {
        return mRealValue.coerceToString();
    }

    @Override
    public String toString() {
        if (!DEBUG) return super.toString();
+0 −6
Original line number Diff line number Diff line
@@ -157,12 +157,6 @@ public final class AutofillValue implements Parcelable {
        }
    }

    /** @hide */
    public String coerceToString() {
        // TODO(b/33197203): How can we filter on toggles or list values?
        return mValue.toString();
    }

    @Override
    public String toString() {
        if (!DEBUG) return super.toString();
+8 −9
Original line number Diff line number Diff line
@@ -914,7 +914,11 @@ final class AutofillManagerServiceImpl {
                    viewState.mAutofillValue = value;

                    // Update the chooser UI
                    getUiForShowing().filterFillUi(value.coerceToString());
                    if (value.isText()) {
                        getUiForShowing().filterFillUi(value.getTextValue().toString());
                    } else {
                        getUiForShowing().filterFillUi(null);
                    }
                }

                return;
@@ -952,14 +956,9 @@ final class AutofillManagerServiceImpl {
        @Override
        public void onFillReady(ViewState viewState, FillResponse response, Rect bounds,
                AutofillId filledId, @Nullable AutofillValue value) {
            String filterText = "";
            if (value != null) {
                // TODO(b/33197203): Handle other AutofillValue types
                if (value.isText()) {
            String filterText = null;
            if (value != null && value.isText()) {
                filterText = value.getTextValue().toString();
                } else {
                    Log.w(TAG, value + " could not be autofilled into " + this);
                }
            }

            getUiForShowing().showFillUi(filledId, response, bounds, filterText);
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public final class AutoFillUI {
            }
            hideSaveUiUiThread();
            if (mFillUi != null) {
                mFillUi.filter(filterText);
                mFillUi.setFilterText(filterText);
            }
        });
    }
+37 −14
Original line number Diff line number Diff line
@@ -113,8 +113,13 @@ final class FillUi {
                        Slog.e(TAG, "Error inflating remote views", e);
                        continue;
                    }
                    items.add(new ViewItem(dataset, value.coerceToString()
                            .toLowerCase(), view));

                    String valueText = null;
                    if (value.isText()) {
                        valueText = value.getTextValue().toString().toLowerCase();
                    }

                    items.add(new ViewItem(dataset, valueText, view));
                }
            }

@@ -134,7 +139,13 @@ final class FillUi {
                mCallback.onDatasetPicked(vi.getDataset());
            });

            filter(filterText);
            if (filterText == null) {
                mFilterText = null;
            } else {
                mFilterText = filterText.toLowerCase();
            }

            applyNewFilterText();
            mWindow = new AnchoredWindow(windowToken, mListView);
        }
    }
@@ -147,16 +158,8 @@ final class FillUi {
        }
    }

    public void filter(@Nullable String filterText) {
        throwIfDestroyed();
        if (mAdapter == null) {
            return;
        }
        if (Objects.equal(mFilterText, filterText)) {
            return;
        }
        mFilterText = filterText;
        mAdapter.getFilter().filter(filterText, (count) -> {
    private void applyNewFilterText() {
        mAdapter.getFilter().filter(mFilterText, (count) -> {
            if (mDestroyed) {
                return;
            }
@@ -176,6 +179,26 @@ final class FillUi {
        });
    }

    public void setFilterText(@Nullable String filterText) {
        throwIfDestroyed();
        if (mAdapter == null) {
            return;
        }

        if (filterText == null) {
            filterText = null;
        } else {
            filterText = filterText.toLowerCase();
        }

        if (Objects.equal(mFilterText, filterText)) {
            return;
        }
        mFilterText = filterText;

        applyNewFilterText();
    }

    public void destroy() {
        throwIfDestroyed();
        mWindow.hide();
@@ -235,7 +258,7 @@ final class FillUi {

        ViewItem(Dataset dataset, String value, View view) {
            mDataset = dataset;
            mValue = value.toLowerCase();
            mValue = value;
            mView = view;
        }