summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tarandeep Singh <tarandeep@google.com> 2019-11-13 14:53:38 -0800
committer Taran Singh <tarandeep@google.com> 2019-11-23 04:14:49 +0000
commitad0a4a229a29eb8c79fe8ec3228399f2239c1c98 (patch)
tree344dd99d9724f91f7c5bc752ad01ffd026cbd030
parent659f477f65a8eda41190b927dc7f72907920f209 (diff)
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 322ee9bf9ec74460d98c13e91ce4749141bf79e7)
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 032af1c5c7b5..eb6dc2a57ee9 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -645,14 +645,14 @@ public final class InputMethodManager {
} catch (RemoteException e) {
}
}
- // Check focus again in case that "onWindowFocus" is called before
- // handling this message.
- if (mServedView != null && canStartInput(mServedView)) {
- if (checkFocusNoStartInput(mRestartOnNextWindowFocus)) {
- final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
- : StartInputReason.DEACTIVATED_BY_IMMS;
- startInputInner(reason, null, 0, 0, 0);
- }
+ }
+ // Check focus again in case that "onWindowFocus" is called before
+ // handling this message.
+ if (mServedView != null && canStartInput(mServedView)) {
+ if (checkFocusNoStartInput(mRestartOnNextWindowFocus)) {
+ final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
+ : StartInputReason.DEACTIVATED_BY_IMMS;
+ startInputInner(reason, null, 0, 0, 0);
}
}
return;
@@ -1215,6 +1215,10 @@ public final class InputMethodManager {
*/
void clearBindingLocked() {
if (DEBUG) Log.v(TAG, "Clearing binding!");
+ if (mWindowFocusGainFuture != null) {
+ mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */);
+ mWindowFocusGainFuture = null;
+ }
clearConnectionLocked();
setInputChannelLocked(null);
mBindSequence = -1;