Display and control your Android device
Synchronize access to DisplayManager
Romain Vimont7a3fe830d4d8
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.javaindex 3f8ed2bd..2f86bbd2 100644--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java@@ -115,7 +115,8 @@ public final class DisplayManager {return flags;}- private Method getGetDisplayInfoMethod() throws NoSuchMethodException {+ // getDisplayInfo() may be used from both the Controller thread and the video (main) thread+ private synchronized Method getGetDisplayInfoMethod() throws NoSuchMethodException {if (getDisplayInfoMethod == null) {getDisplayInfoMethod = manager.getClass().getMethod("getDisplayInfo", int.class);}diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.javaindex a8a56dab..b1123b55 100644--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java@@ -54,7 +54,8 @@ public final class ServiceManager {return windowManager;}- public static DisplayManager getDisplayManager() {+ // The DisplayManager may be used from both the Controller thread and the video (main) thread+ public static synchronized DisplayManager getDisplayManager() {if (displayManager == null) {displayManager = DisplayManager.create();}