Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d16327f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Stop lying about MissingMethodFlags.REQUEST_CURSOR_UPDATES"

parents a7b61e26 6d2e9786
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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);
    }
+3 −2
Original line number Diff line number Diff line
@@ -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);
        }
+6 −1
Original line number Diff line number Diff line
@@ -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);
        });
    }
+2 −1
Original line number Diff line number Diff line
@@ -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 */);
+0 −6
Original line number Diff line number Diff line
@@ -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;