Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +13 −7 Original line number Diff line number Diff line Loading @@ -23,12 +23,12 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERL import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER; import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_BOTTOM; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_LEFT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_RIGHT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_TOP; import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEdgeResizePermitted; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEventFromTouchscreen; Loading Loading @@ -127,7 +127,9 @@ class DragResizeInputListener implements AutoCloseable { Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, DisplayController displayController, DesktopModeEventLogger desktopModeEventLogger) { DesktopModeEventLogger desktopModeEventLogger, InputChannel inputChannel, InputChannel sinkInputChannel) { mContext = context; mWindowSession = windowSession; mBgExecutor = bgExecutor; Loading @@ -154,9 +156,13 @@ class DragResizeInputListener implements AutoCloseable { final InputSetUpResult result = setUpInputChannels(mDisplayId, mWindowSession, mDecorationSurface, mClientToken, mSinkClientToken, mSurfaceControlBuilderSupplier, mSurfaceControlTransactionSupplier); mSurfaceControlTransactionSupplier, inputChannel, sinkInputChannel); mainExecutor.execute(() -> { if (mClosed) { result.mInputChannel.dispose(); result.mSinkInputChannel.dispose(); mSurfaceControlTransactionSupplier.get().remove( result.mInputSinkSurface).apply(); return; } mInputSinkSurface = result.mInputSinkSurface; Loading Loading @@ -208,7 +214,7 @@ class DragResizeInputListener implements AutoCloseable { new DefaultTaskResizeInputEventReceiverFactory(), taskInfo, handler, choreographer, displayId, decorationSurface, callback, surfaceControlBuilderSupplier, surfaceControlTransactionSupplier, displayController, desktopModeEventLogger); displayController, desktopModeEventLogger, new InputChannel(), new InputChannel()); } DragResizeInputListener( Loading Loading @@ -251,11 +257,11 @@ class DragResizeInputListener implements AutoCloseable { @NonNull IBinder clientToken, @NonNull IBinder sinkClientToken, @NonNull Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier) { @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, @NonNull InputChannel inputChannel, @NonNull InputChannel sinkInputChannel) { Trace.beginSection("DragResizeInputListener#setUpInputChannels"); final InputTransferToken inputTransferToken = new InputTransferToken(); final InputChannel inputChannel = new InputChannel(); final InputChannel sinkInputChannel = new InputChannel(); try { windowSession.grantInputChannel( displayId, Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ class DragResizeInputListenerTest : ShellTestCase() { private val testBgExecutor = TestShellExecutor() private val mockWindowSession = mock<IWindowSession>() private val mockInputEventReceiver = mock<TaskResizeInputEventReceiver>() private val inputChannel = mock<InputChannel>() private val sinkInputChannel = mock<InputChannel>() @Test fun testGrantInputChannelOffMainThread() { Loading Loading @@ -143,6 +145,16 @@ class DragResizeInputListenerTest : ShellTestCase() { verify(mockWindowSession).remove(inputListener.mSinkClientToken) } @Test fun testClose_afterBgSetup_disposesOfInputChannels() { val inputListener = create() testBgExecutor.flushAll() inputListener.close() testMainExecutor.flushAll() verify(inputChannel).dispose() verify(sinkInputChannel).dispose() } private fun verifyNoInputChannelGrantRequests() { verify(mockWindowSession, never()) .grantInputChannel( Loading Loading @@ -178,6 +190,8 @@ class DragResizeInputListenerTest : ShellTestCase() { { StubTransaction() }, mock<DisplayController>(), mock<DesktopModeEventLogger>(), inputChannel, sinkInputChannel, ) private class TestInitializationCallback : Runnable { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +13 −7 Original line number Diff line number Diff line Loading @@ -23,12 +23,12 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERL import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER; import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_BOTTOM; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_LEFT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_RIGHT; import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_TOP; import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEdgeResizePermitted; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEventFromTouchscreen; Loading Loading @@ -127,7 +127,9 @@ class DragResizeInputListener implements AutoCloseable { Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, DisplayController displayController, DesktopModeEventLogger desktopModeEventLogger) { DesktopModeEventLogger desktopModeEventLogger, InputChannel inputChannel, InputChannel sinkInputChannel) { mContext = context; mWindowSession = windowSession; mBgExecutor = bgExecutor; Loading @@ -154,9 +156,13 @@ class DragResizeInputListener implements AutoCloseable { final InputSetUpResult result = setUpInputChannels(mDisplayId, mWindowSession, mDecorationSurface, mClientToken, mSinkClientToken, mSurfaceControlBuilderSupplier, mSurfaceControlTransactionSupplier); mSurfaceControlTransactionSupplier, inputChannel, sinkInputChannel); mainExecutor.execute(() -> { if (mClosed) { result.mInputChannel.dispose(); result.mSinkInputChannel.dispose(); mSurfaceControlTransactionSupplier.get().remove( result.mInputSinkSurface).apply(); return; } mInputSinkSurface = result.mInputSinkSurface; Loading Loading @@ -208,7 +214,7 @@ class DragResizeInputListener implements AutoCloseable { new DefaultTaskResizeInputEventReceiverFactory(), taskInfo, handler, choreographer, displayId, decorationSurface, callback, surfaceControlBuilderSupplier, surfaceControlTransactionSupplier, displayController, desktopModeEventLogger); displayController, desktopModeEventLogger, new InputChannel(), new InputChannel()); } DragResizeInputListener( Loading Loading @@ -251,11 +257,11 @@ class DragResizeInputListener implements AutoCloseable { @NonNull IBinder clientToken, @NonNull IBinder sinkClientToken, @NonNull Supplier<SurfaceControl.Builder> surfaceControlBuilderSupplier, @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier) { @NonNull Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier, @NonNull InputChannel inputChannel, @NonNull InputChannel sinkInputChannel) { Trace.beginSection("DragResizeInputListener#setUpInputChannels"); final InputTransferToken inputTransferToken = new InputTransferToken(); final InputChannel inputChannel = new InputChannel(); final InputChannel sinkInputChannel = new InputChannel(); try { windowSession.grantInputChannel( displayId, Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DragResizeInputListenerTest.kt +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ class DragResizeInputListenerTest : ShellTestCase() { private val testBgExecutor = TestShellExecutor() private val mockWindowSession = mock<IWindowSession>() private val mockInputEventReceiver = mock<TaskResizeInputEventReceiver>() private val inputChannel = mock<InputChannel>() private val sinkInputChannel = mock<InputChannel>() @Test fun testGrantInputChannelOffMainThread() { Loading Loading @@ -143,6 +145,16 @@ class DragResizeInputListenerTest : ShellTestCase() { verify(mockWindowSession).remove(inputListener.mSinkClientToken) } @Test fun testClose_afterBgSetup_disposesOfInputChannels() { val inputListener = create() testBgExecutor.flushAll() inputListener.close() testMainExecutor.flushAll() verify(inputChannel).dispose() verify(sinkInputChannel).dispose() } private fun verifyNoInputChannelGrantRequests() { verify(mockWindowSession, never()) .grantInputChannel( Loading Loading @@ -178,6 +190,8 @@ class DragResizeInputListenerTest : ShellTestCase() { { StubTransaction() }, mock<DisplayController>(), mock<DesktopModeEventLogger>(), inputChannel, sinkInputChannel, ) private class TestInitializationCallback : Runnable { Loading