DO NOT MERGE: Freeup lock when IME is set inactive and unbound

Any pending windowGainedFocus future should be cancelled when IME is
switched/unbound.
Additinally, startInputInner() inside synchronized block blocked
WINDOW_FOCUS_GAIN from executing. Its fine to remove synchronization
here since startInputInner() already has relevant synchronized blocks.

Change-Id: I98cb044d8cbfb80480312a3923f168aefa9b7e7d
Fix: 144103599
Bug: 139806621
Test: Manually using the steps in bug.
(cherry picked from commit 322ee9bf9e)
This commit is contained in:
Tarandeep Singh
2019-11-13 14:53:38 -08:00
committed by Taran Singh
parent 659f477f65
commit ad0a4a229a

View File

@@ -645,14 +645,14 @@ public final class InputMethodManager {
} catch (RemoteException e) { } catch (RemoteException e) {
} }
} }
// Check focus again in case that "onWindowFocus" is called before }
// handling this message. // Check focus again in case that "onWindowFocus" is called before
if (mServedView != null && canStartInput(mServedView)) { // handling this message.
if (checkFocusNoStartInput(mRestartOnNextWindowFocus)) { if (mServedView != null && canStartInput(mServedView)) {
final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS if (checkFocusNoStartInput(mRestartOnNextWindowFocus)) {
: StartInputReason.DEACTIVATED_BY_IMMS; final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
startInputInner(reason, null, 0, 0, 0); : StartInputReason.DEACTIVATED_BY_IMMS;
} startInputInner(reason, null, 0, 0, 0);
} }
} }
return; return;
@@ -1215,6 +1215,10 @@ public final class InputMethodManager {
*/ */
void clearBindingLocked() { void clearBindingLocked() {
if (DEBUG) Log.v(TAG, "Clearing binding!"); if (DEBUG) Log.v(TAG, "Clearing binding!");
if (mWindowFocusGainFuture != null) {
mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */);
mWindowFocusGainFuture = null;
}
clearConnectionLocked(); clearConnectionLocked();
setInputChannelLocked(null); setInputChannelLocked(null);
mBindSequence = -1; mBindSequence = -1;