Merge "Increase the timeout that autofill waits for IME callback inline request" into rvc-dev am: ff9701f948
Change-Id: I973aec0a0012d941a78ab45ec1e6304d617a2c02
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.server.autofill;
|
|||||||
|
|
||||||
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
||||||
import static com.android.server.autofill.Helper.sDebug;
|
import static com.android.server.autofill.Helper.sDebug;
|
||||||
|
import static com.android.server.autofill.Helper.sVerbose;
|
||||||
|
|
||||||
import android.annotation.BinderThread;
|
import android.annotation.BinderThread;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -53,7 +54,16 @@ import java.util.function.Consumer;
|
|||||||
final class AutofillInlineSuggestionsRequestSession {
|
final class AutofillInlineSuggestionsRequestSession {
|
||||||
|
|
||||||
private static final String TAG = AutofillInlineSuggestionsRequestSession.class.getSimpleName();
|
private static final String TAG = AutofillInlineSuggestionsRequestSession.class.getSimpleName();
|
||||||
private static final int INLINE_REQUEST_TIMEOUT_MS = 200;
|
|
||||||
|
// 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;
|
||||||
@@ -177,10 +187,10 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
*/
|
*/
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
void onCreateInlineSuggestionsRequestLocked() {
|
void onCreateInlineSuggestionsRequestLocked() {
|
||||||
if (sDebug) Log.d(TAG, "onCreateInlineSuggestionsRequestLocked called: " + mAutofillId);
|
|
||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (sDebug) Log.d(TAG, "onCreateInlineSuggestionsRequestLocked called: " + mAutofillId);
|
||||||
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
mInputMethodManagerInternal.onCreateInlineSuggestionsRequest(mUserId,
|
||||||
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
new InlineSuggestionsRequestInfo(mComponentName, mAutofillId, mUiExtras),
|
||||||
new InlineSuggestionsRequestCallbackImpl(this));
|
new InlineSuggestionsRequestCallbackImpl(this));
|
||||||
@@ -188,7 +198,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
Log.w(TAG, "Timed out waiting for IME callback InlineSuggestionsRequest.");
|
Log.w(TAG, "Timed out waiting for IME callback InlineSuggestionsRequest.");
|
||||||
handleOnReceiveImeRequest(null, null);
|
handleOnReceiveImeRequest(null, null);
|
||||||
};
|
};
|
||||||
mHandler.postDelayed(mTimeoutCallback, INLINE_REQUEST_TIMEOUT_MS);
|
mHandler.postDelayed(mTimeoutCallback, CREATE_INLINE_SUGGESTIONS_REQUEST_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,7 +206,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
*/
|
*/
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void maybeUpdateResponseToImeLocked() {
|
private void maybeUpdateResponseToImeLocked() {
|
||||||
if (sDebug) Log.d(TAG, "maybeUpdateResponseToImeLocked called");
|
if (sVerbose) Log.v(TAG, "maybeUpdateResponseToImeLocked called");
|
||||||
if (mDestroyed || mResponseCallback == null) {
|
if (mDestroyed || mResponseCallback == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -206,7 +216,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
// Although the inline suggestions should disappear when IME hides which removes them
|
// Although the inline suggestions should disappear when IME hides which removes them
|
||||||
// from the view hierarchy, but we still send an empty response to be extra safe.
|
// from the view hierarchy, but we still send an empty response to be extra safe.
|
||||||
|
|
||||||
if (sDebug) Log.d(TAG, "Send empty inline response");
|
if (sVerbose) Log.v(TAG, "Send empty inline response");
|
||||||
updateResponseToImeUncheckLocked(new InlineSuggestionsResponse(Collections.EMPTY_LIST));
|
updateResponseToImeUncheckLocked(new InlineSuggestionsResponse(Collections.EMPTY_LIST));
|
||||||
mPreviousResponseIsNotEmpty = false;
|
mPreviousResponseIsNotEmpty = false;
|
||||||
} else if (mImeInputViewStarted && mInlineSuggestionsResponse != null && match(mAutofillId,
|
} else if (mImeInputViewStarted && mInlineSuggestionsResponse != null && match(mAutofillId,
|
||||||
@@ -217,10 +227,6 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
// No-op if both the previous response and current response are empty.
|
// No-op if both the previous response and current response are empty.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sDebug) {
|
|
||||||
Log.d(TAG, "Send inline response: "
|
|
||||||
+ mInlineSuggestionsResponse.getInlineSuggestions().size());
|
|
||||||
}
|
|
||||||
updateResponseToImeUncheckLocked(mInlineSuggestionsResponse);
|
updateResponseToImeUncheckLocked(mInlineSuggestionsResponse);
|
||||||
mPreviousResponseIsNotEmpty = !isEmptyResponse;
|
mPreviousResponseIsNotEmpty = !isEmptyResponse;
|
||||||
}
|
}
|
||||||
@@ -234,6 +240,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (sDebug) Log.d(TAG, "Send inline response: " + response.getInlineSuggestions().size());
|
||||||
try {
|
try {
|
||||||
mResponseCallback.onInlineSuggestionsResponse(mAutofillId, response);
|
mResponseCallback.onInlineSuggestionsResponse(mAutofillId, response);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -255,7 +262,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
mImeRequestReceived = true;
|
mImeRequestReceived = true;
|
||||||
|
|
||||||
if (mTimeoutCallback != null) {
|
if (mTimeoutCallback != null) {
|
||||||
if (sDebug) Log.d(TAG, "removing timeout callback");
|
if (sVerbose) Log.v(TAG, "removing timeout callback");
|
||||||
mHandler.removeCallbacks(mTimeoutCallback);
|
mHandler.removeCallbacks(mTimeoutCallback);
|
||||||
mTimeoutCallback = null;
|
mTimeoutCallback = null;
|
||||||
}
|
}
|
||||||
@@ -350,7 +357,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputMethodStartInput(AutofillId imeFieldId) throws RemoteException {
|
public void onInputMethodStartInput(AutofillId imeFieldId) throws RemoteException {
|
||||||
if (sDebug) Log.d(TAG, "onInputMethodStartInput() received on " + imeFieldId);
|
if (sVerbose) Log.v(TAG, "onInputMethodStartInput() received on " + imeFieldId);
|
||||||
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.mHandler.sendMessage(obtainMessage(
|
session.mHandler.sendMessage(obtainMessage(
|
||||||
@@ -361,15 +368,15 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputMethodShowInputRequested(boolean requestResult) throws RemoteException {
|
public void onInputMethodShowInputRequested(boolean requestResult) throws RemoteException {
|
||||||
if (sDebug) {
|
if (sVerbose) {
|
||||||
Log.d(TAG, "onInputMethodShowInputRequested() received: " + requestResult);
|
Log.v(TAG, "onInputMethodShowInputRequested() received: " + requestResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
@Override
|
@Override
|
||||||
public void onInputMethodStartInputView() {
|
public void onInputMethodStartInputView() {
|
||||||
if (sDebug) Log.d(TAG, "onInputMethodStartInputView() received");
|
if (sVerbose) Log.v(TAG, "onInputMethodStartInputView() received");
|
||||||
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.mHandler.sendMessage(obtainMessage(
|
session.mHandler.sendMessage(obtainMessage(
|
||||||
@@ -381,7 +388,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
@BinderThread
|
@BinderThread
|
||||||
@Override
|
@Override
|
||||||
public void onInputMethodFinishInputView() {
|
public void onInputMethodFinishInputView() {
|
||||||
if (sDebug) Log.d(TAG, "onInputMethodFinishInputView() received");
|
if (sVerbose) Log.v(TAG, "onInputMethodFinishInputView() received");
|
||||||
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.mHandler.sendMessage(obtainMessage(
|
session.mHandler.sendMessage(obtainMessage(
|
||||||
@@ -392,7 +399,7 @@ final class AutofillInlineSuggestionsRequestSession {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputMethodFinishInput() throws RemoteException {
|
public void onInputMethodFinishInput() throws RemoteException {
|
||||||
if (sDebug) Log.d(TAG, "onInputMethodFinishInput() received");
|
if (sVerbose) Log.v(TAG, "onInputMethodFinishInput() received");
|
||||||
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
final AutofillInlineSuggestionsRequestSession session = mSession.get();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.mHandler.sendMessage(obtainMessage(
|
session.mHandler.sendMessage(obtainMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user