From 7d74594123bd9ee3a09f54d509bff27af5f6cca8 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 14 Oct 2014 11:42:13 +0900 Subject: [PATCH] Fix an NPE. Bug: 17958289 Change-Id: I5c9ea668ff75b38c7ddebd767c36a950835c0c9f --- .../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 62a258b20..a3f7bb4d6 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -860,9 +860,10 @@ public final class RichInputConnection implements PrivateCommandPerformer { * than it really is. */ public void tryFixLyingCursorPosition() { + mIC = mParent.getCurrentInputConnection(); final CharSequence textBeforeCursor = getTextBeforeCursor( Constants.EDITOR_CONTENTS_CACHE_SIZE, 0); - final CharSequence selectedText = mIC.getSelectedText(0 /* flags */); + final CharSequence selectedText = null == mIC ? null : mIC.getSelectedText(0 /* flags */); if (null == textBeforeCursor || (!TextUtils.isEmpty(selectedText) && mExpectedSelEnd == mExpectedSelStart)) { // If textBeforeCursor is null, we have no idea what kind of text field we have or if