Merge "Fix IME crash on SoftInputWindow.show by TOKEN_PENDING"

This commit is contained in:
Ming-Shin Lu
2021-10-14 04:33:35 +00:00
committed by Android (Google) Code Review
2 changed files with 1 additions and 27 deletions

View File

@@ -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);

View File

@@ -74,12 +74,7 @@ public final class InputMethodPrivilegedOperationsRegistry {
if (sRegistry == null) {
sRegistry = new WeakHashMap<>();
}
final WeakReference<InputMethodPrivilegedOperations> previousOps =
sRegistry.put(token, new WeakReference<>(ops));
if (previousOps != null) {
throw new IllegalStateException(previousOps.get() + " is already registered for "
+ " this token=" + token + " newOps=" + ops);
}
sRegistry.put(token, new WeakReference<>(ops));
}
}
@@ -132,21 +127,4 @@ public final class InputMethodPrivilegedOperationsRegistry {
}
}
}
/**
* Check the given IME token registration status.
*
* @param token IME token
* @return {@code true} when the IME token has already registered
* {@link InputMethodPrivilegedOperations}, {@code false} otherwise.
*/
@AnyThread
public static boolean isRegistered(IBinder token) {
synchronized (sLock) {
if (sRegistry == null) {
return false;
}
return sRegistry.containsKey(token);
}
}
}