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

Skip to content
Commit 2a757ef4 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Add @hide IMM#hideSoftInputFromView as an optimization

It seems that it is relatively a common pattern used in the Framework
code when trying to hide a software keyboard.

  var imm = view.getSystemService(InputMethodManager.class);
  if (imm != null && imm.isActive(view)) {
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  }

The above code can be easily optimized by introducing a counterpart of

  InputMethodManager#showSoftInput(View view, int flags);

so that the hide request can be issued when and only when the
specified view has already established a connection to the IME. The
optimized code would look like as follows.

  var imm = view.getSystemService(InputMethodManager.class);
  if (imm != null) {
    imm.hideSoftInputFromView(view, 0);
  }

Major advantages of such an approach are:

 * IMM#checkFocus() can never be called.
 * IMM needs to take a lock only once.

With above, this CL introduces IMM#hideSoftInputFromView() as @hide
method so that we can start making sure that such an approach works
well.

Fix: 296466613
Test: atest CtsInputMethodTestCases:EditTextImeSupportTest
Change-Id: I01e5a29c0f82d068751774a2c58a1bd7b7b7f91a
parent 4d4fc565
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment