From 00c0010ccf2de188743cb8f7364b8ba8b9faf7f8 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 14 Nov 2012 12:22:40 +0900 Subject: [PATCH] Fix a bug with some text fields Not sure when this happens exactly, but it is possible that InputConnection#getTextBeforeCursor returns null. This happens for example upon rotating the screen with the composing field empty in Gmail. In this case, StringBuilder#append will convert the null pointer into the string "null", which is sure better than a crash, but can have a number of bad side-effects, like auto-caps not working. Bug: 7533034 Change-Id: Ia1cfab432c13a12ff1c2f013c59bac05a587f553 --- .../src/com/android/inputmethod/latin/RichInputConnection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 21441369e..75b67bfc6 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -145,7 +145,8 @@ public final class RichInputConnection { mCurrentCursorPosition = newCursorPosition; mComposingText.setLength(0); mCommittedTextBeforeComposingText.setLength(0); - mCommittedTextBeforeComposingText.append(getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE, 0)); + final CharSequence textBeforeCursor = getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE, 0); + if (null != textBeforeCursor) mCommittedTextBeforeComposingText.append(textBeforeCursor); mCharAfterTheCursor = getTextAfterCursor(1, 0); if (null != mIC) { mIC.finishComposingText();