Display and control your Android device
Recreate the display on rotation
Romain Vimont7e3b9359322f
diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java b/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.javaindex f81332f5..e048354a 100644--- a/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java@@ -18,7 +18,6 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList@Overridepublic void init() {- display = createDisplay();device.setRotationListener(this);device.setFoldListener(this);}@@ -32,6 +31,11 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationListRect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect();int videoRotation = screenInfo.getVideoRotation();int layerStack = device.getLayerStack();++ if (display != null) {+ SurfaceControl.destroyDisplay(display);+ }+ display = createDisplay();setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);}@@ -39,7 +43,9 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationListpublic void release() {device.setRotationListener(null);device.setFoldListener(null);- SurfaceControl.destroyDisplay(display);+ if (display != null) {+ SurfaceControl.destroyDisplay(display);+ }}@Override