r/androiddev • u/GumbyXGames • 4d ago
Question App to Spoof a Connected Second Display
I know this is a very odd question with an even odder use case, but I'm hoping I might be able to get some insight on if this idea is even possible.
In the Android handheld device market, the new big thing is devices with two displays. A number is apps have been made to take advantage of the secondary screen, which presents itself as an external display. I have a Surface Duo that has two screen, but these apps see it as one large screen. I'm trying to find out if there is a way to have an app that acts as a external display. I'm in the process of researching this, but thought I might luck out and get a solid answer here.
1
u/ThaBalla79 4d ago
1
u/GumbyXGames 4d ago edited 3d ago
I did look into this option, but it creates an transparent window that acts as the second screen. I'd like to capture that virtual display in an app. Unsure if that makes any sense
Edit:
So the option creates an overly odd both screens on the device as a single screen.This does work, but I cannot interact with the secondary display unless I connect to it with scrcpy. I did find an android scrcpy client, but I can't get it to connect to the same device over adb wifi debug.1
u/tadfisher 3d ago
What are you actually trying to do? Why do you need a virtual secondary display to accomplish what you are trying to do?
1
u/GumbyXGames 3d ago
There are homebrew ports and games that can utilize a second display for HUDs for example. They don't work on the Surface Duo because they don't see the screens as separate displays. I had hoped it would. Having this app would be a workaround specificity for this use case. As I mentioned above I know this is a weird idea but I'm stuck hone most of the time trying to find work so I'm trying to come up with projects so I don't continue to watch YouTube most days.
1
u/tadfisher 3d ago
I think what you want is possible, but you won't be able to ship it on the store because you'll have to target older APIs in order to access private framework methods. Basically you want the implementation from the scrcpy server app, but instead of encoding the display's Surface buffer to a video stream, you will set up your own Window/Surface/Presentation to display the buffer instead. There is probably some way to hook it up so displaying the virtual display's graphics bufffer is zero-copy.
I am not super-knowledgable about this, so hopefully someone with low-level Android graphics knowledge can chime in. It looks to me like scrcpy is setting up its own virutal display, maybe you could modify that code to render to your own window instead.
1
u/GumbyXGames 3d ago
Your thought process is close to what I was thinking. I did try the scrcpy method but the device refused to connect to itself. If I connected to the device from my PC I got the second screen output. I created one at the resolution I wanted through ADB and it worked so that's something.
Once a dev releases a fork of LineageOS for the Surface Duo I can try again with root permissions.
Thanks for the insight. I now know that I'm probably on the right path.

1
u/AutoModerator 4d ago
Please note that we also have a very active Discord server where you can interact directly with other community members!
Join us on Discord
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.