diff options
| author | Ming-Shin Lu <lumark@google.com> | 2021-10-13 02:33:47 +0800 |
|---|---|---|
| committer | Ming-Shin Lu <lumark@google.com> | 2021-10-13 09:31:44 +0800 |
| commit | 8bd8b278536c4f3a9eb9266a845e856d269b04c3 (patch) | |
| tree | 7e50ef6ddc86033466933d7e8aa83e281e19811c /core/java/android/inputmethodservice/InputMethodService.java | |
| parent | 3866f66fcb039a9c63b7c472f4b718994f464d0f (diff) | |
Fix IME crash on SoftInputWindow.show by TOKEN_PENDING
Originated from CL[1] to fix a crash edge case that happened when
calling InputMethodPrivilegedOperationsRegistry#put that assumes there
is only one pair of window token and IInputMethodPrivilegedOperations
in the container.
However, InputMethodPrivilegedOperationsRegistry is a process-level
singleton instances that may run into a timing when there are 2
InputMethodService (IMS) instances, one is just created and the other
is in the way of destorying.
Before the destorying one calls
InputMethodPrivilegedOperationsRegistry#remove, IMS#initializeInternal
invoked for the new one with the same window token, that makes system
ignored the initialization process because CL[1] introduced
InputMethodPrivilegedOperationsRegistry#isRegistered(token) and system
thoughts the token has been registered before, but actually this method
is problemetic to aware this token registraction is for previous IMS.
As the result, IME will crash when SoftInputWindow.show because the
windowState is still under TOKEN_PENDING and lose the token attachment.
To fix this crash timing issue, making
InputMethodPrivilegedOperationsRegistry be able to maintain more than
one pairs of IME token and IInputMethodPrivilegedOperations makes more
sense and we can remove the ignore logic in initializeInternal to
fix the token attachment issue.
[1]: Ie6bfbae735724fe744590e715124d2737d2b665d
Fix: 202081442
Test: atest CtsInputMethodTestCases
Test: atest MultiDisplaySystemDecorationTests
Change-Id: I21cec3f228520ed703cd8ad68ea0ef59c966ed9d
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 6999e3df0e2c..aa3c3611fc7d 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -590,10 +590,6 @@ public class InputMethodService extends AbstractInputMethodService { @Override public final void initializeInternal(@NonNull IBinder token, IInputMethodPrivilegedOperations privilegedOperations, int configChanges) { - if (InputMethodPrivilegedOperationsRegistry.isRegistered(token)) { - Log.w(TAG, "The token has already registered, ignore this initialization."); - return; - } Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initializeInternal"); mConfigTracker.onInitialize(configChanges); mPrivOps.set(privilegedOperations); |
