summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-04-19 14:51:47 +0900
committerThe Android Automerger <android-build@android.com>2013-04-19 10:45:13 -0700
commit49007de565a1f4feac9b4e9ae280881a25f35f22 (patch)
tree2d29cb3225640565de3ff39d8e05a753ecafbb96
parent530fd15eff8bd8df1c4c87cfeab379b5328748c1 (diff)
downloadandroid_packages_inputmethods_LatinIME-49007de565a1f4feac9b4e9ae280881a25f35f22.tar.gz
android_packages_inputmethods_LatinIME-49007de565a1f4feac9b4e9ae280881a25f35f22.tar.bz2
android_packages_inputmethods_LatinIME-49007de565a1f4feac9b4e9ae280881a25f35f22.zip
Fix an NPE in recapitalize
Bug: 8657736 Change-Id: I459d1c200826c1c394f8207475ecf60a4f356793
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 0e1c4dc31..b8203ff74 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1970,9 +1970,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// If we have a recapitalize in progress, use it; otherwise, create a new one.
if (!mRecapitalizeStatus.isActive()
|| !mRecapitalizeStatus.isSetAt(mLastSelectionStart, mLastSelectionEnd)) {
+ final CharSequence selectedText =
+ mConnection.getSelectedText(0 /* flags, 0 for no styles */);
+ if (TextUtils.isEmpty(selectedText)) return; // Race condition with the input connection
mRecapitalizeStatus.initialize(mLastSelectionStart, mLastSelectionEnd,
- mConnection.getSelectedText(0 /* flags, 0 for no styles */).toString(),
- mSettings.getCurrentLocale(), mSettings.getWordSeparators());
+ selectedText.toString(), mSettings.getCurrentLocale(),
+ mSettings.getWordSeparators());
// We trim leading and trailing whitespace.
mRecapitalizeStatus.trim();
// Trimming the object may have changed the length of the string, and we need to