Merge "Fix an off-by-one bug in EditableInputConnection#endBatchEdit() return value" am: e908851af5 am: 0c024d11ed

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1923058

Change-Id: Icaa621b17c72031f0a767aaece8c96a92221fc82
This commit is contained in:
Treehugger Robot
2021-12-15 17:54:19 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 12 deletions

View File

@@ -770,20 +770,25 @@ public interface InputConnection {
boolean beginBatchEdit(); boolean beginBatchEdit();
/** /**
* Tell the editor that you are done with a batch edit previously * Tell the editor that you are done with a batch edit previously initiated with
* initiated with {@link #beginBatchEdit}. This ends the latest * {@link #beginBatchEdit()}. This ends the latest batch only.
* batch only.
* *
* <p><strong>IME authors:</strong> make sure you call this * <p><strong>IME authors:</strong> make sure you call this exactly once for each call to
* exactly once for each call to {@link #beginBatchEdit}.</p> * {@link #beginBatchEdit()}.</p>
* *
* <p><strong>Editor authors:</strong> please be careful about * <p><strong>Editor authors:</strong> please be careful about batch edit nesting. Updates still
* batch edit nesting. Updates still to be held back until the end * to be held back until the end of the last batch edit. In case you are delegating this API
* of the last batch edit.</p> * call to the one obtained from
* {@link android.widget.EditText#onCreateInputConnection(EditorInfo)}, there was an off-by-one
* that had returned {@code true} when its nested batch edit count becomes {@code 0} as a result
* of invoking this API. This bug is fixed in {@link android.os.Build.VERSION_CODES#TIRAMISU}.
* </p>
* *
* @return true if there is still a batch edit in progress after closing * @return For editor authors, you must return {@code true} if a batch edit is still in progress
* the latest one (in other words, if the nesting count is > 0), false * after closing the latest one (in other words, if the nesting count is still a
* otherwise or if the input connection is no longer valid. * positive number). Return {@code false} otherwise. For IME authors, you will
* always receive {@code true} as long as the request was sent to the editor, and
* receive {@code false} only if the input connection is no longer valid.
*/ */
boolean endBatchEdit(); boolean endBatchEdit();

View File

@@ -92,7 +92,7 @@ public class EditableInputConnection extends BaseInputConnection
// contribution to mTextView's nested batch edit count is zero. // contribution to mTextView's nested batch edit count is zero.
mTextView.endBatchEdit(); mTextView.endBatchEdit();
mBatchEditNesting--; mBatchEditNesting--;
return true; return mBatchEditNesting > 0;
} }
} }
return false; return false;