Merge "Skip IME initialization when received the token that already registered" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9bb2607703
@@ -472,8 +472,12 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
*/
|
*/
|
||||||
@MainThread
|
@MainThread
|
||||||
@Override
|
@Override
|
||||||
public final void initializeInternal(IBinder token, int displayId,
|
public final void initializeInternal(@NonNull IBinder token, int displayId,
|
||||||
IInputMethodPrivilegedOperations privilegedOperations) {
|
IInputMethodPrivilegedOperations privilegedOperations) {
|
||||||
|
if (InputMethodPrivilegedOperationsRegistry.isRegistered(token)) {
|
||||||
|
Log.w(TAG, "The token has already registered, ignore this initialization.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mPrivOps.set(privilegedOperations);
|
mPrivOps.set(privilegedOperations);
|
||||||
InputMethodPrivilegedOperationsRegistry.put(token, mPrivOps);
|
InputMethodPrivilegedOperationsRegistry.put(token, mPrivOps);
|
||||||
updateInputMethodDisplay(displayId);
|
updateInputMethodDisplay(displayId);
|
||||||
|
|||||||
@@ -132,4 +132,21 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user