Fixed NPE by guarding the reference of variable

Bug: 2395174
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 34113cf..60813f1 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1526,6 +1526,9 @@
         mDialogBuilder.setSingleChoiceItems(mItems, checkedItem,
                 new AlertDialog.OnClickListener() {
                     public void onClick(DialogInterface dialog, int which) {
+                        if (mIms == null) {
+                            return;
+                        }
                         synchronized (mMethodMap) {
                             InputMethodInfo im = mIms[which];
                             hideInputMethodMenu();