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:
parent
81573d81a0
commit
c7a33fac36
2 changed files with 14 additions and 13 deletions
|
@ -110,11 +110,18 @@ public class Controller {
|
||||||
sender.pushClipboardText(clipboardText);
|
sender.pushClipboardText(clipboardText);
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SET_CLIPBOARD:
|
case ControlMessage.TYPE_SET_CLIPBOARD:
|
||||||
device.setClipboardText(msg.getText());
|
boolean setClipboardOk = device.setClipboardText(msg.getText());
|
||||||
|
if (setClipboardOk) {
|
||||||
|
Ln.i("Device clipboard set");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
||||||
if (device.supportsInputEvents()) {
|
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;
|
break;
|
||||||
case ControlMessage.TYPE_ROTATE_DEVICE:
|
case ControlMessage.TYPE_ROTATE_DEVICE:
|
||||||
|
|
|
@ -180,26 +180,20 @@ public final class Device {
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClipboardText(String text) {
|
public boolean setClipboardText(String text) {
|
||||||
boolean ok = serviceManager.getClipboardManager().setText(text);
|
return serviceManager.getClipboardManager().setText(text);
|
||||||
if (ok) {
|
|
||||||
Ln.i("Device clipboard set");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mode one of the {@code SCREEN_POWER_MODE_*} constants
|
* @param mode one of the {@code SCREEN_POWER_MODE_*} constants
|
||||||
*/
|
*/
|
||||||
public void setScreenPowerMode(int mode) {
|
public boolean setScreenPowerMode(int mode) {
|
||||||
IBinder d = SurfaceControl.getBuiltInDisplay();
|
IBinder d = SurfaceControl.getBuiltInDisplay();
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
Ln.e("Could not get built-in display");
|
Ln.e("Could not get built-in display");
|
||||||
return;
|
return false;
|
||||||
}
|
|
||||||
boolean ok = SurfaceControl.setDisplayPowerMode(d, mode);
|
|
||||||
if (ok) {
|
|
||||||
Ln.i("Device screen turned " + (mode == Device.POWER_MODE_OFF ? "off" : "on"));
|
|
||||||
}
|
}
|
||||||
|
return SurfaceControl.setDisplayPowerMode(d, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue