Implement device-to-computer clipboard copy

On Ctrl+C:
 - the client sends a GET_CLIPBOARD command to the device;
 - the device retrieve its current clipboard text and sends it in a
   GET_CLIPBOARD device event;
 - the client sets this text as the system clipboard text, so that it
   can be pasted in another application.

Fixes <https://github.com/Genymobile/scrcpy/issues/145>
This commit is contained in:
Romain Vimont
2019-05-30 15:23:01 +02:00
parent 3149e2cf4a
commit 63c078ee6c
13 changed files with 109 additions and 0 deletions

View File

@@ -174,6 +174,22 @@ public class ControlEventReaderTest {
Assert.assertEquals(ControlEvent.TYPE_COLLAPSE_NOTIFICATION_PANEL, event.getType());
}
@Test
public void testParseGetClipboardEvent() throws IOException {
ControlEventReader reader = new ControlEventReader();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeByte(ControlEvent.TYPE_GET_CLIPBOARD);
byte[] packet = bos.toByteArray();
reader.readFrom(new ByteArrayInputStream(packet));
ControlEvent event = reader.next();
Assert.assertEquals(ControlEvent.TYPE_GET_CLIPBOARD, event.getType());
}
@Test
public void testMultiEvents() throws IOException {
ControlEventReader reader = new ControlEventReader();