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
This commit is contained in:
Yohei Yukawa
2014-08-28 23:57:11 -07:00
parent b32063822b
commit 72d35fa829

View File

@@ -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