mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 22:29:25 +00:00
More efficient version recycling the scheduling thread
This commit is contained in:
parent
35d2edc7ca
commit
22cdab6bfb
1 changed files with 12 additions and 12 deletions
|
@ -28,6 +28,8 @@ public class Controller {
|
||||||
private final MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[PointersState.MAX_POINTERS];
|
private final MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[PointersState.MAX_POINTERS];
|
||||||
private final MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[PointersState.MAX_POINTERS];
|
private final MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[PointersState.MAX_POINTERS];
|
||||||
|
|
||||||
|
private final Timer keepScreenOffTimer = new Timer("KeepScreenOff", true);
|
||||||
|
|
||||||
public Controller(Device device, DesktopConnection connection) {
|
public Controller(Device device, DesktopConnection connection) {
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -238,18 +240,16 @@ public class Controller {
|
||||||
* Hopefully something better will come up in the future
|
* Hopefully something better will come up in the future
|
||||||
* Tested on a low end Android 6 device
|
* Tested on a low end Android 6 device
|
||||||
*/
|
*/
|
||||||
public void scheduleScreenOff(){
|
public void scheduleScreenOff() {
|
||||||
if(screenStayOff) {
|
if (screenStayOff) {
|
||||||
final Timer timing = new Timer("KeepScreenOn", true);
|
keepScreenOffTimer.schedule(
|
||||||
timing.schedule(new TimerTask() {
|
new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Ln.i("Forcing screen back off");
|
Ln.i("Forcing screen back off");
|
||||||
if (Device.setScreenPowerMode(Device.POWER_MODE_OFF)) {
|
Device.setScreenPowerMode(Device.POWER_MODE_OFF);
|
||||||
timing.cancel();
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
100);
|
100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue