mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-28 19:58:55 +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:
parent
696402c68c
commit
4e1cf13a50
1 changed files with 9 additions and 0 deletions
|
@ -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]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue