Merge "Stop lying about MissingMethodFlags.REQUEST_CURSOR_UPDATES"

This commit is contained in:
TreeHugger Robot
2021-09-13 17:27:34 +00:00
committed by Android (Google) Code Review
5 changed files with 20 additions and 11 deletions

View File

@@ -393,7 +393,15 @@ final class RemoteInputConnection implements InputConnection {
// This method is not implemented.
return false;
}
final CompletableFuture<Boolean> value = mInvoker.requestCursorUpdates(cursorUpdateMode);
final InputMethodServiceInternal ims = mImsInternal.getAndWarnIfNull();
if (ims == null) {
return false;
}
final int displayId = ims.getContext().getDisplayId();
final CompletableFuture<Boolean> value =
mInvoker.requestCursorUpdates(cursorUpdateMode, displayId);
return CompletableFutureUtil.getResultOrFalse(value, TAG, "requestCursorUpdates()",
mCancellationGroup, MAX_WAIT_TIME_MILLIS);
}

View File

@@ -477,15 +477,16 @@ public final class IInputContextInvoker {
* Invokes {@link IInputContext#requestCursorUpdates(int, IIntResultCallback)}.
*
* @param cursorUpdateMode {@code cursorUpdateMode} parameter to be passed.
* @param imeDisplayId the display ID that is associated with the IME.
* @return {@link AndroidFuture<Boolean>} that can be used to retrieve the invocation
* result. {@link RemoteException} will be treated as an error.
*/
@AnyThread
@NonNull
public AndroidFuture<Boolean> requestCursorUpdates(int cursorUpdateMode) {
public AndroidFuture<Boolean> requestCursorUpdates(int cursorUpdateMode, int imeDisplayId) {
final AndroidFuture<Boolean> future = new AndroidFuture<>();
try {
mIInputContext.requestCursorUpdates(cursorUpdateMode, future);
mIInputContext.requestCursorUpdates(cursorUpdateMode, imeDisplayId, future);
} catch (RemoteException e) {
future.completeExceptionally(e);
}

View File

@@ -567,13 +567,18 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub {
}
@Override
public void requestCursorUpdates(int cursorUpdateMode, AndroidFuture future /* T=Boolean */) {
public void requestCursorUpdates(int cursorUpdateMode, int imeDisplayId,
AndroidFuture future /* T=Boolean */) {
dispatchWithTracing("requestCursorUpdates", future, () -> {
final InputConnection ic = getInputConnection();
if (ic == null || !isActive()) {
Log.w(TAG, "requestCursorAnchorInfo on inactive InputConnection");
return false;
}
if (mParentInputMethodManager.getDisplayId() != imeDisplayId) {
// requestCursorUpdates() is not currently supported across displays.
return false;
}
return ic.requestCursorUpdates(cursorUpdateMode);
});
}

View File

@@ -75,7 +75,8 @@ import com.android.internal.infra.AndroidFuture;
void getSelectedText(int flags, in AndroidFuture future /* T=CharSequence */);
void requestCursorUpdates(int cursorUpdateMode, in AndroidFuture future /* T=Boolean */);
void requestCursorUpdates(int cursorUpdateMode, int imeDisplayId,
in AndroidFuture future /* T=Boolean */);
void commitContent(in InputContentInfo inputContentInfo, int flags, in Bundle opts,
in AndroidFuture future /* T=Boolean */);

View File

@@ -2384,12 +2384,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (mCurSeq <= 0) mCurSeq = 1;
mCurClient = cs;
mCurInputContext = inputContext;
if (cs.selfReportedDisplayId != displayIdToShowIme) {
// CursorAnchorInfo API does not work as-is for cross-display scenario. Pretend that
// InputConnection#requestCursorUpdates() is not implemented in the application so that
// IMEs will always receive false from this API.
missingMethods |= MissingMethodFlags.REQUEST_CURSOR_UPDATES;
}
mCurInputContextMissingMethods = missingMethods;
mCurAttribute = attribute;