Use non-secure display for Android 12 preview

Android 12 preview identifies as Android 11, but its codename is "S".

Refs #2129 <https://github.com/Genymobile/scrcpy/issues/2129>
This commit is contained in:
Romain Vimont 2021-06-11 10:02:52 +02:00
parent f7533e8896
commit 16a63e0917

View file

@ -226,8 +226,10 @@ public class ScreenEncoder implements Device.RotationListener {
} }
private static IBinder createDisplay() { private static IBinder createDisplay() {
// Since Android 12, secure displays could not be created with shell permissions anymore // Since Android 12 (preview), secure displays could not be created with shell permissions anymore.
boolean secure = Build.VERSION.SDK_INT <= Build.VERSION_CODES.R; // 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); return SurfaceControl.createDisplay("scrcpy", secure);
} }