summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nikolas Havrikov <havrikov@google.com> 2022-02-18 14:33:01 +0100
committer Cherrypicker Worker <android-build-cherrypicker-worker@google.com> 2022-02-22 10:45:59 +0000
commit1755df787d0747c17a389abc535d8bc02a10caa4 (patch)
tree9caf1b22093aaf912ab22c31ca41db794fc296c7
parent3e4365b8ed6a9c03ddaf9f420dc31900b0c2fbd0 (diff)
Fix showSoftInput crashing when no IME is enabled
This CL adds a shortcut for bindCurrentMethod in InputMethodBindingController to return NO_IME instead of crashing in the rare case when no IME is enabled in the system. Bug: 220125769 Test: atest InputMethodServiceTest#testShowSoftInput_whenAllImesDisabled Change-Id: I7da6ed7f2b80331c469751b7091c340422df40a8 (cherry picked from commit 107035849e9f28c7ba96af0cb1caaa7bed80fd76) Merged-In:I7da6ed7f2b80331c469751b7091c340422df40a8
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodBindingController.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
index b2f500a59ba9..d2d80ffde532 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodBindingController.java
@@ -408,6 +408,11 @@ final class InputMethodBindingController {
@GuardedBy("ImfLock.class")
@NonNull
InputBindResult bindCurrentMethod() {
+ if (mSelectedMethodId == null) {
+ Slog.e(TAG, "mSelectedMethodId is null!");
+ return InputBindResult.NO_IME;
+ }
+
InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
if (info == null) {
throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId);