Extract setting display power to a separate method

For consistency with the other actions.
This commit is contained in:
Romain Vimont 2024-10-31 20:23:11 +01:00
parent e26bdb07a2
commit c7378f4dc8
1 changed files with 13 additions and 10 deletions

View File

@ -272,16 +272,7 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
break;
case ControlMessage.TYPE_SET_DISPLAY_POWER:
if (supportsInputEvents && displayId != Device.DISPLAY_ID_NONE) {
boolean on = msg.getOn();
boolean setDisplayPowerOk = Device.setDisplayPower(displayId, on);
if (setDisplayPowerOk) {
keepDisplayPowerOff = !on;
Ln.i("Device display turned " + (on ? "on" : "off"));
if (cleanUp != null) {
boolean mustRestoreOnExit = !on;
cleanUp.setRestoreDisplayPower(mustRestoreOnExit);
}
}
setDisplayPower(msg.getOn());
}
break;
case ControlMessage.TYPE_ROTATE_DEVICE:
@ -677,4 +668,16 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
return data;
}
}
private void setDisplayPower(boolean on) {
boolean setDisplayPowerOk = Device.setDisplayPower(displayId, on);
if (setDisplayPowerOk) {
keepDisplayPowerOff = !on;
Ln.i("Device display turned " + (on ? "on" : "off"));
if (cleanUp != null) {
boolean mustRestoreOnExit = !on;
cleanUp.setRestoreDisplayPower(mustRestoreOnExit);
}
}
}
}