diff options
| author | 2022-09-16 18:01:30 +0800 | |
|---|---|---|
| committer | 2022-09-16 18:01:30 +0800 | |
| commit | def5cd30a1be030ba359b5e214914cca9680aaa6 (patch) | |
| tree | d6c746a417d5153ef203182227d1fdff702289d7 | |
| parent | 63190cebf26d1fc2040d824a6fd7c0e409741d5c (diff) | |
Prevent InputMethodManager call into DelegateImpl (1/N)
InputMethodManager#DelegateImpl is a delegation for
ImeFocusController to call into InputMethodManager.
Ideally IMM don't need to rely on DelegateImpl. Move
the IMM#hasActiveInputConnection implemetation from
DelegateImpl to make consistency.
Bug: 243778447
Bug: 182259171
Test: atest CtsInputMethodTestCases
Change-Id: I4246fd077b8ddf741311defb7a1b9175136bb769
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 0c7c1639e6c7..c966e93a71c5 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -788,7 +788,7 @@ public final class InputMethodManager { // we'll just do a window focus gain and call it a day. View servedView = controller.getServedView(); boolean nextFocusHasConnection = servedView != null && servedView == focusedView - && hasActiveConnection(focusedView); + && hasActiveInputConnectionInternal(focusedView); if (DEBUG) { Log.v(TAG, "Reporting focus gain, without startInput" + ", nextFocusIsServedView=" + nextFocusHasConnection); @@ -861,22 +861,11 @@ public final class InputMethodManager { /** * Checks whether the active input connection (if any) is for the given view. * - * TODO(b/182259171): Clean-up hasActiveConnection to simplify the logic. - * - * Note that this method is only intended for restarting input after focus gain - * (e.g. b/160391516), DO NOT leverage this method to do another check. + * @see #hasActiveInputConnectionInternal(View)} */ @Override public boolean hasActiveConnection(View view) { - synchronized (mH) { - if (!hasServedByInputMethodLocked(view) || !isImeSessionAvailableLocked()) { - return false; - } - - return mServedInputConnection != null - && mServedInputConnection.isActive() - && mServedInputConnection.getServedView() == view; - } + return hasActiveInputConnectionInternal(view); } } @@ -889,11 +878,31 @@ public final class InputMethodManager { * Checks whether the active input connection (if any) is for the given view. * * @hide - * @see ImeFocusController#getImmDelegate()#hasActiveInputConnection(View) + * @see #hasActiveInputConnectionInternal(View)} */ @TestApi public boolean hasActiveInputConnection(@Nullable View view) { - return mDelegate.hasActiveConnection(view); + return hasActiveInputConnectionInternal(view); + } + + /** + * Checks whether the active input connection (if any) is for the given view. + * + * TODO(b/182259171): Clean-up hasActiveConnection to simplify the logic. + * + * Note that this method is only intended for restarting input after focus gain + * (e.g. b/160391516), DO NOT leverage this method to do another check. + */ + private boolean hasActiveInputConnectionInternal(@Nullable View view) { + synchronized (mH) { + if (!hasServedByInputMethodLocked(view) || !isImeSessionAvailableLocked()) { + return false; + } + + return mServedInputConnection != null + && mServedInputConnection.isActive() + && mServedInputConnection.getServedView() == view; + } } @GuardedBy("mH") |