From dc19ae334dcc55f64a9e29ec9d5e754c6da69657 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 29 Nov 2021 09:18:23 +0100 Subject: [PATCH] Move acknowledgment handling Handle all actions related to SET_CLIPBOARD from the dedicated method. PR #2834 --- .../java/com/genymobile/scrcpy/Controller.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index 8b24b300..b52d413e 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -120,12 +120,7 @@ public class Controller { } break; case ControlMessage.TYPE_SET_CLIPBOARD: - long sequence = msg.getSequence(); - setClipboard(msg.getText(), msg.getPaste()); - if (sequence != ControlMessage.SEQUENCE_INVALID) { - // Acknowledgement requested - sender.pushAckClipboard(sequence); - } + setClipboard(msg.getText(), msg.getPaste(), msg.getSequence()); break; case ControlMessage.TYPE_SET_SCREEN_POWER_MODE: if (device.supportsInputEvents()) { @@ -281,7 +276,7 @@ public class Controller { return device.pressReleaseKeycode(KeyEvent.KEYCODE_POWER); } - private boolean setClipboard(String text, boolean paste) { + private boolean setClipboard(String text, boolean paste, long sequence) { boolean ok = device.setClipboardText(text); if (ok) { Ln.i("Device clipboard set"); @@ -292,6 +287,11 @@ public class Controller { device.pressReleaseKeycode(KeyEvent.KEYCODE_PASTE); } + if (sequence != ControlMessage.SEQUENCE_INVALID) { + // Acknowledgement requested + sender.pushAckClipboard(sequence); + } + return ok; } }