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

Commit 72d35fa8 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Reject request when any unknown flag is speficied

Currently EditableInputConnection#requestUpdateCursorAnchorInfo
never returns false unless InputMethodManager is somehow
unavailable.

This is problematic, especifially when we add a new flag to
EditableInputConnection#requestUpdateCursorAnchorInfo in a
future release.

With this CL, #requestUpdateCursorAnchorInfo does nothing and
immediately returns false when one ore more unknown bits are
specified.

BUG: 17324806
Change-Id: I5601714b481e8efa0ad3337c0d093cfcf55eade3
parent b3206382
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -191,6 +191,20 @@ public class EditableInputConnection extends BaseInputConnection {
    public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
        if (DEBUG) Log.v(TAG, "requestUpdateCursorAnchorInfo " + cursorUpdateMode);

        // It is possible that any other bit is used as a valid flag in a future release.
        // We should reject the entire request in such a case.
        final int KNOWN_FLAGS_MASK = InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE |
                InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR;
        final int unknownFlags = cursorUpdateMode & ~KNOWN_FLAGS_MASK;
        if (unknownFlags != 0) {
            if (DEBUG) {
                Log.d(TAG, "Rejecting requestUpdateCursorAnchorInfo due to unknown flags." +
                        " cursorUpdateMode=" + cursorUpdateMode +
                        " unknownFlags=" + unknownFlags);
            }
            return false;
        }

        if (mIMM == null) {
            // In this case, TYPE_CURSOR_ANCHOR_INFO is not handled.
            // TODO: Return some notification code rather than false to indicate method that