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

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

Merge "Deprecate mRequestUpdateCursorAnchorInfoMonitorMode part 2"

parents 43b6f4b2 752bf17e
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -2827,8 +2827,8 @@ public final class InputMethodManager {
            }
            // If immediate bit is set, we will call updateCursorAnchorInfo() even when the data has
            // not been changed from the previous call.
            final boolean isImmediate = (mRequestUpdateCursorAnchorInfoMonitorMode &
                    CURSOR_UPDATE_IMMEDIATE) != 0;
            final boolean isImmediate = mServedInputConnection != null
                    && mServedInputConnection.resetHasPendingImmediateCursorAnchorInfoUpdate();
            if (!isImmediate && Objects.equals(mCursorAnchorInfo, cursorAnchorInfo)) {
                // TODO: Consider always emitting this message once we have addressed redundant
                // calls of this method from android.widget.Editor.
@@ -2847,8 +2847,6 @@ public final class InputMethodManager {
                mCurrentInputMethodSession.updateCursorAnchorInfo(cursorAnchorInfo);
            }
            mCursorAnchorInfo = cursorAnchorInfo;
            // Clear immediate bit (if any).
            mRequestUpdateCursorAnchorInfoMonitorMode &= ~CURSOR_UPDATE_IMMEDIATE;
        }
    }

+22 −0
Original line number Diff line number Diff line
@@ -177,6 +177,8 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
    private final AtomicBoolean mHasPendingInvalidation = new AtomicBoolean();

    private final AtomicBoolean mIsCursorAnchorInfoMonitoring = new AtomicBoolean(false);
    private final AtomicBoolean mHasPendingImmediateCursorAnchorInfoUpdate =
            new AtomicBoolean(false);

    public RemoteInputConnectionImpl(@NonNull Looper looper,
            @NonNull InputConnection inputConnection,
@@ -224,6 +226,23 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
        return mServedView.get();
    }

    /**
     * Gets and resets {@link #mHasPendingImmediateCursorAnchorInfoUpdate}.
     *
     * <p>Calling this method resets {@link #mHasPendingImmediateCursorAnchorInfoUpdate}. This
     * means that the second call of this method returns {@code false} unless the IME requests
     * {@link android.view.inputmethod.CursorAnchorInfo} again with
     * {@link InputConnection#CURSOR_UPDATE_IMMEDIATE} flag.</p>
     *
     * @return {@code true} if there is any pending request for
     *         {@link android.view.inputmethod.CursorAnchorInfo} with
     *         {@link InputConnection#CURSOR_UPDATE_IMMEDIATE} flag.
     */
    @AnyThread
    public boolean resetHasPendingImmediateCursorAnchorInfoUpdate() {
        return mHasPendingImmediateCursorAnchorInfoUpdate.getAndSet(false);
    }

    /**
     * @return {@code true} if there is any active request for
     *         {@link android.view.inputmethod.CursorAnchorInfo} with
@@ -1010,6 +1029,8 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
            // requestCursorUpdates() is not currently supported across displays.
            return false;
        }
        final boolean hasImmediate =
                (cursorUpdateMode & InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0;
        final boolean hasMonitoring =
                (cursorUpdateMode & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
        boolean result = false;
@@ -1020,6 +1041,7 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
            // TODO(b/199934664): See if we can remove this by providing a default impl.
            return false;
        } finally {
            mHasPendingImmediateCursorAnchorInfoUpdate.set(result && hasImmediate);
            mIsCursorAnchorInfoMonitoring.set(result && hasMonitoring);
        }
    }