Skip to content
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

Can it support another screenshot stream on android - secondary screen #397

Closed
chaooe opened this issue Jan 16, 2019 · 60 comments
Closed

Can it support another screenshot stream on android - secondary screen #397

chaooe opened this issue Jan 16, 2019 · 60 comments

Comments

@chaooe
Copy link

chaooe commented Jan 16, 2019

  1. Normaly we can capture screen 0 by 'adb shell screencap -p -d 0 /sdcard/sc.png', so if we have two or more display, we can use 'adb shell screencap -p -d ${displayid} /sdcard/sc.png', so can we have this supported?
@rom1v
Copy link
Collaborator

rom1v commented Jan 19, 2019

IIUC, you would like to mirror a secondary screen?

It would be great.

Something should be configured to request another screen in this code:

https://github.com/Genymobile/scrcpy/blob/v1.5/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java#L63-L70

But in SurfaceControl.java (in AOSP), I didn't find how to request another screen.

If someone have an idea…

EDIT: also see option -d in screencap.cpp.

@chaooe
Copy link
Author

chaooe commented Jan 21, 2019

Yes, i want to mirror a secondary screen. I am a QA to test Android Device, and we have some future running on another screen.. we can just use screenshot to capture another screen. It is slowly and unstable.

@webian
Copy link

webian commented Apr 14, 2019

I'm another one that will find this feature precious to command Samsung Dex from my linux box without the need to switch mouse/keyboard/monitor.

I'm not an android dev but I found some little things that I hope can help:

  1. if I run this apk https://github.com/mportuesisf/ScreenInfo starting from the smartphone display it returns me the smartphone display resolution, if I run it from the Dex monitor it gives me the resolution of the monitor. So, maybe in the code of ScreenInfo there are some hints on how to achieve this.
  2. AnyDesk can reproduce Dex screen but only if started from the Dex monitor, if started from the smartphone monitor it reproduce the smartphone's one. Also, mouse click are always made on the smartphone even if started from the Dex monitor.

@webian
Copy link

webian commented Apr 14, 2019

Is there maybe a way to make Android to think that the scrcpy server is started on the external (Dex) monitor?

@webian
Copy link

webian commented May 13, 2019

Other info that maybe can help (see "Detect Samsung DeX"):
https://developer.samsung.com/samsung-dex/modify-optimizing

@tchangeme
Copy link

请问,这个怎么实现呢,手机上有另外一个屏幕的时候

@nakele
Copy link

nakele commented Sep 24, 2019

@rom1v I'm not a developer but if I "adb" wirelessly to my phone I get information about other displays, might be useful to this. See screenshots below:
Screenshot 2019-09-24 at 13 48 30

@rom1v rom1v changed the title Can it support another screenshot stream on android Can it support another screenshot stream on android - secondary screen Sep 30, 2019
@nakele
Copy link

nakele commented Oct 18, 2019

@rom1v btw, if the server was wrapped in an apk, and the apk was launched in Samsung Dex mode, it might mirror the second display.

@chaooe
Copy link
Author

chaooe commented Feb 10, 2020

@rom1v I found minitouch have soultion to touch on second screen. before it use, we need to setup minitouch server on device.
minitouch -d /dev/input/event0 /dev/input/event0 is the first screen id. and minitouch -d /dev/input/event1 is the second display id
Does this scrcpy use minitouch to touch the screen?

@rom1v
Copy link
Collaborator

rom1v commented Feb 10, 2020

No, it does not use minitouch. I guess it requires root access on the device to write to /dev/input/event*?

@chaooe
Copy link
Author

chaooe commented Feb 14, 2020

No, the /dev/input/event is the display id. I don't know where to configure the /dev/input/event*

  1. When i copy minitouch and add execution permission to android folder. /tmp/data/minitouch.
  2. /tmp/data/minitouch , it will show the display id.
  3. /tmp/data/minitouch -d /dev/input/event0 to start the minitouch server

@rom1v
Copy link
Collaborator

rom1v commented Feb 25, 2020

Could you test #1177 please?

@chaooe
Copy link
Author

chaooe commented Feb 25, 2020

Ok. I will have a try for this. and reply to ASAP.

@chaooe
Copy link
Author

chaooe commented Feb 25, 2020

For #1177 , it should be ok to mirror the display 1 screen on ubuntu 18.04. But i can't do some touch or text commands.
Add adb shell dumpsys display for reference.
image

@peanutwolf
Copy link
Contributor

@rom1v @chaooe Thank you for testing. I think i've missed the touch functionality for the second screen cause my second screen is not touchable. I'll investigate how it could be supported and will make commit to my PR.

@chaooe
Copy link
Author

chaooe commented Feb 25, 2020

Thanks @peanutwolf , And i have 3 display for this. The default id 0 and display id 1 can be touched. but display id 2 is only for view. just some information, i am not sure if this is helpful for you. And thanks again

@webian
Copy link

webian commented Feb 25, 2020

Thanks @peanutwolf !
I tested #1177 too and it's working except for clicks.
I can see the Dex screen (secondary monitor) but the clicks that I make on scrcpy window are sent to the smartphone instead of Dex, so I guess that a small step is missing.

@peanutwolf
Copy link
Contributor

@chaooe @webian what android API does your devices have? ($ adb shell getprop ro.build.version.sdk | tr -d '\r')
It seems that input events for multiple displays can't be supported for android 9 and lower.
Or maybe you have custom InputFlinger patched for your devices?

@webian
Copy link

webian commented Feb 26, 2020

Mine is a Samsung Galaxy S10e with Android 10:
$ adb shell getprop ro.build.version.sdk | tr -d '\r'
29

No custom InputFlinger as far as I know.

@webian
Copy link

webian commented Feb 26, 2020

Please, also note n.2 of my #397 (comment) I had the same problem about clicking with AnyDesk.

@chaooe
Copy link
Author

chaooe commented Feb 26, 2020

@peanutwolf My version is 27
$ adb shell getprop ro.build.version.sdk | tr -d '\r' 27

@chaooe
Copy link
Author

chaooe commented Feb 26, 2020

Another things for display id 1 which can be input. for my automation test. we found we can use minitouch for touch the second screen.
setup minitouch server on device.
minitouch -d /dev/input/event0
/dev/input/event0 is the first screen id. and minitouch -d /dev/input/event1 is the second display id

@chaooe
Copy link
Author

chaooe commented Apr 8, 2020

Is that possible to add minitouch solution to support this?

@webian
Copy link

webian commented Apr 8, 2020

Hi @rom1v, I tested dev replacing the 2 files and launching with "--display 2" and it works both display and input.
Windows 10 LTSC 1809 + Samsung Galaxy S10e SM-G970F Android 10

@rom1v
Copy link
Collaborator

rom1v commented Apr 8, 2020

@webian Cool 🎉 Thank you for your test.

(How do you get multiple displays in practice with your phone?)

@webian
Copy link

webian commented Apr 8, 2020

@webian Cool 🎉 Thank you for your test.

You don't need to thank me... I thank you a lot for the amazing scrcpy!

(How do you get multiple displays in practice with your phone?)

see #898 (comment)
I add that in practice I use an USB to HDMI adapter and connect it to a monitor with an HDMI cable. This way I can mirror the phone screen. To start Dex on the external screen I also have to power the adapter with an external USB charger.

@rom1v
Copy link
Collaborator

rom1v commented Apr 9, 2020

I guess this issue can be closed with the new --display option implemented on dev branch.

@rom1v rom1v closed this as completed Apr 9, 2020
@rom1v
Copy link
Collaborator

rom1v commented Apr 29, 2020

Released in v1.13.

@tchangeme
Copy link

The second screen can be displayed normally, but the mouse and keyboard cannot be used。

@tchangeme
Copy link

In addition, the screen cannot be fully displayed

@rom1v
Copy link
Collaborator

rom1v commented May 3, 2020

but the mouse and keyboard cannot be used

That's expected before Android 10.
https://github.com/Genymobile/scrcpy/releases/tag/v1.13

In addition, the screen cannot be fully displayed

What do you mean?

@jvisser99
Copy link

jvisser99 commented May 13, 2020

Greetings,

Thanks for the great program, I use it daily.

I can't get DeX to work. I tried the --display option, and for anything other than 0 i get an error of this form:

$ scrcpy --display 1
INFO: scrcpy 1.13 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1...pushed. 3.1 MB/s (27694 bytes in 0.009s)
[server] INFO: Device: samsung SM-G960U1 (Android 10)
[server] ERROR: Exception on thread Thread[main,5,main]
com.genymobile.scrcpy.InvalidDisplayIdException: There is no display having id 1
	at com.genymobile.scrcpy.Device.<init>(Device.java:46)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:20)
	at com.genymobile.scrcpy.Server.main(Server.java:177)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:339)
[server] ERROR: Try to use one of the available display ids:
[server] ERROR:     scrcpy --display 0

I'm running Red Hat Enterprise Linux Workstation 7.6, Samsung Galaxy 9, Android 10. Connected via a Lenovo Thunderbolt doc to a Lenovo X1 Carbon Gen. 6, 2 displayport-connected monitors.

Any help appreciated. Happy to test.

jv

@rom1v
Copy link
Collaborator

rom1v commented May 13, 2020

Is DeX running when you execute this command?

@jvisser99
Copy link

Thanks for the quick reply.
I don't know. I get a notification that says "you can use Sasung DeX on your computer. I searched for DeX, and found four apps, DeX for PC, Samsung DeX, Samsung DeX home, and Samsung DeX System UI, all installed, but no indication that they are running.

@rom1v
Copy link
Collaborator

rom1v commented May 13, 2020

AFAIK, DeX can only be enabled when you plug your device to some HDMI monitor.

@jvisser99
Copy link

jvisser99 commented May 13, 2020

AFAIK, DeX can only be enabled when you plug your device to some HDMI monitor.

If you do this, how do you run scrcpy? And, scrcpy 1.13 supports DeX screen mirroring.

@nakele
Copy link

nakele commented May 13, 2020

@jvisser99 if u want to run Dex on PC you need to install Dex appliaction on your pc as well, plug the cable to phone, wait to say it's connected and you should get a window dex on your pc monitor. No needed for for anythingelse. HoWEVER scrcpy could be used to mirror dex on devices that don't support Dex on PC like the S8/Note8 line + S9/Note9 on Android 9.

First you need to trigger Dex via HDMI cable or HDMI dummy plug (my case), then use scrcpy via WiFi (because your port will be used for the HDMI)
In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

@rom1v
Copy link
Collaborator

rom1v commented May 13, 2020

scrcpy 1.13 supports DeX screen mirroring.

It supports mirroring a secondary display.

On devices supporting DeX, a secondary display is created when DeX is enabled. And DeX is enabled when you plug the device via HDMI.

@jvisser99
Copy link

@jvisser99 if u want to run Dex on PC you need to install Dex appliaction on your pc as well, plug the cable to phone, wait to say it's connected and you should get a window dex on your pc monitor. No needed for for anythingelse. HoWEVER scrcpy could be used to mirror dex on devices that don't support Dex on PC like the S8/Note8 line + S9/Note9 on Android 9.

First you need to trigger Dex via HDMI cable or HDMI dummy plug (my case), then use scrcpy via WiFi (because your port will be used for the HDMI)
In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

I'm running linux on my laptop

@rom1v
Copy link
Collaborator

rom1v commented May 13, 2020

In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

IIUC, this app allows to enable DeX without plugging the device via HDMI?

If this is the case, then it shows that it is possible to enable DeX programmatically. If someone knows how, it could be implemented in scrcpy 😉

@jvisser99
Copy link

In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

IIUC, this app allows to enable DeX without plugging the device via HDMI?

If this is the case, then it shows that it is possible to enable DeX programmatically. If someone knows how, it could be implemented in scrcpy

I thought it was implemented in 1.13

@rom1v
Copy link
Collaborator

rom1v commented May 13, 2020

No, in scrcpy 1.13, a new option has been added to mirror a display other than the one having id 0.

It occurs that DeX creates such a secondary display when enabled, so scrcpy can mirror it.

@nakele
Copy link

nakele commented May 13, 2020

@jvisser99 if u want to run Dex on PC you need to install Dex appliaction on your pc as well, plug the cable to phone, wait to say it's connected and you should get a window dex on your pc monitor. No needed for for anythingelse. HoWEVER scrcpy could be used to mirror dex on devices that don't support Dex on PC like the S8/Note8 line + S9/Note9 on Android 9.
First you need to trigger Dex via HDMI cable or HDMI dummy plug (my case), then use scrcpy via WiFi (because your port will be used for the HDMI)
In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

I'm running linux on my laptop

Ah, I suspected that. I believe wine won't work with Samsung Dex on PC.

@nakele
Copy link

nakele commented May 13, 2020

In your case you don't need scrcpy, the samsung app "Dex on Window", also available on Mac.

IIUC, this app allows to enable DeX without plugging the device via HDMI?

If this is the case, then it shows that it is possible to enable DeX programmatically. If someone knows how, it could be implemented in scrcpy 😉

It's possible, definitely.
2 things comes to mind, if not 3: Dex on PC will trigger dex programmatically, Dex on a Tab has a toggle to show DeX on the tablet itself, so no hdmi required. Lastly someone has seen Dex Wireless options (might be a thing in the future)

@webian
Copy link

webian commented May 14, 2020

There's also this thread in Samsung forum where a moderator says, in October 2018, that they are "working on a wireless connection for DEX but a few improvements need to be made first". If you want you can add your post to the thread so they know how much this feature is requested.

@rom1v
Copy link
Collaborator

rom1v commented May 14, 2020

I don't have any DeX device. Could you please check if enabling dex with "Dex on Windows" changes settings:

# with dex disabled
adb shell "settings list global | sort" > global.txt
adb shell "settings list secure | sort" > secure.txt
adb shell "settings list system | sort" > system.txt
# with dex enabled
adb shell "settings list global | sort" > global_dex.txt
adb shell "settings list secure | sort" > secure_dex.txt
adb shell "settings list system | sort" > system_dex.txt
# compare
diff -U3 global.txt global_dex.txt
diff -U3 secure.txt secure_dex.txt
diff -U3 system.txt system_dex.txt

@webian
Copy link

webian commented May 14, 2020

These are the diffs before/after connecting my Galaxy S10e with USB cable and starting Dex on PC:

@0x15f2d
Copy link

0x15f2d commented Jul 26, 2022

I hope this method works better because I have 2 devices that either can't encode video properly (old phone) or doesn't have a codec to encode video (watch, can decode some webm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants