Merge "Bind IME and retry creating inline suggestions" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e6c9014ad3
@@ -313,6 +313,7 @@ final class InputMethodBindingController {
|
|||||||
mSupportsStylusHw);
|
mSupportsStylusHw);
|
||||||
mService.scheduleNotifyImeUidToAudioService(mCurMethodUid);
|
mService.scheduleNotifyImeUidToAudioService(mCurMethodUid);
|
||||||
mService.reRequestCurrentClientSessionLocked();
|
mService.reRequestCurrentClientSessionLocked();
|
||||||
|
mService.performOnCreateInlineSuggestionsRequestLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset Handwriting event receiver.
|
// reset Handwriting event receiver.
|
||||||
|
|||||||
@@ -286,6 +286,30 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final Set<String> mNonPreemptibleInputMethods;
|
private final Set<String> mNonPreemptibleInputMethods;
|
||||||
|
|
||||||
|
private static final class CreateInlineSuggestionsRequest {
|
||||||
|
@NonNull final InlineSuggestionsRequestInfo mRequestInfo;
|
||||||
|
@NonNull final IInlineSuggestionsRequestCallback mCallback;
|
||||||
|
@NonNull final String mPackageName;
|
||||||
|
|
||||||
|
CreateInlineSuggestionsRequest(
|
||||||
|
@NonNull InlineSuggestionsRequestInfo requestInfo,
|
||||||
|
@NonNull IInlineSuggestionsRequestCallback callback,
|
||||||
|
@NonNull String packageName) {
|
||||||
|
mRequestInfo = requestInfo;
|
||||||
|
mCallback = callback;
|
||||||
|
mPackageName = packageName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a request to create inline autofill suggestions comes in while the IME is unbound
|
||||||
|
* due to {@link #mPreventImeStartupUnlessTextEditor}, this is where it is stored, so
|
||||||
|
* that it may be fulfilled once the IME rebinds.
|
||||||
|
*/
|
||||||
|
@GuardedBy("ImfLock.class")
|
||||||
|
@Nullable
|
||||||
|
private CreateInlineSuggestionsRequest mPendingInlineSuggestionsRequest;
|
||||||
|
|
||||||
@UserIdInt
|
@UserIdInt
|
||||||
private int mLastSwitchUserId;
|
private int mLastSwitchUserId;
|
||||||
|
|
||||||
@@ -2137,16 +2161,24 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
private void onCreateInlineSuggestionsRequestLocked(@UserIdInt int userId,
|
private void onCreateInlineSuggestionsRequestLocked(@UserIdInt int userId,
|
||||||
InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback,
|
InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback,
|
||||||
boolean touchExplorationEnabled) {
|
boolean touchExplorationEnabled) {
|
||||||
|
clearPendingInlineSuggestionsRequestLocked();
|
||||||
final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
|
final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
|
||||||
try {
|
try {
|
||||||
IInputMethodInvoker curMethod = getCurMethodLocked();
|
if (userId == mSettings.getCurrentUserId()
|
||||||
if (userId == mSettings.getCurrentUserId() && curMethod != null
|
|
||||||
&& imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
|
&& imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
|
||||||
final IInlineSuggestionsRequestCallback callbackImpl =
|
mPendingInlineSuggestionsRequest = new CreateInlineSuggestionsRequest(
|
||||||
new InlineSuggestionsRequestCallbackDecorator(callback,
|
requestInfo, callback, imi.getPackageName());
|
||||||
imi.getPackageName(), mCurTokenDisplayId, getCurTokenLocked(),
|
if (getCurMethodLocked() != null) {
|
||||||
this);
|
// In the normal case when the IME is connected, we can make the request here.
|
||||||
curMethod.onCreateInlineSuggestionsRequest(requestInfo, callbackImpl);
|
performOnCreateInlineSuggestionsRequestLocked();
|
||||||
|
} else {
|
||||||
|
// Otherwise, the next time the IME connection is established,
|
||||||
|
// InputMethodBindingController.mMainConnection#onServiceConnected() will call
|
||||||
|
// into #performOnCreateInlineSuggestionsRequestLocked() to make the request.
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "IME not connected. Delaying inline suggestions request.");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callback.onInlineSuggestionsUnsupported();
|
callback.onInlineSuggestionsUnsupported();
|
||||||
}
|
}
|
||||||
@@ -2155,6 +2187,34 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("ImfLock.class")
|
||||||
|
void performOnCreateInlineSuggestionsRequestLocked() {
|
||||||
|
if (mPendingInlineSuggestionsRequest == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IInputMethodInvoker curMethod = getCurMethodLocked();
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Performing onCreateInlineSuggestionsRequest. mCurMethod = " + curMethod);
|
||||||
|
}
|
||||||
|
if (curMethod != null) {
|
||||||
|
final IInlineSuggestionsRequestCallback callback =
|
||||||
|
new InlineSuggestionsRequestCallbackDecorator(
|
||||||
|
mPendingInlineSuggestionsRequest.mCallback,
|
||||||
|
mPendingInlineSuggestionsRequest.mPackageName,
|
||||||
|
mCurTokenDisplayId, getCurTokenLocked(), this);
|
||||||
|
curMethod.onCreateInlineSuggestionsRequest(
|
||||||
|
mPendingInlineSuggestionsRequest.mRequestInfo, callback);
|
||||||
|
} else {
|
||||||
|
Slog.w(TAG, "No IME connected! Abandoning inline suggestions creation request.");
|
||||||
|
}
|
||||||
|
clearPendingInlineSuggestionsRequestLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GuardedBy("ImfLock.class")
|
||||||
|
private void clearPendingInlineSuggestionsRequestLocked() {
|
||||||
|
mPendingInlineSuggestionsRequest = null;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isInlineSuggestionsEnabled(InputMethodInfo imi,
|
private static boolean isInlineSuggestionsEnabled(InputMethodInfo imi,
|
||||||
boolean touchExplorationEnabled) {
|
boolean touchExplorationEnabled) {
|
||||||
return imi.isInlineSuggestionsEnabled()
|
return imi.isInlineSuggestionsEnabled()
|
||||||
|
|||||||
Reference in New Issue
Block a user