Commits

Yohei Yukawa authored aaa38c9f1ae
Ensure IC#finishComposingText() is called on the correct Handler. This attempts to reland previously reverted CLs [1][2] due to an unexpected regression (Bug 27824691). The Bug 27868748 we want to address by this CL is that currently InputConnection#finishComposingText() can be called on the root view's Handler no matter what Handler is associated with ControlledInputConnectionWrapper. Actually the root cause of Bug 6789252 is the same, but there we worked around it by not calling InputConnection#finishComposingText() in certain situations [3]. With this CL we should be able to logically revert that workaround. This CL also removes redundant IMM#mServedInputConnection. This is safe because the following two fields have the same lifetime. - InputMethodManager#mServedInputConnection - InputMethodManager#mServedInputConnectionWrapper We do not need to maintain both of them. This also allows us to use a strong refecente in IInputConnectionWrapper#mInputConnection instead of a WeakReference. To understand why this is safe, we need to understand how things previously worked, which is as follows: 1. InputMethodManager#mServedInputConnection becomes non-null. -> IInputConnectionWrapper#mInputConnection.get() is guaranteed to be alive. 2. InputMethodManager#mServedInputConnection becomes null or another object. -> IInputConnectionWrapper#mInputConnection.get() may not be alive. Since we know exactly when InputMethodManager#mServedInputConnection is updated, in theory we do not need to use WeakReference here, and with this CL we do not use WeakReference anymore. Actually the initial commit [1] accidentally removed the last strong reference to the active InputConnection and WeakReference could be null at any time, which was what we observed in Bug 27824691. [1]: I1181e067aa5bedbdf0c7ec1bcec479257aea511c afb6558c8f5e0ee797b252558d7e529e3d946d8f [2]: Ibe94f115e607a198d12ecd3d4e4f91a7d9469c98 16e2c7b59aacf44df7aaa0d04e0228240907487f [3]: I66f51da1299532793ef8fa700f35b0811670f235 4e5184f929d2498714bc7734fe10b9b8810cb071 Bug: 27868748 Change-Id: If2a03bc84d318775fd4a197fa43acde086eda442