-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android14 mirrordisplay #4848
Comments
I'm not sure to understand.
Could you please post some commit/patch to show what you changed? |
in Scrcpy server code, does mirror mian display in android 14,so it show black screen. |
Scrcpy correctly works on Android 14. It shows a black screen for windows with "secure flag" set (since Android 12, see #2129).
Please post a commit/patch to show what you suggest. |
this is my test code: create a surface . run on main display. but not show in scrcpy sp<SurfaceControl> surfaceControl = client->createSurface(String8("TestSurface"),
3000, 3000, PIXEL_FORMAT_RGB_565,
0);
sp<Surface> surface = surfaceControl->getSurface();
SurfaceComposerClient::Transaction{}
.setLayer(surfaceControl, std::numeric_limits<int32_t>::max()).show(surfaceControl).apply();
SurfaceComposerClient::Transaction t;
t.setFixedTransformHint(surfaceControl, android::ui::Transform::ROT_0);
t.setLayerStack(surfaceControl, ui::LayerStack::fromValue(0));
t.show(surfaceControl);
t.apply();
ANativeWindow_Buffer outBuffer;
surface->lock(&outBuffer, NULL);
ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
memset((uint16_t*)outBuffer.bits, 0xF800, bpr*outBuffer.height);
surface->unlockAndPost(); |
my suggest code is : |
The screen capture code is here (in java, not in C++): https://github.com/Genymobile/scrcpy/blob/master/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java What do you suggest to change here? |
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenCapture.java
@@ -43,11 +43,15 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
virtualDisplay.release();
virtualDisplay = null;
}
try {
display = createDisplay();
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
Ln.d("cxyDisplay: using SurfaceControl API layerStack:...."+layerStack);
if(Build.VERSION.SDK_INT >=34){
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, device.getDisplayLayerStack());
}else{
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
}
Ln.d("cxyDisplay: using mirror layerStack:"+layerStack+",current displayLayerStack:"+device.getDisplayLayerStack()+",Android:"+Build.VERSION.SDK_INT);
} catch (Exception surfaceControlException) {
Rect videoRect = screenInfo.getVideoSize().toRect();
try {
@@ -106,6 +110,10 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
SurfaceControl.setDisplaySurface(display, surface);
SurfaceControl.setDisplayProjection(display, orientation, deviceRect, displayRect);
SurfaceControl.setDisplayLayerStack(display, layerStack);
//mirror
if(Build.VERSION.SDK_INT >=34) {
SurfaceControl.mirrorMainDisplay(layerStack);
}
} finally {
SurfaceControl.closeTransaction();
} mirrorMainDisplay use jni call SurfaceComposerClient set |
Environment
Describe the bug
When creating a virtual screen in the Android system or using native methods to create a surface, Scrcpy opens with a black screen. I checked the source code of Android 14 and it seems that creating mirrordisplay is required. Scrcpy did not cause a black screen due to this operation. Please help confirm. Thank you
The text was updated successfully, but these errors were encountered: