diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index c9eb2d2a386f2..bf6964fcfcb37 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -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 (sVerbose) { - Slog.v(TAG, "ignoring autofilled change on id " + id); + 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); + } } - return; } + // Update the internal state... viewState.setState(ViewState.STATE_CHANGED); diff --git a/services/autofill/java/com/android/server/autofill/ViewState.java b/services/autofill/java/com/android/server/autofill/ViewState.java index e6cd7e0f6ebd2..a8dae03e4c125 100644 --- a/services/autofill/java/com/android/server/autofill/ViewState.java +++ b/services/autofill/java/com/android/server/autofill/ViewState.java @@ -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) {