summaryrefslogtreecommitdiff
path: root/services/autofill
diff options
context:
space:
mode:
authorFeng Cao <fengcao@google.com>2020-05-20 19:36:15 -0700
committerFeng Cao <fengcao@google.com>2020-05-21 12:04:25 -0700
commit523dca0729e243849906d4a4b2fc1756ff4c8dda (patch)
treede4fc24e3b250f2b8b3e8e81c033a336f14d91d5 /services/autofill
parent093730bff1bac053075b1cc5cb5c12243c5098f4 (diff)
Fix a bug where autofill resends inline suggestions in the wrong app
* This is broken by ag/11443581 where we remove clearing the suggestions when view exit. The problem is that we cache the suggestions across onFinishInput/onStartInput events and resends the suggestions when autofill id matches. But the autofill id can be the same for different apps, so we ended up resending the old suggestion in the new app field with the same autofill id but doesn't have its own autofill suggestions. * The fix is to clear the suggestions cache in the autofill side, but to avoid flickering the IME UI we don't send an empty response to the IME when observing ACTION_VIEW_EXITED Test: atest android.autofillservice.cts.inline Bug: 157174936 Change-Id: I156eecab3cae0b0684f3c5f5e0f852bf73e93a19
Diffstat (limited to 'services/autofill')
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java16
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java10
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java3
3 files changed, 29 insertions, 0 deletions
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java
index 3dd2433ac2bd..23bb9d63d6fa 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java
@@ -127,6 +127,22 @@ final class AutofillInlineSessionController {
}
/**
+ * Clear the locally cached inline fill UI, but don't clear the suggestion in the IME.
+ *
+ * <p>This is called to invalid the locally cached inline suggestions so we don't resend them
+ * to the IME, while assuming that the IME will clean up suggestion on their own when the input
+ * connection is finished. We don't send an empty response to IME so that it doesn't cause UI
+ * flicker on the IME side if it arrives before the input view is finished on the IME.
+ */
+ @GuardedBy("mLock")
+ void resetInlineFillUiLocked() {
+ mInlineFillUi = null;
+ if (mSession != null) {
+ mSession.resetInlineFillUiLocked();
+ }
+ }
+
+ /**
* Updates the inline fill UI with the filter text. It'll send updated inline suggestions to
* the IME.
*/
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
index 1a3baba1ff19..687b75a8b949 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
@@ -191,6 +191,16 @@ final class AutofillInlineSuggestionsRequestSession {
}
/**
+ * Clear the locally cached inline fill UI, but don't clear the suggestion in IME.
+ *
+ * See also {@link AutofillInlineSessionController#resetInlineFillUiLocked()}
+ */
+ @GuardedBy("mLock")
+ void resetInlineFillUiLocked() {
+ mInlineFillUi = null;
+ }
+
+ /**
* Optionally sends inline response to the IME, depending on the current state.
*/
@GuardedBy("mLock")
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 1d3ab9b7e24b..558acfa3ed19 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -2581,6 +2581,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (sVerbose) Slog.v(TAG, "Exiting view " + id);
mUi.hideFillUi(this);
hideAugmentedAutofillLocked(viewState);
+ // We don't send an empty response to IME so that it doesn't cause UI flicker
+ // on the IME side if it arrives before the input view is finished on the IME.
+ mInlineSessionController.resetInlineFillUiLocked();
mCurrentViewId = null;
}
break;