diff options
| author | 2018-03-20 16:28:59 -0700 | |
|---|---|---|
| committer | 2018-03-21 01:15:02 +0000 | |
| commit | 0cf7b310125ea283f2177d705cb134e895ff32bd (patch) | |
| tree | fdec7dcfa8cde5d7e5cf892bd03259f030ccc123 | |
| parent | 3785417848f95c24d2095daeaed0d1cb6b04fb35 (diff) | |
Fix confusing Log.e message in SpellCheckerSession
With this CL, calling SpellCheckerSession#close() multiple times will
no longer show the following error message in logcat, which was quite
confusing.
E SpellCheckerSession: ignoring processOrEnqueueTask due to
unexpected mState=TASK_CLOSE scp.mWhat=TASK_CLOSE
Note that with a recent CL [1], we now more often see the above
message. A typical scenario is:
1. App creates SpellCheckerSession x.
2. App calls x.close().
3. x is garbage-collected. ART calls x.finalize(), which internally
calls x.close() again.
[1]: I4e00c3a2cec93d1dacff20546e481fe757279661
9b64367193ffb252f869fb9f65a60b51a654119e
Bug: 72974646
Fix: 72974646
Test: Made sure that no error message in question with a test app
that calls SpellCheckerSession#close() multiple times then
trigger SpellCheckerSession#finalize().
Change-Id: Ie9690860e6d0406dc6746cd03c28f693e65c1dde
| -rw-r--r-- | core/java/android/view/textservice/SpellCheckerSession.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java index 779eefb14c74..886f5c822fb4 100644 --- a/core/java/android/view/textservice/SpellCheckerSession.java +++ b/core/java/android/view/textservice/SpellCheckerSession.java @@ -445,9 +445,15 @@ public class SpellCheckerSession { private void processOrEnqueueTask(SpellCheckerParams scp) { ISpellCheckerSession session; synchronized (this) { + if (scp.mWhat == TASK_CLOSE && (mState == STATE_CLOSED_AFTER_CONNECTION + || mState == STATE_CLOSED_BEFORE_CONNECTION)) { + // It is OK to call SpellCheckerSession#close() multiple times. + // Don't output confusing/misleading warning messages. + return; + } if (mState != STATE_WAIT_CONNECTION && mState != STATE_CONNECTED) { Log.e(TAG, "ignoring processOrEnqueueTask due to unexpected mState=" - + taskToString(scp.mWhat) + + stateToString(mState) + " scp.mWhat=" + taskToString(scp.mWhat)); return; } |