Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9992e088 authored by lumark's avatar lumark Committed by android-build-merger
Browse files

Merge "Skip IME initialization when received the token that already registered" into qt-dev

am: 9bb26077

Change-Id: I47e3521b214d5b5e057c979dfe8d96696bd42009
parents 4236f986 9bb26077
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -472,8 +472,12 @@ public class InputMethodService extends AbstractInputMethodService {
         */
        @MainThread
        @Override
        public final void initializeInternal(IBinder token, int displayId,
        public final void initializeInternal(@NonNull IBinder token, int displayId,
                IInputMethodPrivilegedOperations privilegedOperations) {
            if (InputMethodPrivilegedOperationsRegistry.isRegistered(token)) {
                Log.w(TAG, "The token has already registered, ignore this initialization.");
                return;
            }
            mPrivOps.set(privilegedOperations);
            InputMethodPrivilegedOperationsRegistry.put(token, mPrivOps);
            updateInputMethodDisplay(displayId);
+17 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}