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

Commit ce31eaf8 authored by Joy Babafemi's avatar Joy Babafemi Committed by Android (Google) Code Review
Browse files

Merge "Ignore updating autofill view state to empty if previous value has length > 1" into main

parents f5e37373 76bab27c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ import android.service.autofill.FillEventHistory.Event;
import android.service.autofill.FillEventHistory.Event.NoSaveReason;
import android.service.autofill.FillRequest;
import android.service.autofill.FillResponse;
import android.service.autofill.Flags;
import android.service.autofill.InlinePresentation;
import android.service.autofill.InternalSanitizer;
import android.service.autofill.InternalValidator;
@@ -579,6 +580,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    @GuardedBy("mLock")
    private AutofillId[] mLastFillDialogTriggerIds;

    private boolean mIgnoreViewStateResetToEmpty;

    void onSwitchInputMethodLocked() {
        // One caveat is that for the case where the focus is on a field for which regular autofill
        // returns null, and augmented autofill is triggered,  and then the user switches the input
@@ -1441,6 +1444,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        mSessionCommittedEventLogger.maybeSetComponentPackageUid(uid);
        mSaveEventLogger = SaveEventLogger.forSessionId(sessionId);
        mIsPrimaryCredential = isPrimaryCredential;
        mIgnoreViewStateResetToEmpty = Flags.ignoreViewStateResetToEmpty();

        synchronized (mLock) {
            mSessionFlags = new SessionFlags();
@@ -4419,6 +4423,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    @GuardedBy("mLock")
    private void updateViewStateAndUiOnValueChangedLocked(AutofillId id, AutofillValue value,
            ViewState viewState, int flags) {
        if (mIgnoreViewStateResetToEmpty && (value == null || value.isEmpty())
                && viewState.getCurrentValue() != null && viewState.getCurrentValue().isText()
                && viewState.getCurrentValue().getTextValue() != null
                && viewState.getCurrentValue().getTextValue().length() > 1) {
            if (sVerbose) {
                Slog.v(TAG, "Ignoring view state reset to empty on id " + id);
            }
            return;
        }
        final String textValue;
        if (value == null || !value.isText()) {
            textValue = null;