diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index eb5a0805..4442188c 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -110,11 +110,18 @@ public class Controller { sender.pushClipboardText(clipboardText); break; case ControlMessage.TYPE_SET_CLIPBOARD: - device.setClipboardText(msg.getText()); + boolean setClipboardOk = device.setClipboardText(msg.getText()); + if (setClipboardOk) { + Ln.i("Device clipboard set"); + } break; case ControlMessage.TYPE_SET_SCREEN_POWER_MODE: if (device.supportsInputEvents()) { - device.setScreenPowerMode(msg.getAction()); + int mode = msg.getAction(); + boolean setPowerModeOk = device.setScreenPowerMode(mode); + if (setPowerModeOk) { + Ln.i("Device screen turned " + (mode == Device.POWER_MODE_OFF ? "off" : "on")); + } } break; case ControlMessage.TYPE_ROTATE_DEVICE: diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index 6e788928..1a851b15 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -180,26 +180,20 @@ public final class Device { return s.toString(); } - public void setClipboardText(String text) { - boolean ok = serviceManager.getClipboardManager().setText(text); - if (ok) { - Ln.i("Device clipboard set"); - } + public boolean setClipboardText(String text) { + return serviceManager.getClipboardManager().setText(text); } /** * @param mode one of the {@code SCREEN_POWER_MODE_*} constants */ - public void setScreenPowerMode(int mode) { + public boolean setScreenPowerMode(int mode) { IBinder d = SurfaceControl.getBuiltInDisplay(); if (d == null) { Ln.e("Could not get built-in display"); - return; - } - boolean ok = SurfaceControl.setDisplayPowerMode(d, mode); - if (ok) { - Ln.i("Device screen turned " + (mode == Device.POWER_MODE_OFF ? "off" : "on")); + return false; } + return SurfaceControl.setDisplayPowerMode(d, mode); } /**