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

Commit b313d3a5 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Unregister input channel by token

We don't need to pass the entire InputChannel (which includes the fd) to
unregister it. We can just unregister it by its token.

Bug: 167947395
Test: atest libinput_tests
Change-Id: If48ba73fe9c569b89c1f0500e18e005d92eb5b29
parent aa9a577c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ public class InputManagerService extends IInputManager.Stub
    private static native void nativeRegisterInputChannel(long ptr, InputChannel inputChannel);
    private static native void nativeRegisterInputMonitor(long ptr, InputChannel inputChannel,
            int displayId, boolean isGestureMonitor);
    private static native void nativeUnregisterInputChannel(long ptr, InputChannel inputChannel);
    private static native void nativeUnregisterInputChannel(long ptr, IBinder connectionToken);
    private static native void nativePilferPointers(long ptr, IBinder token);
    private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
    private static native void nativeSetInTouchMode(long ptr, boolean inTouchMode);
@@ -581,17 +581,17 @@ public class InputManagerService extends IInputManager.Stub

    /**
     * Unregisters an input channel.
     * @param inputChannel The input channel to unregister.
     * @param connectionToken The input channel to unregister.
     */
    public void unregisterInputChannel(InputChannel inputChannel) {
        if (inputChannel == null) {
            throw new IllegalArgumentException("inputChannel must not be null.");
    public void unregisterInputChannel(IBinder connectionToken) {
        if (connectionToken == null) {
            throw new IllegalArgumentException("connectionToken must not be null.");
        }
        synchronized (mGestureMonitorPidsLock) {
            mGestureMonitorPidsByToken.remove(inputChannel.getToken());
            mGestureMonitorPidsByToken.remove(connectionToken);
        }

        nativeUnregisterInputChannel(mPtr, inputChannel);
        nativeUnregisterInputChannel(mPtr, connectionToken);
    }

    /**
@@ -2455,7 +2455,7 @@ public class InputManagerService extends IInputManager.Stub

        @Override
        public void dispose() {
            nativeUnregisterInputChannel(mPtr, mInputChannel);
            nativeUnregisterInputChannel(mPtr, mInputChannel.getToken());
            mInputChannel.dispose();
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ class DragState {
        }

        void tearDown() {
            mService.mInputManager.unregisterInputChannel(mServerChannel);
            mService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
            mInputEventReceiver.dispose();
            mInputEventReceiver = null;
            mClientChannel.dispose();
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ class EmbeddedWindowController {

        void onRemoved() {
            if (mInputChannel != null) {
                mWmService.mInputManager.unregisterInputChannel(mInputChannel);
                mWmService.mInputManager.unregisterInputChannel(mInputChannel.getToken());
                mInputChannel.dispose();
                mInputChannel = null;
            }
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ class InputConsumerImpl implements IBinder.DeathRecipient {
    }

    void disposeChannelsLw(SurfaceControl.Transaction t) {
        mService.mInputManager.unregisterInputChannel(mServerChannel);
        mService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
        mClientChannel.dispose();
        mServerChannel.dispose();
        t.remove(mInputSurface);
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ public class Letterbox {
        }

        void dispose() {
            mWmService.mInputManager.unregisterInputChannel(mServerChannel);
            mWmService.mInputManager.unregisterInputChannel(mServerChannel.getToken());
            mInputEventReceiver.dispose();
            mServerChannel.dispose();
            mClientChannel.dispose();
Loading