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

Commit d55a7a68 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Passing back the SurfaceControl as part of InputMonitor" into udc-dev

parents 0a0ac21d 371de120
Loading
Loading
Loading
Loading
+22 −5
Original line number Original line Diff line number Diff line
@@ -43,7 +43,8 @@ public final class InputMonitor implements Parcelable {
    private final InputChannel mInputChannel;
    private final InputChannel mInputChannel;
    @NonNull
    @NonNull
    private final IInputMonitorHost mHost;
    private final IInputMonitorHost mHost;

    @NonNull
    private final SurfaceControl mSurface;


    /**
    /**
     * Takes all of the current pointer events streams that are currently being sent to this
     * Takes all of the current pointer events streams that are currently being sent to this
@@ -70,6 +71,7 @@ public final class InputMonitor implements Parcelable {
     */
     */
    public void dispose() {
    public void dispose() {
        mInputChannel.dispose();
        mInputChannel.dispose();
        mSurface.release();
        try {
        try {
            mHost.dispose();
            mHost.dispose();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
@@ -95,13 +97,17 @@ public final class InputMonitor implements Parcelable {
    @DataClass.Generated.Member
    @DataClass.Generated.Member
    public InputMonitor(
    public InputMonitor(
            @NonNull InputChannel inputChannel,
            @NonNull InputChannel inputChannel,
            @NonNull IInputMonitorHost host) {
            @NonNull IInputMonitorHost host,
            @NonNull SurfaceControl surface) {
        this.mInputChannel = inputChannel;
        this.mInputChannel = inputChannel;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mInputChannel);
                NonNull.class, null, mInputChannel);
        this.mHost = host;
        this.mHost = host;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mHost);
                NonNull.class, null, mHost);
        this.mSurface = surface;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mSurface);


        // onConstructed(); // You can define this method to get a callback
        // onConstructed(); // You can define this method to get a callback
    }
    }
@@ -116,6 +122,11 @@ public final class InputMonitor implements Parcelable {
        return mHost;
        return mHost;
    }
    }


    @DataClass.Generated.Member
    public @NonNull SurfaceControl getSurface() {
        return mSurface;
    }

    @Override
    @Override
    @DataClass.Generated.Member
    @DataClass.Generated.Member
    public String toString() {
    public String toString() {
@@ -124,7 +135,8 @@ public final class InputMonitor implements Parcelable {


        return "InputMonitor { " +
        return "InputMonitor { " +
                "inputChannel = " + mInputChannel + ", " +
                "inputChannel = " + mInputChannel + ", " +
                "host = " + mHost +
                "host = " + mHost + ", " +
                "surface = " + mSurface +
        " }";
        " }";
    }
    }


@@ -136,6 +148,7 @@ public final class InputMonitor implements Parcelable {


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


    @Override
    @Override
@@ -151,6 +164,7 @@ public final class InputMonitor implements Parcelable {


        InputChannel inputChannel = (InputChannel) in.readTypedObject(InputChannel.CREATOR);
        InputChannel inputChannel = (InputChannel) in.readTypedObject(InputChannel.CREATOR);
        IInputMonitorHost host = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
        IInputMonitorHost host = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
        SurfaceControl surface = (SurfaceControl) in.readTypedObject(SurfaceControl.CREATOR);


        this.mInputChannel = inputChannel;
        this.mInputChannel = inputChannel;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
@@ -158,6 +172,9 @@ public final class InputMonitor implements Parcelable {
        this.mHost = host;
        this.mHost = host;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mHost);
                NonNull.class, null, mHost);
        this.mSurface = surface;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mSurface);


        // onConstructed(); // You can define this method to get a callback
        // onConstructed(); // You can define this method to get a callback
    }
    }
@@ -177,10 +194,10 @@ public final class InputMonitor implements Parcelable {
    };
    };


    @DataClass.Generated(
    @DataClass.Generated(
            time = 1637697281750L,
            time = 1679692514588L,
            codegenVersion = "1.0.23",
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/view/InputMonitor.java",
            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 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)")
            inputSignatures = "private static final  java.lang.String TAG\nprivate static final  boolean DEBUG\nprivate final @android.annotation.NonNull android.view.InputChannel mInputChannel\nprivate final @android.annotation.NonNull android.view.IInputMonitorHost mHost\nprivate final @android.annotation.NonNull android.view.SurfaceControl mSurface\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
    @Deprecated
    private void __metadata() {}
    private void __metadata() {}


+13 −10
Original line number Original line Diff line number Diff line
@@ -686,13 +686,7 @@ public class InputManagerService extends IInputManager.Stub


    @NonNull
    @NonNull
    private InputChannel createSpyWindowGestureMonitor(IBinder monitorToken, String name,
    private InputChannel createSpyWindowGestureMonitor(IBinder monitorToken, String name,
            int displayId, int pid, int uid) {
            SurfaceControl sc, int displayId, int pid, int uid) {
        final SurfaceControl sc = mWindowManagerCallbacks.createSurfaceForGestureMonitor(name,
                displayId);
        if (sc == null) {
            throw new IllegalArgumentException(
                    "Could not create gesture monitor surface on display: " + displayId);
        }
        final InputChannel channel = createInputChannel(name);
        final InputChannel channel = createInputChannel(name);


        try {
        try {
@@ -749,9 +743,18 @@ public class InputManagerService extends IInputManager.Stub


        final long ident = Binder.clearCallingIdentity();
        final long ident = Binder.clearCallingIdentity();
        try {
        try {
            final InputChannel inputChannel =
            final SurfaceControl sc = mWindowManagerCallbacks.createSurfaceForGestureMonitor(name,
                            createSpyWindowGestureMonitor(monitorToken, name, displayId, pid, uid);
                    displayId);
            return new InputMonitor(inputChannel, new InputMonitorHost(inputChannel.getToken()));
            if (sc == null) {
                throw new IllegalArgumentException(
                        "Could not create gesture monitor surface on display: " + displayId);
            }

            final InputChannel inputChannel = createSpyWindowGestureMonitor(
                    monitorToken, name, sc, displayId, pid, uid);
            return new InputMonitor(inputChannel,
                new InputMonitorHost(inputChannel.getToken()),
                new SurfaceControl(sc, "IMS.monitorGestureInput"));
        } finally {
        } finally {
            Binder.restoreCallingIdentity(ident);
            Binder.restoreCallingIdentity(ident);
        }
        }