Merge "AF: Remove the timeout for receiving InlineSuggestionsRequest from IME" into rvc-dev am: 2ec1d707fa
Change-Id: I382868b9f0dd78b02f90579b161964cbb0e11c7c
This commit is contained in:
@@ -67,8 +67,8 @@ final class AutofillInlineSessionController {
|
|||||||
* Requests the IME to create an {@link InlineSuggestionsRequest} for {@code autofillId}.
|
* Requests the IME to create an {@link InlineSuggestionsRequest} for {@code autofillId}.
|
||||||
*
|
*
|
||||||
* @param autofillId the Id of the field for which the request is for.
|
* @param autofillId the Id of the field for which the request is for.
|
||||||
* @param requestConsumer the callback which will be invoked when IME responded or if it times
|
* @param requestConsumer the callback to be invoked when the IME responds. Note that this is
|
||||||
* out waiting for IME response.
|
* never invoked if the IME doesn't respond.
|
||||||
*/
|
*/
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
void onCreateInlineSuggestionsRequestLocked(@NonNull AutofillId autofillId,
|
void onCreateInlineSuggestionsRequestLocked(@NonNull AutofillId autofillId,
|
||||||
|
|||||||
@@ -55,16 +55,6 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
|
|
||||||
private static final String TAG = AutofillInlineSuggestionsRequestSession.class.getSimpleName();
|
private static final String TAG = AutofillInlineSuggestionsRequestSession.class.getSimpleName();
|
||||||
|
|
||||||
// This timeout controls how long Autofill should wait for the IME to respond either
|
|
||||||
// unsupported or an {@link InlineSuggestionsRequest}. The timeout is needed to take into
|
|
||||||
// account the latency between the two events after a field is focused, 1) an Autofill
|
|
||||||
// request is triggered on framework; 2) the InputMethodService#onStartInput() event is
|
|
||||||
// triggered on the IME side. When 1) happens, Autofill may call the IME to return an {@link
|
|
||||||
// InlineSuggestionsRequest}, but the IME will only return it after 2) happens (or return
|
|
||||||
// immediately if the IME doesn't support inline suggestions). Also there is IPC latency
|
|
||||||
// between the framework and the IME but that should be small compare to that.
|
|
||||||
private static final int CREATE_INLINE_SUGGESTIONS_REQUEST_TIMEOUT_MS = 1000;
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final InputMethodManagerInternal mInputMethodManagerInternal;
|
private final InputMethodManagerInternal mInputMethodManagerInternal;
|
||||||
private final int mUserId;
|
private final int mUserId;
|
||||||
@@ -92,9 +82,6 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@Nullable
|
@Nullable
|
||||||
private IInlineSuggestionsResponseCallback mResponseCallback;
|
private IInlineSuggestionsResponseCallback mResponseCallback;
|
||||||
@GuardedBy("mLock")
|
|
||||||
@Nullable
|
|
||||||
private Runnable mTimeoutCallback;
|
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -174,12 +161,17 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method must be called when the session is destroyed, to avoid further callbacks from/to
|
* Prevents further interaction with the IME. Must be called before starting a new request
|
||||||
* the IME.
|
* session to avoid unwanted behavior from two overlapping requests.
|
||||||
*/
|
*/
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
void destroySessionLocked() {
|
void destroySessionLocked() {
|
||||||
mDestroyed = true;
|
mDestroyed = true;
|
||||||
|
|
||||||
|
if (!mImeRequestReceived) {
|
||||||
|
Slog.w(TAG,
|
||||||
|
"Never received an InlineSuggestionsRequest from the IME for " + mAutofillId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,11 +188,6 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
||||||
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
||||||
new InlineSuggestionsRequestCallbackImpl(this));
|
new InlineSuggestionsRequestCallbackImpl(this));
|
||||||
mTimeoutCallback = () -> {
|
|
||||||
Slog.w(TAG, "Timed out waiting for IME callback InlineSuggestionsRequest.");
|
|
||||||
handleOnReceiveImeRequest(null, null);
|
|
||||||
};
|
|
||||||
mHandler.postDelayed(mTimeoutCallback, CREATE_INLINE_SUGGESTIONS_REQUEST_TIMEOUT_MS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,11 +251,6 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
}
|
}
|
||||||
mImeRequestReceived = true;
|
mImeRequestReceived = true;
|
||||||
|
|
||||||
if (mTimeoutCallback != null) {
|
|
||||||
if (sVerbose) Slog.v(TAG, "removing timeout callback");
|
|
||||||
mHandler.removeCallbacks(mTimeoutCallback);
|
|
||||||
mTimeoutCallback = null;
|
|
||||||
}
|
|
||||||
if (request != null && callback != null) {
|
if (request != null && callback != null) {
|
||||||
mImeRequest = request;
|
mImeRequest = request;
|
||||||
mResponseCallback = callback;
|
mResponseCallback = callback;
|
||||||
|
|||||||
Reference in New Issue
Block a user