Hide logspam due to redundant finishComposingText
Currently we see two warning messages
"finishComposingText on inactive InputConnection"
"finishComposingText on inactive InputConnection"
every time every time the View focus is switched from one EditText
to another EditText on the same window, which is really spammy.
This is actually not critical if IInputConnectionWrapper was already
finished, because with my previous CL [1] it is guaranteed that
InputConnection#finishComposingText() was already called followed by
InputConnection#closeConnection(), which means that the connection
is closed and should not accept any further requests. Thus ignoring
further #finishComposingText() only means that the system and/or IME
is calling #finishComposingText() unnecessarily, which is worth
showing spammy warnings in production builds.
To reduce logspam this CL hides warnings from the above case behind
DEBUG flag.
[1]: If2a03bc84d318775fd4a197fa43acde086eda442
aaa38c9f1ae019f0fe8c3ba80630f26e582cc89c
Test: Make sure `adb logcat -s IInputConnectionWrapper:*` does not
show "finishComposingText on inactive InputConnection" warnings
while switching focus across different EditText on the same
window.
Bug: 35079353
Bug: 35301295
Change-Id: I17f3a4f500bc19ebf8bae771bf658a93627b3ba3
diff --git a/core/java/com/android/internal/view/IInputConnectionWrapper.java b/core/java/com/android/internal/view/IInputConnectionWrapper.java
index cb2d885..9de1b21 100644
--- a/core/java/com/android/internal/view/IInputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/IInputConnectionWrapper.java
@@ -36,7 +36,8 @@
import android.view.inputmethod.InputContentInfo;
public abstract class IInputConnectionWrapper extends IInputContext.Stub {
- static final String TAG = "IInputConnectionWrapper";
+ private static final String TAG = "IInputConnectionWrapper";
+ private static final boolean DEBUG = false;
private static final int DO_GET_TEXT_AFTER_CURSOR = 10;
private static final int DO_GET_TEXT_BEFORE_CURSOR = 20;
@@ -392,6 +393,14 @@
return;
}
case DO_FINISH_COMPOSING_TEXT: {
+ if (isFinished()) {
+ // In this case, #finishComposingText() is guaranteed to be called already.
+ // There should be no negative impact if we ignore this call silently.
+ if (DEBUG) {
+ Log.w(TAG, "Bug 35301295: Redundant finishComposingText.");
+ }
+ return;
+ }
InputConnection ic = getInputConnection();
// Note we do NOT check isActive() here, because this is safe
// for an IME to call at any time, and we need to allow it