Skip to content

Display and control your Android device

Ignore first displayFoldChanged event

Romain Vimont5f0480c0398b
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
index af9a9283..df7cd8f2 100644
--- a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
@@ -75,8 +75,17 @@ public class ScreenCapture extends SurfaceCapture {
if (Build.VERSION.SDK_INT >= AndroidVersions.API_29_ANDROID_10) {
displayFoldListener = new IDisplayFoldListener.Stub() {
+
+ private boolean first = true;
+
@Override
public void onDisplayFoldChanged(int displayId, boolean folded) {
+ if (first) {
+ // An event is posted on registration to signal the initial state. Ignore it to avoid restarting encoding.
+ first = false;
+ return;
+ }
+
if (ScreenCapture.this.displayId != displayId) {
// Ignore events related to other display ids
return;