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

Commit 29aea7fa authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use DataClass annotation for InputMonitor

To test out the new codegen functionality, convert the InputMonitor
class to use the @DataClass annotation.

Test: presubmit
Bug: none
Change-Id: Idcddb410555aba0c45fe4997db8b662548ce1c39
parent ea5c362d
Loading
Loading
Loading
Loading
+102 −50
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;

import com.android.internal.util.DataClass;

/**
 * An {@code InputMonitor} allows privileged applications and components to monitor streams of
 * {@link InputEvent}s without having to be the designated recipient for the event.
@@ -31,57 +33,19 @@ import android.os.RemoteException;
 *
 * @hide
 */
@DataClass(genToString = true)
public final class InputMonitor implements Parcelable {
    private static final String TAG = "InputMonitor";

    private static final boolean DEBUG = false;

    public static final Parcelable.Creator<InputMonitor> CREATOR =
            new Parcelable.Creator<InputMonitor>() {

            public InputMonitor createFromParcel(Parcel source) {
                return new InputMonitor(source);
            }

            public InputMonitor[] newArray(int size) {
                return new InputMonitor[size];
            }
    };

    @NonNull
    private final String mName;
    @NonNull
    private final InputChannel mChannel;
    private final InputChannel mInputChannel;
    @NonNull
    private final IInputMonitorHost mHost;

    public InputMonitor(@NonNull String name, @NonNull InputChannel channel,
            @NonNull IInputMonitorHost host) {
        mName = name;
        mChannel = channel;
        mHost = host;
    }

    public InputMonitor(Parcel in) {
        mName = in.readString();
        mChannel = in.readParcelable(null);
        mHost = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
    }

    /**
     * Get the {@link InputChannel} corresponding to this InputMonitor
     */
    public InputChannel getInputChannel() {
        return mChannel;
    }

    /**
     * Get the name of this channel.
     */
    public String getName() {
        return mName;
    }


    /**
     * Takes all of the current pointer events streams that are currently being sent to this
@@ -107,7 +71,7 @@ public final class InputMonitor implements Parcelable {
     * no longer be used.
     */
    public void dispose() {
        mChannel.dispose();
        mInputChannel.dispose();
        try {
            mHost.dispose();
        } catch (RemoteException e) {
@@ -115,20 +79,108 @@ public final class InputMonitor implements Parcelable {
        }
    }



    // Code below generated by codegen v1.0.1.
    //
    // DO NOT MODIFY!
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/InputMonitor.java
    //
    // CHECKSTYLE:OFF Generated code

    @DataClass.Generated.Member
    public InputMonitor(
            @NonNull String name,
            @NonNull InputChannel inputChannel,
            @NonNull IInputMonitorHost host) {
        this.mName = name;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mName);
        this.mInputChannel = inputChannel;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mInputChannel);
        this.mHost = host;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mHost);

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public @NonNull String getName() {
        return mName;
    }

    @DataClass.Generated.Member
    public @NonNull InputChannel getInputChannel() {
        return mInputChannel;
    }

    @DataClass.Generated.Member
    public @NonNull IInputMonitorHost getHost() {
        return mHost;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(mName);
        out.writeParcelable(mChannel, flags);
        out.writeStrongBinder(mHost.asBinder());
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "InputMonitor { " +
                "name = " + mName + ", " +
                "inputChannel = " + mInputChannel + ", " +
                "host = " + mHost +
        " }";
    }

    @Override
    public int describeContents() {
        return 0;
    @DataClass.Generated.Member
    public void writeToParcel(Parcel dest, int flags) {
        // You can override field parcelling by defining methods like:
        // void parcelFieldName(Parcel dest, int flags) { ... }

        dest.writeString(mName);
        dest.writeTypedObject(mInputChannel, flags);
        dest.writeStrongInterface(mHost);
    }

    @Override
    public String toString() {
        return "InputMonitor{mName=" + mName + ", mChannel=" + mChannel + ", mHost=" + mHost + "}";
    @DataClass.Generated.Member
    public int describeContents() { return 0; }

    @DataClass.Generated.Member
    public static final @NonNull Parcelable.Creator<InputMonitor> CREATOR
            = new Parcelable.Creator<InputMonitor>() {
        @Override
        public InputMonitor[] newArray(int size) {
            return new InputMonitor[size];
        }

        @Override
        @SuppressWarnings({"unchecked", "RedundantCast"})
        public InputMonitor createFromParcel(Parcel in) {
            // You can override field unparcelling by defining methods like:
            // static FieldType unparcelFieldName(Parcel in) { ... }

            String name = in.readString();
            InputChannel inputChannel = (InputChannel) in.readTypedObject(InputChannel.CREATOR);
            IInputMonitorHost host = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
            return new InputMonitor(
                    name,
                    inputChannel,
                    host);
        }
    };

    @DataClass.Generated(
            time = 1569871940995L,
            codegenVersion = "1.0.1",
            sourceFile = "frameworks/base/core/java/android/view/InputMonitor.java",
            inputSignatures = "private static final  java.lang.String TAG\nprivate static final  boolean DEBUG\nprivate final @android.annotation.NonNull java.lang.String mName\nprivate final @android.annotation.NonNull android.view.InputChannel mInputChannel\nprivate final @android.annotation.NonNull android.view.IInputMonitorHost mHost\npublic  void pilferPointers()\npublic  void dispose()\nclass InputMonitor extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true)")
    @Deprecated
    private void __metadata() {}

}