Change a heuristic and add a log.
The heuristic in RichInputConnection makes little sense when textLength > mExpectedSelStart but we have more than 1024 characters of text. If there are that many, it's about 100% sure that 1024 is not the correct cursor position. With no good guess, we'll just continue trusting the app, even though we know it's lying : at least it will make the problem visible to the app author. Also, there have been a lot of confusion about initialSelStart and initialSelEnd. The keyboard should log them so that it helps us and editor authors debug more easily these common problems. Issue #65170 in AOSP and Bug: 12772035 Change-Id: I6665a16c9f2832d33ee323f033bb38bcc092a3b4
This commit is contained in:
parent
1b3a142cac
commit
3b4c1d3056
2 changed files with 5 additions and 3 deletions
|
@ -751,6 +751,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
+ ", word caps = "
|
||||
+ ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0));
|
||||
}
|
||||
Log.i(TAG, "Starting input. Cursor position = "
|
||||
+ editorInfo.initialSelStart + "," + editorInfo.initialSelEnd);
|
||||
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
ResearchLogger.latinIME_onStartInputViewInternal(editorInfo, prefs);
|
||||
|
|
|
@ -847,9 +847,9 @@ public final class RichInputConnection {
|
|||
mExpectedSelStart = mExpectedSelEnd = Constants.NOT_A_CURSOR_POSITION;
|
||||
} else {
|
||||
final int textLength = textBeforeCursor.length();
|
||||
if (textLength > mExpectedSelStart
|
||||
|| (textLength < Constants.EDITOR_CONTENTS_CACHE_SIZE
|
||||
&& mExpectedSelStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
|
||||
if (textLength < Constants.EDITOR_CONTENTS_CACHE_SIZE
|
||||
&& (textLength > mExpectedSelStart
|
||||
|| mExpectedSelStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
|
||||
// It should not be possible to have only one of those variables be
|
||||
// NOT_A_CURSOR_POSITION, so if they are equal, either the selection is zero-sized
|
||||
// (simple cursor, no selection) or there is no cursor/we don't know its pos
|
||||
|
|
Loading…
Reference in a new issue