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

Commit 5b848f27 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Implement InputConnection task cancellation

This CL introduces the task cancellation mechanism into
RemoteInputConnection and RemoteInputConnectionImpl.

The code idea is to ignore InputConnection tasks if the session IDs do
not match.  By incrementing the session ID upon every "interruption",
we can effectively cancel any pending events issued before the
"interruption" happened.

Note that even with this CL RemoteInputConnection and
RemoteInputConnectionImpl still uses "0" as the session ID.
Hence there should be no user observable behavior change yet.

Fix: 203086369
Test: presubmit
Change-Id: I383c3958d2ac1a8d217706509fa12a92b381bbb3
parent 40a525de
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ public final class IInputContextInvoker {

    @NonNull
    InputConnectionCommandHeader createHeader() {
        return new InputConnectionCommandHeader();
        // TODO(b/203086369): Propagate session ID for interruption
        return new InputConnectionCommandHeader(0 /* sessionId */);
    }

    /**
+16 −2
Original line number Diff line number Diff line
@@ -25,7 +25,19 @@ import android.os.Parcelable;
 * {@link android.inputmethodservice.RemoteInputConnection}.
 */
public final class InputConnectionCommandHeader implements Parcelable {
    public InputConnectionCommandHeader() {
    /**
     * An identifier that is to be used when multiplexing multiple sessions into a single
     * {@link com.android.internal.view.IInputContext}.
     *
     * <p>This ID is considered to belong to an implicit namespace defined for each
     * {@link com.android.internal.view.IInputContext} instance.  Uniqueness of the session ID
     * across multiple instances of {@link com.android.internal.view.IInputContext} is not
     * guaranteed unless explicitly noted in a higher layer.</p>
     */
    public final int mSessionId;

    public InputConnectionCommandHeader(int sessionId) {
        mSessionId = sessionId;
    }

    @Override
@@ -38,7 +50,8 @@ public final class InputConnectionCommandHeader implements Parcelable {
            new Parcelable.Creator<InputConnectionCommandHeader>() {
                @NonNull
                public InputConnectionCommandHeader createFromParcel(Parcel in) {
                    return new InputConnectionCommandHeader();
                    final int sessionId = in.readInt();
                    return new InputConnectionCommandHeader(sessionId);
                }

                @NonNull
@@ -49,5 +62,6 @@ public final class InputConnectionCommandHeader implements Parcelable {

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mSessionId);
    }
}
+123 −0

File changed.

Preview size limit exceeded, changes collapsed.