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

Commit c2420f96 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Annotate lock-free method in InputMethodManagerInternal" into main

parents 2b06a160 8dc058d8
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.inputmethod;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -30,6 +32,9 @@ import com.android.internal.inputmethod.InlineSuggestionsRequestInfo;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.server.LocalServices;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.Collections;
import java.util.List;

@@ -37,6 +42,16 @@ import java.util.List;
 * Input method manager local system service interface.
 */
public abstract class InputMethodManagerInternal {
    /**
     * Indicates that the method is guaranteed to not require {@link ImfLock}.
     *
     * <p>You can call this method without worrying about system_server lock layering.</p>
     */
    @Retention(SOURCE)
    @Target({ElementType.METHOD})
    public @interface ImfLockFree {
    }

    /**
     * Listener for input method list changed events.
     */
@@ -53,6 +68,7 @@ public abstract class InputMethodManagerInternal {
     *
     * @param interactive the interactive mode parameter
     */
    @ImfLockFree
    public abstract void setInteractive(boolean interactive);

    /**
@@ -61,6 +77,7 @@ public abstract class InputMethodManagerInternal {
     * @param reason               the reason for hiding the current input method
     * @param originatingDisplayId the display ID the request is originated
     */
    @ImfLockFree
    public abstract void hideAllInputMethods(@SoftInputShowHideReason int reason,
            int originatingDisplayId);

@@ -143,6 +160,7 @@ public abstract class InputMethodManagerInternal {
     *
     * @param listener the listener to add
     */
    @ImfLockFree
    public abstract void registerInputMethodListListener(InputMethodListListener listener);

    /**
@@ -178,6 +196,7 @@ public abstract class InputMethodManagerInternal {
     *
     * @param displayId the display hosting the IME window
     */
    @ImfLockFree
    public abstract void removeImeSurface(int displayId);

    /**
@@ -188,12 +207,14 @@ public abstract class InputMethodManagerInternal {
     * @param disableImeIcon indicates whether IME icon should be enabled or not
     * @param displayId      the display for which to update the IME window status
     */
    @ImfLockFree
    public abstract void updateImeWindowStatus(boolean disableImeIcon, int displayId);

    /**
     * Finish stylus handwriting by calling {@link InputMethodService#finishStylusHandwriting()} if
     * there is an ongoing handwriting session.
     */
    @ImfLockFree
    public abstract void maybeFinishStylusHandwriting();

    /**
@@ -240,10 +261,12 @@ public abstract class InputMethodManagerInternal {
     */
    private static final InputMethodManagerInternal NOP =
            new InputMethodManagerInternal() {
                @ImfLockFree
                @Override
                public void setInteractive(boolean interactive) {
                }

                @ImfLockFree
                @Override
                public void hideAllInputMethods(@SoftInputShowHideReason int reason,
                        int originatingDisplayId) {
@@ -282,6 +305,7 @@ public abstract class InputMethodManagerInternal {
                        int deviceId, @Nullable String imeId) {
                }

                @ImfLockFree
                @Override
                public void registerInputMethodListListener(InputMethodListListener listener) {
                }
@@ -300,10 +324,12 @@ public abstract class InputMethodManagerInternal {
                public void onImeParentChanged(int displayId) {
                }

                @ImfLockFree
                @Override
                public void removeImeSurface(int displayId) {
                }

                @ImfLockFree
                @Override
                public void updateImeWindowStatus(boolean disableImeIcon, int displayId) {
                }
@@ -318,6 +344,7 @@ public abstract class InputMethodManagerInternal {
                        @UserIdInt int userId) {
                }

                @ImfLockFree
                @Override
                public void maybeFinishStylusHandwriting() {
                }
+6 −0
Original line number Diff line number Diff line
@@ -5500,12 +5500,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    private final class LocalServiceImpl extends InputMethodManagerInternal {

        @ImfLockFree
        @Override
        public void setInteractive(boolean interactive) {
            // Do everything in handler so as not to block the caller.
            mHandler.obtainMessage(MSG_SET_INTERACTIVE, interactive ? 1 : 0, 0).sendToTarget();
        }

        @ImfLockFree
        @Override
        public void hideAllInputMethods(@SoftInputShowHideReason int reason,
                int originatingDisplayId) {
@@ -5591,6 +5593,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            }
        }

        @ImfLockFree
        @Override
        public void registerInputMethodListListener(InputMethodListListener listener) {
            mInputMethodListListeners.addIfAbsent(listener);
@@ -5638,11 +5641,13 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            }
        }

        @ImfLockFree
        @Override
        public void removeImeSurface(int displayId) {
            mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget();
        }

        @ImfLockFree
        @Override
        public void updateImeWindowStatus(boolean disableImeIcon, int displayId) {
            mHandler.obtainMessage(MSG_UPDATE_IME_WINDOW_STATUS, disableImeIcon ? 1 : 0, 0)
@@ -5720,6 +5725,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            }
        }

        @ImfLockFree
        @Override
        public void maybeFinishStylusHandwriting() {
            mHandler.removeMessages(MSG_FINISH_HANDWRITING);