Display and control your Android device
Restore power mode to normal on cleanup
brunoais30714aba34e8
diff --git a/server/src/main/java/com/genymobile/scrcpy/CleanUp.java b/server/src/main/java/com/genymobile/scrcpy/CleanUp.javaindex 74555636..d0ea141b 100644--- a/server/src/main/java/com/genymobile/scrcpy/CleanUp.java+++ b/server/src/main/java/com/genymobile/scrcpy/CleanUp.java@@ -19,18 +19,19 @@ public final class CleanUp {// not instantiable}- public static void configure(boolean disableShowTouches, int restoreStayOn) throws IOException {- boolean needProcess = disableShowTouches || restoreStayOn != -1;+ public static void configure(boolean disableShowTouches, int restoreStayOn, boolean restoreNormalPowerMode) throws IOException {+ boolean needProcess = disableShowTouches || restoreStayOn != -1 || restoreNormalPowerMode;if (needProcess) {- startProcess(disableShowTouches, restoreStayOn);+ startProcess(disableShowTouches, restoreStayOn, restoreNormalPowerMode);} else {// There is no additional clean up to do when scrcpy diesunlinkSelf();}}- private static void startProcess(boolean disableShowTouches, int restoreStayOn) throws IOException {- String[] cmd = {"app_process", "/", CleanUp.class.getName(), String.valueOf(disableShowTouches), String.valueOf(restoreStayOn)};+ private static void startProcess(boolean disableShowTouches, int restoreStayOn, boolean restoreNormalPowerMode) throws IOException {+ String[] cmd = {"app_process", "/", CleanUp.class.getName(), String.valueOf(disableShowTouches), String.valueOf(+ restoreStayOn), String.valueOf(restoreNormalPowerMode)};ProcessBuilder builder = new ProcessBuilder(cmd);builder.environment().put("CLASSPATH", SERVER_PATH);@@ -59,6 +60,7 @@ public final class CleanUp {boolean disableShowTouches = Boolean.parseBoolean(args[0]);int restoreStayOn = Integer.parseInt(args[1]);+ boolean restoreNormalPowerMode = Boolean.parseBoolean(args[2]);if (disableShowTouches || restoreStayOn != -1) {ServiceManager serviceManager = new ServiceManager();@@ -73,5 +75,10 @@ public final class CleanUp {}}}++ if (restoreNormalPowerMode) {+ Ln.i("Restoring normal power mode");+ Device.setScreenPowerMode(Device.POWER_MODE_NORMAL);+ }}}diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.javaindex 44b3afd4..d257e319 100644--- a/server/src/main/java/com/genymobile/scrcpy/Server.java+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java@@ -49,7 +49,7 @@ public final class Server {}}- CleanUp.configure(mustDisableShowTouchesOnCleanUp, restoreStayOn);+ CleanUp.configure(mustDisableShowTouchesOnCleanUp, restoreStayOn, true);boolean tunnelForward = options.isTunnelForward();