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
Loading
Please register or sign in to comment