From e46fe51e7fa5dcc08f7ead0d730bb0a649ff690a Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 12 Jun 2019 18:36:25 +0200 Subject: [PATCH] Use getPhysicalDisplayToken on Anroid Q+ instead of getBuiltInDisplay This makes the -S (screen off) parameter work on Android Q beta 4 Closes #586 --- .../com/genymobile/scrcpy/wrappers/SurfaceControl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java index bed21b3c79..b302979f98 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java @@ -77,7 +77,13 @@ public static IBinder createDisplay(String name, boolean secure) { public static IBinder getBuiltInDisplay(int builtInDisplayId) { try { - return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId); + // Android Q does not have this method anymore but has a + // replacement. + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId); + } else { + return (IBinder) CLASS.getMethod("getPhysicalDisplayToken", long.class).invoke(null, builtInDisplayId); + } } catch (Exception e) { throw new AssertionError(e); }