Use non-secure display for Android 12 preview
Android 12 preview identifies as Android 11, but its codename is "S".
Refs <https://github.com/Genymobile/scrcpy/issues/2129>
@@ -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);
}
