From 93c00ceafbdab21f69ac12eb9ad5c93c4158e8bc Mon Sep 17 00:00:00 2001 From: Tarandeep Singh Date: Fri, 16 Feb 2018 14:31:17 -0800 Subject: [PATCH] Unbind InputMethod when app crashes If a running app (with bound InputMethod) crashes, the currently running InputMethod is not unbound. As a result, onBindInput is not called. In order to fix this, IMMS.removeClient() should also unbind the current client and clear the flag IMMS.mBoundToMethod. With the fix, I haven't seen any test failures mentioned in bug. Bug: 72399950 Fixes: 73274813 Test: atest InputMethodServiceLifecycleTest && atest FocusHandlingTest Change-Id: I0c09381b43a8b96480976edafbc0b0ee40ae5de0 --- .../java/com/android/server/InputMethodManagerService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 7cd007bd0b8f2..b0923a13cf746 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -1706,6 +1706,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (cs != null) { clearClientSessionLocked(cs); if (mCurClient == cs) { + if (mBoundToMethod) { + mBoundToMethod = false; + if (mCurMethod != null) { + executeOrSendMessage(mCurMethod, mCaller.obtainMessageO( + MSG_UNBIND_INPUT, mCurMethod)); + } + } mCurClient = null; } if (mCurFocusedWindowClient == cs) {