Track the last softInputMode in IMMS
A field in WindowManager.LayoutParams softInputMode is something that
definitely needs to be kept tracking in historical debugging
infrastructure across IME-related processes (Bug 35079353) [1]. As a
preparation, this CL enables InputMethodManagerService (IMMS) to
include the last softInputMode specified in IMMS#windowGainedFocus()
in the dumpsys in human readable format.
[1]: As explained in b.android.com/224318, softInputMode misspecified
by app developers is a typical root cause of unexpected behavior
in keyboard visibility. Bugs such as Bug 23168250, Bug 27275709,
and Bug 31770400 fall into this category.
Test: `adb shell dumpsys input_method | grep softInputMode=`
Bug: 35079353
Change-Id: I485ced030def179dad78b4b811c6eb52b5e5c951
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 2b3d8d4..b2b8f85 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -348,6 +348,13 @@
IBinder mCurFocusedWindow;
/**
+ * {@link WindowManager.LayoutParams#softInputMode} of {@link #mCurFocusedWindow}.
+ *
+ * @see #mCurFocusedWindow
+ */
+ int mCurFocusedWindowSoftInputMode;
+
+ /**
* The client by which {@link #mCurFocusedWindow} was reported. Used only for debugging.
*/
ClientState mCurFocusedWindowClient;
@@ -2288,7 +2295,7 @@
+ InputConnectionInspector.getMissingMethodFlagsAsString(missingMethods)
+ " attribute=" + attribute
+ " controlFlags=#" + Integer.toHexString(controlFlags)
- + " softInputMode=#" + Integer.toHexString(softInputMode)
+ + " softInputMode=" + InputMethodClient.softInputModeToString(softInputMode)
+ " windowFlags=#" + Integer.toHexString(windowFlags));
ClientState cs = mClients.get(client.asBinder());
@@ -2333,6 +2340,7 @@
return null;
}
mCurFocusedWindow = windowToken;
+ mCurFocusedWindowSoftInputMode = softInputMode;
mCurFocusedWindowClient = cs;
// Should we auto-show the IME even if the caller has not
@@ -4087,9 +4095,11 @@
p.println(" mCurMethodId=" + mCurMethodId);
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + mCurSeq);
- p.println(" mCurFocusedWindow=" + mCurFocusedWindow);
+ p.println(" mCurFocusedWindow=" + mCurFocusedWindow
+ + " softInputMode=" +
+ InputMethodClient.softInputModeToString(mCurFocusedWindowSoftInputMode)
+ + " client=" + mCurFocusedWindowClient);
focusedWindowClient = mCurFocusedWindowClient;
- p.println(" mCurFocusedWindowClient=" + focusedWindowClient);
p.println(" mCurId=" + mCurId + " mHaveConnect=" + mHaveConnection
+ " mBoundToMethod=" + mBoundToMethod);
p.println(" mCurToken=" + mCurToken);