mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-31 14:25:56 +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 283326b2f6
Fixes #6146 <https://github.com/Genymobile/scrcpy/issues/6146>
This commit is contained in:
@@ -7,6 +7,7 @@ import com.genymobile.scrcpy.util.SettingsException;
|
||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Looper;
|
||||
import android.system.ErrnoException;
|
||||
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) {
|
||||
try {
|
||||
// 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();
|
||||
|
||||
// Needed for workarounds
|
||||
prepareMainLooper();
|
||||
|
||||
int displayId = Integer.parseInt(args[0]);
|
||||
int restoreStayOn = Integer.parseInt(args[1]);
|
||||
boolean disableShowTouches = Boolean.parseBoolean(args[2]);
|
||||
|
Reference in New Issue
Block a user