diff options
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/Session.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index c4e8f12b72f5..d71258a564f2 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -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; |