diff options
| author | 2020-03-04 01:47:21 +0000 | |
|---|---|---|
| committer | 2020-03-04 01:47:21 +0000 | |
| commit | d74346b8cfcb667f0f33f81ef26c61a355c7a94a (patch) | |
| tree | 098fa885cff2e20f9af8864318d8aaafd15871e3 | |
| parent | dac57a3e5375b43aa2a9931de33e56983a31d6ef (diff) | |
| parent | 7bbce8ee6b647e48e4fedcb8851b7cce1dac01a9 (diff) | |
Merge "Ignore unchecked IME show/hide when no root" into rvc-dev
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index aca265b1f59a..482d5b25e9da 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1634,14 +1634,20 @@ public final class InputMethodManager { @Deprecated @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768499) public void showSoftInputUnchecked(int flags, ResultReceiver resultReceiver) { - try { - Log.w(TAG, "showSoftInputUnchecked() is a hidden method, which will be removed " - + "soon. If you are using android.support.v7.widget.SearchView, please update " - + "to version 26.0 or newer version."); - mService.showSoftInput( - mClient, mCurRootView.getView().getWindowToken(), flags, resultReceiver); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); + synchronized (mH) { + try { + Log.w(TAG, "showSoftInputUnchecked() is a hidden method, which will be" + + " removed soon. If you are using android.support.v7.widget.SearchView," + + " please update to version 26.0 or newer version."); + if (mCurRootView == null || mCurRootView.getView() == null) { + Log.w(TAG, "No current root view, ignoring showSoftInputUnchecked()"); + return; + } + mService.showSoftInput( + mClient, mCurRootView.getView().getWindowToken(), flags, resultReceiver); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } } @@ -1986,11 +1992,17 @@ public final class InputMethodManager { @UnsupportedAppUsage void closeCurrentInput() { - try { - mService.hideSoftInput( - mClient, mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); + synchronized (mH) { + if (mCurRootView == null || mCurRootView.getView() == null) { + Log.w(TAG, "No current root view, ignoring closeCurrentInput()"); + return; + } + try { + mService.hideSoftInput( + mClient, mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } } |