Loading services/companion/java/com/android/server/companion/virtual/InputController.java +8 −8 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeButtonEvent(inputDeviceDescriptor.getNativePointer(), event.getButtonCode(), event.getAction(), event.getEventTimeNanos()); Loading Loading @@ -373,8 +373,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeRelativeEvent(inputDeviceDescriptor.getNativePointer(), event.getRelativeX(), event.getRelativeY(), event.getEventTimeNanos()); Loading @@ -390,8 +390,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeScrollEvent(inputDeviceDescriptor.getNativePointer(), event.getXAxisMovement(), event.getYAxisMovement(), event.getEventTimeNanos()); Loading @@ -408,8 +408,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return LocalServices.getService(InputManagerInternal.class).getCursorPosition(); } Loading services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +0 −48 Original line number Diff line number Diff line Loading @@ -1254,22 +1254,6 @@ public class VirtualDeviceManagerServiceTest { verify(mNativeWrapperMock).writeButtonEvent(fd, buttonCode, action, eventTimeNanos); } @Test public void sendButtonEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final int buttonCode = VirtualMouseButtonEvent.BUTTON_BACK; final int action = VirtualMouseButtonEvent.ACTION_BUTTON_PRESS; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendButtonEvent(BINDER, new VirtualMouseButtonEvent.Builder() .setButtonCode(buttonCode) .setAction(action).build())); } @Test public void sendRelativeEvent_noFd() { assertThat(mDeviceImpl.sendRelativeEvent(BINDER, Loading Loading @@ -1301,22 +1285,6 @@ public class VirtualDeviceManagerServiceTest { } @Test public void sendRelativeEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final float x = -0.2f; final float y = 0.7f; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendRelativeEvent(BINDER, new VirtualMouseRelativeEvent.Builder() .setRelativeX(x).setRelativeY(y).build())); } @Test public void sendScrollEvent_noFd() { assertThat(mDeviceImpl.sendScrollEvent(BINDER, Loading Loading @@ -1348,22 +1316,6 @@ public class VirtualDeviceManagerServiceTest { } @Test public void sendScrollEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final float x = 0.5f; final float y = 1f; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendScrollEvent(BINDER, new VirtualMouseScrollEvent.Builder() .setXAxisMovement(x) .setYAxisMovement(y).build())); } @Test public void sendTouchEvent_noFd() { assertThat(mDeviceImpl.sendTouchEvent(BINDER, Loading Loading
services/companion/java/com/android/server/companion/virtual/InputController.java +8 −8 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeButtonEvent(inputDeviceDescriptor.getNativePointer(), event.getButtonCode(), event.getAction(), event.getEventTimeNanos()); Loading Loading @@ -373,8 +373,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeRelativeEvent(inputDeviceDescriptor.getNativePointer(), event.getRelativeX(), event.getRelativeY(), event.getEventTimeNanos()); Loading @@ -390,8 +390,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return mNativeWrapper.writeScrollEvent(inputDeviceDescriptor.getNativePointer(), event.getXAxisMovement(), event.getYAxisMovement(), event.getEventTimeNanos()); Loading @@ -408,8 +408,8 @@ class InputController { } if (inputDeviceDescriptor.getDisplayId() != mInputManagerInternal.getVirtualMousePointerDisplayId()) { throw new IllegalStateException( "Display id associated with this mouse is not currently targetable"); mInputManagerInternal.setVirtualMousePointerDisplayId( inputDeviceDescriptor.getDisplayId()); } return LocalServices.getService(InputManagerInternal.class).getCursorPosition(); } Loading
services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +0 −48 Original line number Diff line number Diff line Loading @@ -1254,22 +1254,6 @@ public class VirtualDeviceManagerServiceTest { verify(mNativeWrapperMock).writeButtonEvent(fd, buttonCode, action, eventTimeNanos); } @Test public void sendButtonEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final int buttonCode = VirtualMouseButtonEvent.BUTTON_BACK; final int action = VirtualMouseButtonEvent.ACTION_BUTTON_PRESS; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendButtonEvent(BINDER, new VirtualMouseButtonEvent.Builder() .setButtonCode(buttonCode) .setAction(action).build())); } @Test public void sendRelativeEvent_noFd() { assertThat(mDeviceImpl.sendRelativeEvent(BINDER, Loading Loading @@ -1301,22 +1285,6 @@ public class VirtualDeviceManagerServiceTest { } @Test public void sendRelativeEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final float x = -0.2f; final float y = 0.7f; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendRelativeEvent(BINDER, new VirtualMouseRelativeEvent.Builder() .setRelativeX(x).setRelativeY(y).build())); } @Test public void sendScrollEvent_noFd() { assertThat(mDeviceImpl.sendScrollEvent(BINDER, Loading Loading @@ -1348,22 +1316,6 @@ public class VirtualDeviceManagerServiceTest { } @Test public void sendScrollEvent_hasFd_wrongDisplay_throwsIllegalStateException() { final int fd = 1; final float x = 0.5f; final float y = 1f; mInputController.addDeviceForTesting(BINDER, fd, InputController.InputDeviceDescriptor.TYPE_MOUSE, DISPLAY_ID_1, PHYS, DEVICE_NAME_1, INPUT_DEVICE_ID); assertThrows( IllegalStateException.class, () -> mDeviceImpl.sendScrollEvent(BINDER, new VirtualMouseScrollEvent.Builder() .setXAxisMovement(x) .setYAxisMovement(y).build())); } @Test public void sendTouchEvent_noFd() { assertThat(mDeviceImpl.sendTouchEvent(BINDER, Loading