From eb004b010e649a537b3bccf851e80fb2f829cb46 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 10 Dec 2024 19:12:26 +0100 Subject: [PATCH] Improve manual rotation reliability Manually requesting a device orientation change using MOD+r often fails. Introducing a small delay dramatically improves reliability. --- server/src/main/java/com/genymobile/scrcpy/device/Device.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/device/Device.java b/server/src/main/java/com/genymobile/scrcpy/device/Device.java index 3553dc2784..260cba8ec8 100644 --- a/server/src/main/java/com/genymobile/scrcpy/device/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/device/Device.java @@ -206,6 +206,10 @@ public static void rotateDevice(int displayId) { // restore auto-rotate if necessary if (accelerometerRotation) { + if (displayId == 0) { + // HACK: rotation on the main display often fail on recent Android devices if thawRotation() is called immediately + SystemClock.sleep(10); + } wm.thawRotation(displayId); } }