mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-29 13:28:13 +00:00
Run a main looper in the cleanup process
Since a main looper is explicitly run in the main process, the initialization of workarounds no longer calls Looper.prepareMainLooper(), leading to a crash: java.lang.RuntimeException: Can't create handler inside thread Thread[main,5,main] that has not called Looper.prepare() As a result, --power-off-on-close was broken. Refs 283326b2f6fa3fdaeecc181f69a3a4bcd429c06a Fixes #6146 <https://github.com/Genymobile/scrcpy/issues/6146>
This commit is contained in:
parent
696402c68c
commit
4e1cf13a50
@ -7,6 +7,7 @@ import com.genymobile.scrcpy.util.SettingsException;
|
|||||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||||
|
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
|
import android.os.Looper;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
|
|
||||||
@ -179,6 +180,11 @@ public final class CleanUp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private static void prepareMainLooper() {
|
||||||
|
Looper.prepareMainLooper();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
try {
|
try {
|
||||||
// Start a new session to avoid being terminated along with the server process on some devices
|
// Start a new session to avoid being terminated along with the server process on some devices
|
||||||
@ -188,6 +194,9 @@ public final class CleanUp {
|
|||||||
}
|
}
|
||||||
unlinkSelf();
|
unlinkSelf();
|
||||||
|
|
||||||
|
// Needed for workarounds
|
||||||
|
prepareMainLooper();
|
||||||
|
|
||||||
int displayId = Integer.parseInt(args[0]);
|
int displayId = Integer.parseInt(args[0]);
|
||||||
int restoreStayOn = Integer.parseInt(args[1]);
|
int restoreStayOn = Integer.parseInt(args[1]);
|
||||||
boolean disableShowTouches = Boolean.parseBoolean(args[2]);
|
boolean disableShowTouches = Boolean.parseBoolean(args[2]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user