diff --git a/experimental/app/src/main/java/io/devicefarmer/minicap/provider/SurfaceProvider.kt b/experimental/app/src/main/java/io/devicefarmer/minicap/provider/SurfaceProvider.kt index c0aff60..a9f9e96 100644 --- a/experimental/app/src/main/java/io/devicefarmer/minicap/provider/SurfaceProvider.kt +++ b/experimental/app/src/main/java/io/devicefarmer/minicap/provider/SurfaceProvider.kt @@ -18,6 +18,7 @@ package io.devicefarmer.minicap.provider import android.graphics.Rect import android.media.ImageReader import android.net.LocalSocket +import android.os.Build import android.os.Handler import android.os.IBinder import android.os.Looper @@ -80,7 +81,10 @@ class SurfaceProvider(targetSize: Size, orientation: Int) : BaseProvider(targetS */ private fun initSurface(l: ImageReader.OnImageAvailableListener) { //must be done on the main thread - display = SurfaceControl.createDisplay("minicap", false) + // Support Android 12 (preview),and resolve black screen problem + val secure = + Build.VERSION.SDK_INT < Build.VERSION_CODES.R || Build.VERSION.SDK_INT == Build.VERSION_CODES.R && "S" != Build.VERSION.CODENAME + display = SurfaceControl.createDisplay("minicap", secure) //initialise the surface to get the display in the ImageReader SurfaceControl.openTransaction() try {