summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpeter <lpeter@google.com>2020-07-02 14:39:45 +0800
committerAhaan Ugale <augale@google.com>2020-07-08 17:40:00 +0000
commita383f339de946f28b9e6cdbf072c839710241de5 (patch)
tree21dedc6c08657f4278c162cd4e5bc6e7e85ddb47
parentdb6e11150c16bc8d66c44940c445821cd1c19959 (diff)
Change to drop down when the inline suggestions don't be shown in IME.
The current implementation has a problem where: In the autofill side, there can be multiple autofill sessions existed at the same time. But in the IME side, there is always only one InlineSuggestionSession at any given time. It will cause the previous autofill session to fail communication with IME. It would better change to drop down UI when the autofill inline suggestions don't be shown in IME. How to reproduce this issue: To add an input field with autofillable into the authentication activity of InlineFillService. To tap on the input field of the authentication activity during the authentication flow. After completing the authentication, the inline suggestions won't be shown in IME. BTW, if the input field is marked as non-autofillable, this issue won't occur. Manual verification: 1.Tested this patch with InlineFillService and it worked well. 2.Feng also helped to test this patch with the webview (sort of randomly), and didn't find any broken case Bug: 158877106 Test: atest CtsInputMethodTestCases Test: atest CtsAutoFillServiceTestCases Test: new CTS test Ie1d9055b0eabfcaa00861869467be8dcee25833e Test: manual verification with InlineFillService Test: Feng also helped to test this patch with the webview Change-Id: Ib06edd823fa4478f34362164f3f7dd3544e51705
-rw-r--r--core/java/android/inputmethodservice/InlineSuggestionSession.java5
-rw-r--r--core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl3
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java32
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java5
4 files changed, 44 insertions, 1 deletions
diff --git a/core/java/android/inputmethodservice/InlineSuggestionSession.java b/core/java/android/inputmethodservice/InlineSuggestionSession.java
index 509cbe09df69..90d0ff0a5026 100644
--- a/core/java/android/inputmethodservice/InlineSuggestionSession.java
+++ b/core/java/android/inputmethodservice/InlineSuggestionSession.java
@@ -149,6 +149,11 @@ class InlineSuggestionSession {
*/
@MainThread
void invalidate() {
+ try {
+ mCallback.onInlineSuggestionsSessionInvalidated();
+ } catch (RemoteException e) {
+ Log.w(TAG, "onInlineSuggestionsSessionInvalidated() remote exception:" + e);
+ }
if (mResponseCallback != null) {
consumeInlineSuggestionsResponse(EMPTY_RESPONSE);
mResponseCallback.invalidate();
diff --git a/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl b/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl
index cf1220c08467..03948a92bcab 100644
--- a/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl
+++ b/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl
@@ -58,4 +58,7 @@ oneway interface IInlineSuggestionsRequestCallback {
// #onFinishInput()} is called on the field specified by the earlier
// {@link #onInputMethodStartInput(AutofillId)}.
void onInputMethodFinishInput();
+
+ // Indicates that the current IME changes inline suggestion session.
+ void onInlineSuggestionsSessionInvalidated();
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
index 68eeb0a3ca2e..b2daae48bb0e 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
@@ -103,6 +103,8 @@ final class AutofillInlineSuggestionsRequestSession {
private boolean mDestroyed = false;
@GuardedBy("mLock")
private boolean mPreviousHasNonPinSuggestionShow;
+ @GuardedBy("mLock")
+ private boolean mImeSessionInvalidated = false;
AutofillInlineSuggestionsRequestSession(
@NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId,
@@ -157,7 +159,7 @@ final class AutofillInlineSuggestionsRequestSession {
Slog.d(TAG,
"onInlineSuggestionsResponseLocked called for:" + inlineFillUi.getAutofillId());
}
- if (mImeRequest == null || mResponseCallback == null) {
+ if (mImeRequest == null || mResponseCallback == null || mImeSessionInvalidated) {
return false;
}
// TODO(b/151123764): each session should only correspond to one field.
@@ -191,6 +193,7 @@ final class AutofillInlineSuggestionsRequestSession {
if (mDestroyed) {
return;
}
+ mImeSessionInvalidated = false;
if (sDebug) Slog.d(TAG, "onCreateInlineSuggestionsRequestLocked called: " + mAutofillId);
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
@@ -291,6 +294,7 @@ final class AutofillInlineSuggestionsRequestSession {
return;
}
mImeRequestReceived = true;
+ mImeSessionInvalidated = false;
if (request != null && callback != null) {
mImeRequest = request;
@@ -346,6 +350,20 @@ final class AutofillInlineSuggestionsRequestSession {
}
}
+ /**
+ * Handles the IME session status received from the IME.
+ *
+ * <p> Should only be invoked in the {@link #mHandler} thread.
+ */
+ private void handleOnReceiveImeSessionInvalidated() {
+ synchronized (mLock) {
+ if (mDestroyed) {
+ return;
+ }
+ mImeSessionInvalidated = true;
+ }
+ }
+
private static final class InlineSuggestionsRequestCallbackImpl extends
IInlineSuggestionsRequestCallback.Stub {
@@ -433,6 +451,18 @@ final class AutofillInlineSuggestionsRequestSession {
session, false, false));
}
}
+
+ @BinderThread
+ @Override
+ public void onInlineSuggestionsSessionInvalidated() throws RemoteException {
+ if (sDebug) Slog.d(TAG, "onInlineSuggestionsSessionInvalidated() called.");
+ final AutofillInlineSuggestionsRequestSession session = mSession.get();
+ if (session != null) {
+ session.mHandler.sendMessage(obtainMessage(
+ AutofillInlineSuggestionsRequestSession
+ ::handleOnReceiveImeSessionInvalidated, session));
+ }
+ }
}
private static boolean match(@Nullable AutofillId autofillId,
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 15e8a92ba0e4..c027ebcfd568 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -2128,6 +2128,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
public void onInputMethodFinishInput() throws RemoteException {
mCallback.onInputMethodFinishInput();
}
+
+ @Override
+ public void onInlineSuggestionsSessionInvalidated() throws RemoteException {
+ mCallback.onInlineSuggestionsSessionInvalidated();
+ }
}
/**