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

Commit 99d84d42 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add IMM#invalidateInput()"

parents af9aa6d6 daa6695c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52548,6 +52548,7 @@ package android.view.inputmethod {
    method public boolean hideSoftInputFromWindow(android.os.IBinder, int);
    method public boolean hideSoftInputFromWindow(android.os.IBinder, int, android.os.ResultReceiver);
    method @Deprecated public void hideStatusIcon(android.os.IBinder);
    method public void invalidateInput(@NonNull android.view.View);
    method public boolean isAcceptingText();
    method public boolean isActive(android.view.View);
    method public boolean isActive();
+10 −0
Original line number Diff line number Diff line
@@ -67,6 +67,16 @@ public abstract class AbstractInputMethodService extends WindowProviderService
        implements KeyEvent.Callback {
    private InputMethod mInputMethod;

    /**
     * @return {@link InputMethod} instance returned from {@link #onCreateInputMethodInterface()}.
     *         {@code null} if {@link #onCreateInputMethodInterface()} is not yet called.
     * @hide
     */
    @Nullable
    protected final InputMethod getInputMethodInternal() {
        return mInputMethod;
    }

    /**
     * Keep the strong reference to {@link InputMethodServiceInternal} to ensure that it will not be
     * garbage-collected until {@link AbstractInputMethodService} gets garbage-collected.
+19 −0
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.InputMethodSession;

import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;
import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodSession;

class IInputMethodSessionWrapper extends IInputMethodSession.Stub
@@ -54,6 +56,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
    private static final int DO_NOTIFY_IME_HIDDEN = 120;
    private static final int DO_REMOVE_IME_SURFACE = 130;
    private static final int DO_FINISH_INPUT = 140;
    private static final int DO_INVALIDATE_INPUT = 150;


    @UnsupportedAppUsage
@@ -142,6 +145,16 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mInputMethodSession.finishInput();
                return;
            }
            case DO_INVALIDATE_INPUT: {
                final SomeArgs args = (SomeArgs) msg.obj;
                try {
                    mInputMethodSession.invalidateInputInternal((EditorInfo) args.arg1,
                            (IInputContext) args.arg2, msg.arg1);
                } finally {
                    args.recycle();
                }
                return;
            }
        }
        Log.w(TAG, "Unhandled message code: " + msg.what);
    }
@@ -217,6 +230,12 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_FINISH_SESSION));
    }

    @Override
    public void invalidateInput(EditorInfo editorInfo, IInputContext inputContext,  int sessionId) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(
                DO_INVALIDATE_INPUT, sessionId, editorInfo, inputContext));
    }

    @Override
    public void finishInput() {
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_FINISH_INPUT));
+24 −1
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import com.android.internal.inputmethod.ImeTracing;
import com.android.internal.inputmethod.InputMethodPrivilegedOperations;
import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry;
import com.android.internal.view.IInlineSuggestionsRequestCallback;
import com.android.internal.view.IInputContext;
import com.android.internal.view.InlineSuggestionsRequestInfo;

import java.io.FileDescriptor;
@@ -1063,6 +1064,28 @@ public class InputMethodService extends AbstractInputMethodService {
        public final void removeImeSurface() {
            InputMethodService.this.scheduleImeSurfaceRemoval();
        }

        /**
         * {@inheritDoc}
         * @hide
         */
        @Override
        public final void invalidateInputInternal(@NonNull EditorInfo editorInfo,
                @NonNull IInputContext inputContext, int sessionId) {
            if (mStartedInputConnection instanceof RemoteInputConnection) {
                final RemoteInputConnection ric = (RemoteInputConnection) mStartedInputConnection;
                if (!ric.isSameConnection(inputContext)) {
                    // This is not an error, and can be safely ignored.
                    if (DEBUG) {
                        Log.d(TAG, "ignoring invalidateInput() due to context mismatch.");
                    }
                    return;
                }
                editorInfo.makeCompatible(getApplicationInfo().targetSdkVersion);
                getInputMethodInternal().restartInput(new RemoteInputConnection(ric, sessionId),
                        editorInfo);
            }
        }
    }

    /**
+11 −0
Original line number Diff line number Diff line
@@ -103,6 +103,17 @@ final class RemoteInputConnection implements InputConnection {
        mCancellationGroup = cancellationGroup;
    }

    @AnyThread
    public boolean isSameConnection(@NonNull IInputContext inputContext) {
        return mInvoker.isSameConnection(inputContext);
    }

    RemoteInputConnection(@NonNull RemoteInputConnection original, int sessionId) {
        mImsInternal = original.mImsInternal;
        mInvoker = original.mInvoker.cloneWithSessionId(sessionId);
        mCancellationGroup = original.mCancellationGroup;
    }

    /**
     * See {@link InputConnection#getTextAfterCursor(int, int)}.
     */
Loading