From d0047b2110e2bd70ac2b27e7cec012747b01dfb7 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 1 Nov 2025 00:34:20 +0100 Subject: [PATCH] Do not fail when uniqueId field is missing On some devices, DisplayInfo does not have a "uniqueId" field. This field is only used for correct UHID behavior on virtual displays, so its absence should not prevent scrcpy from working. Refs #6009 Fixes #6461 --- .../com/genymobile/scrcpy/wrappers/DisplayManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java index a12470a4..9e84ec00 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java @@ -139,7 +139,13 @@ public final class DisplayManager { int layerStack = cls.getDeclaredField("layerStack").getInt(displayInfo); int flags = cls.getDeclaredField("flags").getInt(displayInfo); int dpi = cls.getDeclaredField("logicalDensityDpi").getInt(displayInfo); - String uniqueId = (String) cls.getDeclaredField("uniqueId").get(displayInfo); + String uniqueId; + try { + uniqueId = (String) cls.getDeclaredField("uniqueId").get(displayInfo); + } catch (NoSuchFieldException e) { + // This field might not exist: + uniqueId = null; + } return new DisplayInfo(displayId, new Size(width, height), rotation, layerStack, flags, dpi, uniqueId); } catch (ReflectiveOperationException e) { throw new AssertionError(e);