summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeng Cao <fengcao@google.com>2020-06-07 16:15:42 -0700
committerFeng Cao <fengcao@google.com>2020-06-07 16:17:40 -0700
commit1e0e1238e0c25ceb797fc05040e37393843d2a79 (patch)
treef0988559f87575eaab9815980dc2dd2684c3f476
parent8083336a8897437f8290de43d30e7fb1b62e9fda (diff)
Send empty inline response to IME if augmented autofill returns no suggestion
* The augmented autofill may dynamically request an autofill request which will "invalidate" the old suggestions. In case the new request doesn't return any suggestions, we need to make sure the old suggestions are removed from the IME. * See the scenario in https://b.corp.google.com/issues/158038231#comment14 Test: manual Test: atest android.autofillservice.cts.inline Bug: 157515522 Bug: 158038231 Change-Id: If85592395ad918197566a5ca556fba8ccc971071
-rw-r--r--core/java/android/service/autofill/augmented/FillCallback.java3
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java4
-rw-r--r--services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java5
3 files changed, 9 insertions, 3 deletions
diff --git a/core/java/android/service/autofill/augmented/FillCallback.java b/core/java/android/service/autofill/augmented/FillCallback.java
index 21738d80f2d3..8ba5c173890c 100644
--- a/core/java/android/service/autofill/augmented/FillCallback.java
+++ b/core/java/android/service/autofill/augmented/FillCallback.java
@@ -62,9 +62,10 @@ public final class FillCallback {
List<Dataset> inlineSuggestions = response.getInlineSuggestions();
Bundle clientState = response.getClientState();
+ // We need to report result regardless of whether inline suggestions are returned or not.
+ mProxy.reportResult(inlineSuggestions, clientState);
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE);
- mProxy.reportResult(inlineSuggestions, clientState);
return;
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
index e7a43b75f9d5..48895ad42e99 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
@@ -93,7 +93,7 @@ final class AutofillInlineSuggestionsRequestSession {
@Nullable
private InlineFillUi mInlineFillUi;
@GuardedBy("mLock")
- private boolean mPreviousResponseIsNotEmpty;
+ private Boolean mPreviousResponseIsNotEmpty = null;
@GuardedBy("mLock")
private boolean mDestroyed = false;
@@ -213,7 +213,7 @@ final class AutofillInlineSuggestionsRequestSession {
// if IME is visible, and response is not null, send the response
InlineSuggestionsResponse response = mInlineFillUi.getInlineSuggestionsResponse();
boolean isEmptyResponse = response.getInlineSuggestions().isEmpty();
- if (isEmptyResponse && !mPreviousResponseIsNotEmpty) {
+ if (isEmptyResponse && Boolean.FALSE.equals(mPreviousResponseIsNotEmpty)) {
// No-op if both the previous response and current response are empty.
return;
}
diff --git a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java
index 851e4cc0bfd1..a7d0061cc043 100644
--- a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java
+++ b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java
@@ -245,6 +245,11 @@ final class RemoteAugmentedAutofillService
if (inlineSuggestionsData == null || inlineSuggestionsData.isEmpty()
|| inlineSuggestionsCallback == null || request == null
|| remoteRenderService == null) {
+ // If it was an inline request and the response doesn't have any inline suggestions,
+ // we will send an empty response to IME.
+ if (inlineSuggestionsCallback != null && request != null) {
+ inlineSuggestionsCallback.apply(InlineFillUi.emptyUi(focusedId));
+ }
return;
}
mCallbacks.setLastResponse(sessionId);