Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf5dc9ec authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make IMM#hasActiveInputConnection() more predictable

This is a follow up CL to our previous CL [1], which introduced

  InputMethodManager#hasActiveInputConnection(View)

as a test API.

As this remains to be a test API, we should be able to tweak its
behavior as long as existing use cases continue working.

The main motivations of this CL is to make it more predictable and
easier to understand.

Even with simplification, ImeAwareEditText and CTS tests should
continue working as expected.  Also there must be no app compatibility
concern in this CL.

 [1]: I466a93e2b4706ae809ac50dc16dc8e4ffa7c2f1c
      8bcce88c

Bug: 176697749
Bug: 182259171
Test: presubmit
Change-Id: I7fe8b18ffbb450fd1e272e15f06f2629518f320c
parent bb563d8c
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -873,12 +873,25 @@ public final class InputMethodManager {
    /**
     * Checks whether the active input connection (if any) is for the given view.
     *
     * <p>Note that {@code view} parameter does not take
     * {@link View#checkInputConnectionProxy(View)} into account. This method returns {@code true}
     * when and only when the specified {@code view} is the actual {@link View} instance that is
     * connected to the IME.</p>
     *
     * @param view {@link View} to be checked.
     * @return {@code true} if {@code view} is currently interacting with IME.
     * @hide
     * @see #hasActiveInputConnectionInternal(View)}
     */
    @TestApi
    public boolean hasActiveInputConnection(@Nullable View view) {
        return hasActiveInputConnectionInternal(view);
        synchronized (mH) {
            return mCurRootView != null
                    && view != null
                    && mServedView == view
                    && mServedInputConnection != null
                    && mServedInputConnection.isAssociatedWith(view)
                    && isImeSessionAvailableLocked();
        }
    }

    /**