Skip to content

Commit

Permalink
Update Server.java
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoviola-systemelectronics committed Jul 4, 2024
1 parent e2220cc commit 12b1cc8
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions server/src/main/java/org/cagnulein/android_remote/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,10 @@ private Server() {
private static void scrcpy(Options options) throws IOException {
final Device device = new Device(options);

/*if (options.getStayAwake())*/ {
int stayOn = BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB | BatteryManager.BATTERY_PLUGGED_WIRELESS;
try {
String oldValue = Settings.getAndPutValue(Settings.TABLE_GLOBAL, "stay_on_while_plugged_in", String.valueOf(stayOn));
try {
int restoreStayOn = Integer.parseInt(oldValue);
if (restoreStayOn != stayOn) {
// Restore only if the current value is different
if (!cleanUp.setRestoreStayOn(restoreStayOn)) {
Ln.e("Could not restore stay on on exit");
}
}
} catch (NumberFormatException e) {
// ignore
}
} catch (SettingsException e) {
Ln.e("Could not change \"stay_on_while_plugged_in\"", e);
}
try {
String oldValue = Settings.getAndPutValue(Settings.TABLE_SYSTEM, "screen_off_timeout", String.valueOf(1800000));
} catch (SettingsException e) {
Ln.e("Could not change \"screen_off_timeout\"", e);
}

try (DroidConnection connection = DroidConnection.open(ip)) {
Expand All @@ -59,6 +45,12 @@ private static void scrcpy(Options options) throws IOException {
Ln.d("Screen streaming stopped");

}

try {
Settings.getAndPutValue(Settings.TABLE_SYSTEM, "screen_off_timeout", oldValue);
} catch (SettingsException e) {
Ln.e("Could not change \"screen_off_timeout\"", e);
}
}
}

Expand Down

0 comments on commit 12b1cc8

Please sign in to comment.