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

Commit a484cbb0 authored by Adam He's avatar Adam He
Browse files

Show autofill picker again after user changed a field.

Change-Id: I28894dad6ba31ae7bc03dc1f45958355e41f50af
Fixes: 116008042
Test: atest android.autofillservice.cts.LoginActivityTest#testUiShowOnChangeAfterAutofill android.autofillservice.cts.LoginActivityTest#testUiShowOnChangeAfterAutofillOnePresentation
Test: atest CtsAutoFillServiceTestCases
parent d2b1a570
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -1206,7 +1206,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            // - not autofilled but matches a dataset value -> manuallyFilledIds
            if ((state & ViewState.STATE_CHANGED) != 0) {
                // Check if autofilled value was changed
                if ((state & ViewState.STATE_AUTOFILLED) != 0) {
                if ((state & ViewState.STATE_AUTOFILLED_ONCE) != 0) {
                    final String datasetId = viewState.getDatasetId();
                    if (datasetId == null) {
                        // Sanity check - should never happen.
@@ -2181,12 +2181,28 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    // Must check if this update was caused by autofilling the view, in which
                    // case we just update the value, but not the UI.
                    final AutofillValue filledValue = viewState.getAutofilledValue();
                    if (filledValue != null && filledValue.equals(value)) {
                    if (filledValue != null) {
                        if (filledValue.equals(value)) {
                            if (sVerbose) {
                                Slog.v(TAG, "ignoring autofilled change on id " + id);
                            }
                            viewState.resetState(ViewState.STATE_CHANGED);
                            return;
                        }
                        else {
                            if ((viewState.id.equals(this.mCurrentViewId)) &&
                                    (viewState.getState() & ViewState.STATE_AUTOFILLED) != 0) {
                                // Remove autofilled state once field is changed after autofilling.
                                if (sVerbose) {
                                    Slog.v(TAG, "field changed after autofill on id " + id);
                                }
                                viewState.resetState(ViewState.STATE_AUTOFILLED);
                                final ViewState currentView = mViewStates.get(mCurrentViewId);
                                currentView.maybeCallOnFillReady(flags);
                            }
                        }
                    }

                    // Update the internal state...
                    viewState.setState(ViewState.STATE_CHANGED);

+6 −1
Original line number Diff line number Diff line
@@ -69,8 +69,10 @@ final class ViewState {
    public static final int STATE_RESTARTED_SESSION = 0x100;
    /** View is the URL bar of a package on compat mode. */
    public  static final int STATE_URL_BAR = 0x200;
    /** View was asked to autofil but failed to do so. */
    /** View was asked to autofill but failed to do so. */
    public static final int STATE_AUTOFILL_FAILED = 0x400;
    /** View has been autofilled at least once. */
    public static final int STATE_AUTOFILLED_ONCE = 0x800;

    public final AutofillId id;

@@ -161,6 +163,9 @@ final class ViewState {
        } else {
            mState |= state;
        }
        if (state == STATE_AUTOFILLED) {
            mState |= STATE_AUTOFILLED_ONCE;
        }
    }

    void resetState(int state) {