From 16a63e0917e423fb417eaad3ae0ca05f16227db6 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 11 Jun 2021 10:02:52 +0200 Subject: [PATCH] Use non-secure display for Android 12 preview Android 12 preview identifies as Android 11, but its codename is "S". Refs #2129 --- .../src/main/java/com/genymobile/scrcpy/ScreenEncoder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 9a149241..2f7109c5 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -226,8 +226,10 @@ public class ScreenEncoder implements Device.RotationListener { } private static IBinder createDisplay() { - // Since Android 12, secure displays could not be created with shell permissions anymore - boolean secure = Build.VERSION.SDK_INT <= Build.VERSION_CODES.R; + // Since Android 12 (preview), secure displays could not be created with shell permissions anymore. + // On Android 12 preview, SDK_INT is still R (not S), but CODENAME is "S". + boolean secure = Build.VERSION.SDK_INT < Build.VERSION_CODES.R || (Build.VERSION.SDK_INT == Build.VERSION_CODES.R && !"S" + .equals(Build.VERSION.CODENAME)); return SurfaceControl.createDisplay("scrcpy", secure); }