mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 13:34:20 +01:00
Extract setting display power to a separate method
For consistency with the other actions.
This commit is contained in:
@@ -272,16 +272,7 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
|
|||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SET_DISPLAY_POWER:
|
case ControlMessage.TYPE_SET_DISPLAY_POWER:
|
||||||
if (supportsInputEvents && displayId != Device.DISPLAY_ID_NONE) {
|
if (supportsInputEvents && displayId != Device.DISPLAY_ID_NONE) {
|
||||||
boolean on = msg.getOn();
|
setDisplayPower(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_ROTATE_DEVICE:
|
case ControlMessage.TYPE_ROTATE_DEVICE:
|
||||||
@@ -677,4 +668,16 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
|
|||||||
return data;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user