Merge "Change to drop down when the inline suggestions don't be shown in IME." into rvc-dev am: 5fa3f11717 am: fac896ec46
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12066145 Change-Id: I75a25b8fcfc345ff1b074d56acb12c3c0b6469c6
This commit is contained in:
@@ -149,6 +149,11 @@ class InlineSuggestionSession {
|
|||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
void invalidate() {
|
void invalidate() {
|
||||||
|
try {
|
||||||
|
mCallback.onInlineSuggestionsSessionInvalidated();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "onInlineSuggestionsSessionInvalidated() remote exception:" + e);
|
||||||
|
}
|
||||||
if (mResponseCallback != null) {
|
if (mResponseCallback != null) {
|
||||||
consumeInlineSuggestionsResponse(EMPTY_RESPONSE);
|
consumeInlineSuggestionsResponse(EMPTY_RESPONSE);
|
||||||
mResponseCallback.invalidate();
|
mResponseCallback.invalidate();
|
||||||
|
|||||||
@@ -58,4 +58,7 @@ oneway interface IInlineSuggestionsRequestCallback {
|
|||||||
// #onFinishInput()} is called on the field specified by the earlier
|
// #onFinishInput()} is called on the field specified by the earlier
|
||||||
// {@link #onInputMethodStartInput(AutofillId)}.
|
// {@link #onInputMethodStartInput(AutofillId)}.
|
||||||
void onInputMethodFinishInput();
|
void onInputMethodFinishInput();
|
||||||
|
|
||||||
|
// Indicates that the current IME changes inline suggestion session.
|
||||||
|
void onInlineSuggestionsSessionInvalidated();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
private boolean mDestroyed = false;
|
private boolean mDestroyed = false;
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private boolean mPreviousHasNonPinSuggestionShow;
|
private boolean mPreviousHasNonPinSuggestionShow;
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private boolean mImeSessionInvalidated = false;
|
||||||
|
|
||||||
AutofillInlineSuggestionsRequestSession(
|
AutofillInlineSuggestionsRequestSession(
|
||||||
@NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId,
|
@NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId,
|
||||||
@@ -157,7 +159,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
Slog.d(TAG,
|
Slog.d(TAG,
|
||||||
"onInlineSuggestionsResponseLocked called for:" + inlineFillUi.getAutofillId());
|
"onInlineSuggestionsResponseLocked called for:" + inlineFillUi.getAutofillId());
|
||||||
}
|
}
|
||||||
if (mImeRequest == null || mResponseCallback == null) {
|
if (mImeRequest == null || mResponseCallback == null || mImeSessionInvalidated) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO(b/151123764): each session should only correspond to one field.
|
// TODO(b/151123764): each session should only correspond to one field.
|
||||||
@@ -191,6 +193,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mImeSessionInvalidated = false;
|
||||||
if (sDebug) Slog.d(TAG, "onCreateInlineSuggestionsRequestLocked called: " + mAutofillId);
|
if (sDebug) Slog.d(TAG, "onCreateInlineSuggestionsRequestLocked called: " + mAutofillId);
|
||||||
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
||||||
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
||||||
@@ -291,6 +294,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mImeRequestReceived = true;
|
mImeRequestReceived = true;
|
||||||
|
mImeSessionInvalidated = false;
|
||||||
|
|
||||||
if (request != null && callback != null) {
|
if (request != null && callback != null) {
|
||||||
mImeRequest = request;
|
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
|
private static final class InlineSuggestionsRequestCallbackImpl extends
|
||||||
IInlineSuggestionsRequestCallback.Stub {
|
IInlineSuggestionsRequestCallback.Stub {
|
||||||
|
|
||||||
@@ -433,6 +451,18 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
session, false, false));
|
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,
|
private static boolean match(@Nullable AutofillId autofillId,
|
||||||
|
|||||||
@@ -2128,6 +2128,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
public void onInputMethodFinishInput() throws RemoteException {
|
public void onInputMethodFinishInput() throws RemoteException {
|
||||||
mCallback.onInputMethodFinishInput();
|
mCallback.onInputMethodFinishInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInlineSuggestionsSessionInvalidated() throws RemoteException {
|
||||||
|
mCallback.onInlineSuggestionsSessionInvalidated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user