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

Commit 7aef3e50 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Initiate drag and drop using channel tokens

When the drag and drop is started, the input system only needs to know
the tokens of the windows that are involved. The input channels don't
need to be provided; in fact, in a future CL, the input channel won't
even be stored inside the caller (since the WM code initiates drag and
drop on behalf of the app).

In this CL, only the source is modified to use the channel token instead
of channel. In a separate CL, the target will also be modified.

Bug: 323450804
Test: atest android.view.surfacecontrol.cts.SurfaceControlViewHostTests
Test: atest WmTests:com.android.server.wm.DragDropControllerTests
Flag: EXEMPT refactor
Change-Id: Ie1d4a1a5d0be1c2b80d33a160e1b00ec69fe2517
parent 5145363d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1259,9 +1259,9 @@ public class InputManagerService extends IInputManager.Stub
     * @param dragAndDropChannel The input channel associated with the system drag window.
     * @return true if drag and drop was successfully started, false otherwise.
     */
    public boolean startDragAndDrop(@NonNull InputChannel fromChannel,
    public boolean startDragAndDrop(@NonNull IBinder fromChannelToken,
            @NonNull InputChannel dragAndDropChannel) {
        return mNative.transferTouchGesture(fromChannel.getToken(), dragAndDropChannel.getToken(),
        return mNative.transferTouchGesture(fromChannelToken, dragAndDropChannel.getToken(),
                true /* isDragDrop */);
    }

+1 −1
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ public abstract class WindowManagerInternal {
                InputChannel source) {
            return state.register(display)
                .thenApply(unused ->
                    service.startDragAndDrop(source, state.getInputChannel()));
                    service.startDragAndDrop(source.getToken(), state.getInputChannel()));
        }

        /**
+4 −5
Original line number Diff line number Diff line
@@ -152,8 +152,8 @@ public class DragDropControllerTests extends WindowTestsBase {
        // Use a new TestIWindow so we don't collect events for other windows
        final WindowState window = createWindow(
                null, TYPE_BASE_APPLICATION, activity, name, ownerId, false, new TestIWindow());
        window.mInputChannel = new InputChannel();
        window.mInputChannelToken = window.mInputChannel.getToken();
        InputChannel channel = new InputChannel();
        window.openInputChannel(channel);
        window.mHasSurface = true;
        mWm.mWindowMap.put(window.mClient.asBinder(), window);
        mWm.mInputToWindowMap.put(window.mInputChannelToken, window);
@@ -178,7 +178,7 @@ public class DragDropControllerTests extends WindowTestsBase {
                TEST_PID, TEST_UID);
        mWindow = createDropTargetWindow("Drag test window", 0);
        doReturn(mWindow).when(mDisplayContent).getTouchableWinAtPointLocked(0, 0);
        when(mWm.mInputManager.startDragAndDrop(any(InputChannel.class),
        when(mWm.mInputManager.startDragAndDrop(any(IBinder.class),
                any(InputChannel.class))).thenReturn(true);

        mWm.mWindowMap.put(mWindow.mClient.asBinder(), mWindow);
@@ -707,8 +707,7 @@ public class DragDropControllerTests extends WindowTestsBase {
                    .setFormat(PixelFormat.TRANSLUCENT)
                    .build();

            assertTrue(mWm.mInputManager.startDragAndDrop(new InputChannel(),
                    new InputChannel()));
            assertTrue(mWm.mInputManager.startDragAndDrop(new Binder(), new InputChannel()));
            mToken = mTarget.performDrag(TEST_PID, 0, mWindow.mClient,
                    flag, surface, 0, 0, 0, 0, 0, 0, 0, data);
            assertNotNull(mToken);