Move acknowledgment handling
Handle all actions related to SET_CLIPBOARD from the dedicated method.
PR <https://github.com/Genymobile/scrcpy/pull/2834>
@@ -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;
}
}
