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

Commit c5af33d3 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Deprecate mRequestUpdateCursorAnchorInfoMonitorMode part 1

This is the initial step towards deprecating

 InputMethodManager#mRequestUpdateCursorAnchorInfoMonitorMode,

which was introduced as a minimum implementation to support
CursorAnchorInfo API in EditText [1]

Before this CL, there is a behavior discrepancy in

 MSG_UPDATE_VIRTUAL_DISPLAY_TO_SCREEN_MATRIX

handler because mRequestUpdateCursorAnchorInfoMonitorMode has a valid
value when and only when the editor component is EditText.

With this CL, the same behavior will be applied to non-View based
editors.

 [1]: I3c6b69bd9d79b199afe68d838f25effa6048e5cc
      cf8421df856a5950729ff1d0e73f21d480aa98fb

Bug: 236713697
Test: presubmit
Change-Id: I8d42aef4ffd81253181ba876f8970179643d834c
parent 7a3cf53a
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1131,9 +1131,7 @@ public final class InputMethodManager {
                                || mServedInputConnection == null) {
                            return;
                        }
                        final boolean isMonitoring = (mRequestUpdateCursorAnchorInfoMonitorMode
                                & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
                        if (!isMonitoring) {
                        if (!mServedInputConnection.isCursorAnchorInfoMonitoring()) {
                            return;
                        }
                        // Since the host VirtualDisplay is moved, we need to issue
+19 −1
Original line number Diff line number Diff line
@@ -176,6 +176,8 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
    private final AtomicInteger mCurrentSessionId = new AtomicInteger(0);
    private final AtomicBoolean mHasPendingInvalidation = new AtomicBoolean();

    private final AtomicBoolean mIsCursorAnchorInfoMonitoring = new AtomicBoolean(false);

    public RemoteInputConnectionImpl(@NonNull Looper looper,
            @NonNull InputConnection inputConnection,
            @NonNull InputMethodManager inputMethodManager, @Nullable View servedView) {
@@ -222,6 +224,16 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
        return mServedView.get();
    }

    /**
     * @return {@code true} if there is any active request for
     *         {@link android.view.inputmethod.CursorAnchorInfo} with
     *         {@link InputConnection#CURSOR_UPDATE_MONITOR} flag.
     */
    @AnyThread
    public boolean isCursorAnchorInfoMonitoring() {
        return mIsCursorAnchorInfoMonitoring.get();
    }

    /**
     * Schedule a task to execute
     * {@link InputMethodManager#doInvalidateInput(RemoteInputConnectionImpl, TextSnapshot, int)}
@@ -998,11 +1010,17 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
            // requestCursorUpdates() is not currently supported across displays.
            return false;
        }
        final boolean hasMonitoring =
                (cursorUpdateMode & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
        boolean result = false;
        try {
            return ic.requestCursorUpdates(cursorUpdateMode, cursorUpdateFilter);
            result = ic.requestCursorUpdates(cursorUpdateMode, cursorUpdateFilter);
            return result;
        } catch (AbstractMethodError ignored) {
            // TODO(b/199934664): See if we can remove this by providing a default impl.
            return false;
        } finally {
            mIsCursorAnchorInfoMonitoring.set(result && hasMonitoring);
        }
    }