diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 233e28508cb40..c7e4cd22fc08a 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -4591,6 +4591,13 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub Slog.w(TAG, "Ignoring setInputMethod of uid " + Binder.getCallingUid() + " token: " + token); return; + } else { + // Called with current IME's token. + if (mMethodMap.get(id) != null + && mSettings.getEnabledInputMethodListWithFilterLocked( + (info) -> info.getId().equals(id)).isEmpty()) { + throw new IllegalStateException("Requested IME is not enabled: " + id); + } } final long ident = Binder.clearCallingIdentity();