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,6 +645,7 @@ public final class InputMethodManager {
} catch (RemoteException e) { } catch (RemoteException e) {
} }
} }
}
// Check focus again in case that "onWindowFocus" is called before // Check focus again in case that "onWindowFocus" is called before
// handling this message. // handling this message.
if (mServedView != null && canStartInput(mServedView)) { if (mServedView != null && canStartInput(mServedView)) {
@@ -654,7 +655,6 @@ public final class InputMethodManager {
startInputInner(reason, null, 0, 0, 0); startInputInner(reason, null, 0, 0, 0);
} }
} }
}
return; return;
} }
case MSG_SEND_INPUT_EVENT: { case MSG_SEND_INPUT_EVENT: {
@@ -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;