Log actions on the caller side

Some actions are exposed by the Device class, but logging success should
be done by the caller.
This commit is contained in:
Romain Vimont 2020-05-25 02:23:32 +02:00
parent 81573d81a0
commit c7a33fac36
2 changed files with 14 additions and 13 deletions

View file

@ -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:

View file

@ -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);
}
/**