mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
Add scheduleScreenOn
This commit is contained in:
parent
5fa46ad0c7
commit
bbc0ae27d5
2 changed files with 13 additions and 7 deletions
|
@ -19,18 +19,19 @@ public final class CleanUp {
|
||||||
// not instantiable
|
// not instantiable
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configure(boolean disableShowTouches, int restoreStayOn) throws IOException {
|
public static void configure(boolean disableShowTouches, int restoreStayOn, boolean scheduleScreenOn) throws IOException {
|
||||||
boolean needProcess = disableShowTouches || restoreStayOn != -1;
|
boolean needProcess = disableShowTouches || restoreStayOn != -1 || scheduleScreenOn;
|
||||||
if (needProcess) {
|
if (needProcess) {
|
||||||
startProcess(disableShowTouches, restoreStayOn);
|
startProcess(disableShowTouches, restoreStayOn, scheduleScreenOn);
|
||||||
} else {
|
} else {
|
||||||
// There is no additional clean up to do when scrcpy dies
|
// There is no additional clean up to do when scrcpy dies
|
||||||
unlinkSelf();
|
unlinkSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startProcess(boolean disableShowTouches, int restoreStayOn) throws IOException {
|
private static void startProcess(boolean disableShowTouches, int restoreStayOn, boolean scheduleScreenOn) throws IOException {
|
||||||
String[] cmd = {"app_process", "/", CleanUp.class.getName(), String.valueOf(disableShowTouches), String.valueOf(restoreStayOn)};
|
String[] cmd = {"app_process", "/", CleanUp.class.getName(), String.valueOf(disableShowTouches),
|
||||||
|
String.valueOf(restoreStayOn), String.valueOf(scheduleScreenOn)};
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(cmd);
|
ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||||
builder.environment().put("CLASSPATH", SERVER_PATH);
|
builder.environment().put("CLASSPATH", SERVER_PATH);
|
||||||
|
@ -59,8 +60,9 @@ public final class CleanUp {
|
||||||
|
|
||||||
boolean disableShowTouches = Boolean.parseBoolean(args[0]);
|
boolean disableShowTouches = Boolean.parseBoolean(args[0]);
|
||||||
int restoreStayOn = Integer.parseInt(args[1]);
|
int restoreStayOn = Integer.parseInt(args[1]);
|
||||||
|
boolean scheduleScreenOn = Boolean.parseBoolean(args[2]);
|
||||||
|
|
||||||
if (disableShowTouches || restoreStayOn != -1) {
|
if (disableShowTouches || restoreStayOn != -1 || scheduleScreenOn) {
|
||||||
ServiceManager serviceManager = new ServiceManager();
|
ServiceManager serviceManager = new ServiceManager();
|
||||||
try (ContentProvider settings = serviceManager.getActivityManager().createSettingsProvider()) {
|
try (ContentProvider settings = serviceManager.getActivityManager().createSettingsProvider()) {
|
||||||
if (disableShowTouches) {
|
if (disableShowTouches) {
|
||||||
|
@ -72,6 +74,10 @@ public final class CleanUp {
|
||||||
settings.putValue(ContentProvider.TABLE_GLOBAL, "stay_on_while_plugged_in", String.valueOf(restoreStayOn));
|
settings.putValue(ContentProvider.TABLE_GLOBAL, "stay_on_while_plugged_in", String.valueOf(restoreStayOn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (scheduleScreenOn) {
|
||||||
|
Ln.i("Restoring \"displayPowerMode\"");
|
||||||
|
new Device(new Options()).setScreenPowerMode(Device.POWER_MODE_NORMAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CleanUp.configure(mustDisableShowTouchesOnCleanUp, restoreStayOn);
|
CleanUp.configure(mustDisableShowTouchesOnCleanUp, restoreStayOn, true);
|
||||||
|
|
||||||
boolean tunnelForward = options.isTunnelForward();
|
boolean tunnelForward = options.isTunnelForward();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue