Merge "Fix showSoftInput crashing when no IME is enabled" into tm-dev am: 00dcf266fb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16974611

Change-Id: Ieea83acf11e4dd7e9337b1e6b7aaa3d7206865d4
This commit is contained in:
TreeHugger Robot
2022-02-22 16:38:09 +00:00
committed by Automerger Merge Worker
2 changed files with 9 additions and 6 deletions

View File

@@ -54,13 +54,11 @@ public final class ImeFocusController {
@NonNull @NonNull
private InputMethodManagerDelegate getImmDelegate() { private InputMethodManagerDelegate getImmDelegate() {
InputMethodManagerDelegate delegate = mDelegate; if (mDelegate == null) {
if (delegate != null) { mDelegate = mViewRootImpl.mContext.getSystemService(
return delegate; InputMethodManager.class).getDelegate();
} }
delegate = mViewRootImpl.mContext.getSystemService(InputMethodManager.class).getDelegate(); return mDelegate;
mDelegate = delegate;
return delegate;
} }
/** Called when the view root is moved to a different display. */ /** Called when the view root is moved to a different display. */

View File

@@ -408,6 +408,11 @@ final class InputMethodBindingController {
@GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class")
@NonNull @NonNull
InputBindResult bindCurrentMethod() { InputBindResult bindCurrentMethod() {
if (mSelectedMethodId == null) {
Slog.e(TAG, "mSelectedMethodId is null!");
return InputBindResult.NO_IME;
}
InputMethodInfo info = mMethodMap.get(mSelectedMethodId); InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
if (info == null) { if (info == null) {
throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId); throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId);