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

Have phone screen off while mirroring on computer #175

Closed
WrathX opened this issue Jun 15, 2018 · 53 comments
Closed

Have phone screen off while mirroring on computer #175

WrathX opened this issue Jun 15, 2018 · 53 comments

Comments

@WrathX
Copy link

WrathX commented Jun 15, 2018

It would be nice to have the screen mirroring on like it does but have the phone screen off, only showing on the computer. Would need to be able have the screen awake all the time while plugged in as well. Great job on this so far, just got it recently and it's very responsive. I use it at work all day. Thanks.

@alambike
Copy link

👍 Disable phone screen will be a nice feature .

@rom1v rom1v changed the title Feature Request: Have phone screen off while mirroring on computer Have phone screen off while mirroring on computer Jun 17, 2018
@rom1v
Copy link
Collaborator

rom1v commented Jun 17, 2018

Yes, that would be great. But I have no technical solution. See reddit comment.

@WrathX
Copy link
Author

WrathX commented Jun 18, 2018

Ok thanks for the response. Anyway of having the screen switch to stay awake when using this? Currently every time I use this I have to go into developer options and switch on stay awake while charging. I don't really want it staying awake if I am charging my phone overnight while not using this so I have to go back in every time after using scrcpy and switch stay awake off. If possible it would be a nice convenience. Thanks for this, I've been using this for a few days now at work. Since Oreo came out Sidesync hasn't been working so this was a great find. thumbs up

@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2018

Anyway of having the screen switch to stay awake when using this?

Currently, no. It's probably possible to wrap scrcpy with a script that enable/disable "keep screen on".

(Just for info, a right click switches the screen on.)

@WrathX
Copy link
Author

WrathX commented Jun 18, 2018

Ok thanks again for the response. Ya I was using the right click to turn on but I have to unlock the phone everytime so it would be better to have the screen awake all the time in my case. I use my phone a lot during the day to contact my drivers (I'm in dispatch) so unlocking the phone everytime gets clunky. Thanks for whatever you can do.

@bonrry
Copy link

bonrry commented Jun 18, 2018 via email

@Keneil-Thompson
Copy link

bypassing the lock screen, that would be quite the exploit in the android os (unless u purposely put it there).
if there is no lock screen on, maybe remove the unlock animation, turn screen brightness down to about 200 nits...very low , keep screen on while charging, have double tap to wake mappable to any key eg. double shift.
have a copy of your android device in a virtual machine.
dont know if this is even possible just throwing some ideas out there

@cleberOliva
Copy link

What's the version of downloaded scrcpy? If it's below the current then download the actual version and run on terminal the command scrcpy -h, there's a session of shortcuts in the end. To turn on/off screen of phone, type Ctrl + P.

@yrrah
Copy link

yrrah commented Dec 21, 2018

Anyway of having the screen switch to stay awake when using this?

Currently, no. It's probably possible to wrap scrcpy with a script that enable/disable "keep screen on".

(Just for info, a right click switches the screen on.)

I was able to do this with a script combined with Tasker and AutoRemote installed on the phone. Tasker sets the display timeout. I also have it set screen brightness to minimum.

I would like to turn off the screen on the phone but can't do it without blanking scrcpy as well.

@Shinkiro1
Copy link

I was able to do this with a script combined with Tasker and AutoRemote installed on the phone. Tasker sets the display timeout. I also have it set screen brightness to minimum.

What did you use for the trigger? I'm looking to do something similar.

@rom1v
Copy link
Collaborator

rom1v commented Mar 15, 2019

Oh, I investigated a bit tonight, in fact it's quite easy:

IBinder display = SurfaceControlgetBuiltInDisplay(0);
SurfaceControl.setDisplayPowerMode(display, POWER_MODE_OFF);

I have a working PoC.

The power button reenables the screen (which is good for the physical button, but is also an issue with the simulated power button on scrcpy starting and on right-click/Ctrl+P, e.g. when the screen goes black after timeout, a right-click also reenable the device screen).

I will probably work on this soon if I find some time.

@rom1v
Copy link
Collaborator

rom1v commented Mar 15, 2019

If you are interested, here is my quick test: screenoff.

@cotfas
Copy link

cotfas commented May 12, 2019

I am also interested when the screen goes off, in Vysor there was implemented when this happened and I click on any key it will turn on the screen. Will be nice to have this feature.

@rom1v
Copy link
Collaborator

rom1v commented May 12, 2019

I click on any key it will turn on the screen. Will be nice to have this feature.

If the screen is off, a right-click turns it on.

@cotfas
Copy link

cotfas commented May 12, 2019

It works, thanks!

@xeon927
Copy link

xeon927 commented May 13, 2019

+1 - have tried the test and it works just about perfectly (Galaxy Note 9) - only thing I've found is as stated above - if screen turns off, when it comes back on, phone display also does too.

Would also love to see if it's possible to include a --no-screen flag to choose at launch if you want screen off or not.

rom1v added a commit that referenced this issue May 31, 2019
Add two shortcuts:
 - Ctrl+o to turn the device screen off while mirroring
 - Ctrl+Shift+o to turn it back on

On power on (either via the POWER key or BACK while screen is off), both
the device screen and the mirror are turned on.

<#175>
@rom1v
Copy link
Collaborator

rom1v commented May 31, 2019

Implemented on dev by 12a3bb2.

Press Ctrl+o to turn the device screen off while mirroring, and Ctrl+Shift+o to turn it back on.

Would also love to see if it's possible to include a --no-screen flag to choose at launch if you want screen off or not.

I decided not to add such an option, because as soon as the display is off (timeout or explicit power off), we need to "power on", causing both the device screen and the mirror to be turned on. Thus, the command line option would not be "persistent", and this would be confusing.

@rom1v rom1v closed this as completed May 31, 2019
@npes87184
Copy link
Contributor

npes87184 commented Jun 1, 2019

I have tested this feature.

There is a problem I find, after switch off and on sometimes, the device screen cannot be turned on.

I am using HTC One M8 with android 6 and OnePlus 6 with android 9 for testing.

@rom1v
Copy link
Collaborator

rom1v commented Jun 1, 2019

@npes87184 Anything in adb logcat?

Does it switch on with the power button?

(if both the device screen and the mirror are black, you need to POWER ON)

@rom1v
Copy link
Collaborator

rom1v commented Jun 1, 2019

Maybe Ctrl+Shift+o should power on instead when screen is off?

@npes87184
Copy link
Contributor

npes87184 commented Jun 1, 2019

@rom1v

The problem is device screen is black and the scrcpy works. In this time I cannot turn on screen by Ctrl + Shift + o

There are some logs here:

It seems the first time failed, it will show:

06-01 23:41:34.604   429   429 D SurfaceFlinger: Set power mode=2, type=0 flinger=0xb8beadf0
06-01 23:41:34.604   429   429 D qdhwcomposer: hwc_blank: Unblanking display: 0
06-01 23:41:34.822   429   497 I qdhwcomposer: handle_blank_event: dpy:0 panel power state: 1
06-01 23:41:34.858   429   429 E qdexternal: writeHPDOption: file write failed '/sys/devices/virtual/graphics/fb1/hp
d'
06-01 23:41:34.858   429   429 D qdhwcomposer: hwc_blank: Done unblanking display: 0
06-01 23:41:34.883  4772  4946 D SurfaceControl: Excessive delay in setPowerMode(): 278ms
06-01 23:41:34.883  4772  4946 I scrcpy  : Device screen turned on

After it, when I try to turn it off:

06-01 23:42:15.209   429   429 D SurfaceFlinger: Set power mode=0, type=0 flinger=0xb8beadf0                        06-01 23:42:15.209   429   429 D qdhwcomposer: hwc_blank: Blanking display: 0                                       
06-01 23:42:15.418   429   497 I qdhwcomposer: handle_blank_event: dpy:0 panel power state: 0                       
06-01 23:42:15.434   429   429 E qdoverlay: Failed to call ioctl MSMFB_DISPLAY_COMMIT err=Bad file descriptor       
06-01 23:42:15.434   429   429 E qdoverlay: static bool overlay::Overlay::displayCommit(const int&, const overlay::utils::Dim&): commit failed                                                                                          
06-01 23:42:15.434   429   429 E qdhwcomposer: hwc_blank: display commit fail for virtual!                
06-01 23:42:15.434   429   429 D qdhwcomposer: hwc_blank: Done blanking display: 0                                  06-01 23:42:15.489  4772  4946 D SurfaceControl: Excessive delay in setPowerMode(): 287ms                           
06-01 23:42:15.493  4772  4946 I scrcpy  : Device screen turned off     

And try turn on again:

06-01 23:43:01.543  1747  1796 W SensorService: D/Accel(x, y, z, t) = (  1.8,  -0.1,   9.8, 241666ms), sys_time = 241666ms                                                                                                              
06-01 23:43:02.191  1747  1774 D XAN-DPS : setBB(2,255)                                                             
06-01 23:43:03.104   429   429 D SurfaceFlinger: Set power mode=2, type=0 flinger=0xb8beadf0                        
06-01 23:43:03.104   429   429 D qdhwcomposer: hwc_blank: Unblanking display: 0                                     
06-01 23:43:03.322   429   497 I qdhwcomposer: handle_blank_event: dpy:0 panel power state: 1                       
06-01 23:43:03.356   429   429 E qdexternal: writeHPDOption: file write failed '/sys/devices/virtual/graphics/fb1/hpd'                                                                                                                  
06-01 23:43:03.356   429   429 D qdhwcomposer: hwc_blank: Done unblanking display: 0                                06-01 23:43:03.380  4772  4946 D SurfaceControl: Excessive delay in setPowerMode(): 283ms                           
06-01 23:43:03.380  4772  4946 I scrcpy  : Device screen turned on                                              

The log is flowing, I try my best to get related log...

If the log does not meet the requirement, please contact me, I will reproduce it again and get more detail.

Thanks.

@WrathX
Copy link
Author

WrathX commented Jun 1, 2019

Is there a release to test this out?

@rom1v
Copy link
Collaborator

rom1v commented Jun 2, 2019

@npes87184 I have no idea about the cause, and I cannot reproduce :(

@char101
Copy link

char101 commented Mar 30, 2020

And while keeping the screen turned off, we can use this batch file to prevent the OS from sleeping

@echo off
setlocal
set APP=scrcpy-noconsole.exe
set APP_DIR=C:\scrcpy

:scrcpy
pushd %APP_DIR%
start %APP% -b 16M -S
popd

rem generate mouse event while scrcpy is running
:loop
adb shell input keyevent mouse
timeout /t 5 /nobreak > NUL
tasklist /FI "IMAGENAME eq %APP%" 2>NUL | find /I /N "%APP%" > NUL
if "%ERRORLEVEL%"=="0" goto loop

:end
endlocal

@rom1v
Copy link
Collaborator

rom1v commented May 27, 2020

I just reactivated the shortcut (Ctrl+Shift+o), in practice it works: dcde578

@npes87184 can you still reproduce the issue?

@npes87184
Copy link
Contributor

I would test it after 6/3.

@iamthekings5
Copy link

iamthekings5 commented May 30, 2020

My screen seems to get permanently dimmed if I use Ctrl + Shift + O (turning it off and on will make it remain dimmed, only can fix with restart).

@npes87184
Copy link
Contributor

I tested it on my samsung galaxy note10+. It worked!

@sandeepkumardev-zz
Copy link

when i press 'ctrl + o' then this error through 👇
[server] ERROR: Exception on thread Thread[Thread-1,5,main]
java.lang.AssertionError: java.lang.NoSuchMethodException: android.view.SurfaceControl.getBuiltInDisplay [int]
at com.genymobile.scrcpy.wrappers.SurfaceControl.getBuiltInDisplay(SurfaceControl.java:82)
at com.genymobile.scrcpy.Device.setScreenPowerMode(Device.java:164)
at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:113)
at com.genymobile.scrcpy.Controller.control(Controller.java:73)
at com.genymobile.scrcpy.Server$1.run(Server.java:45)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.NoSuchMethodException: android.view.SurfaceControl.getBuiltInDisplay [int]
at java.lang.Class.getMethod(Class.java:2072)
at java.lang.Class.getMethod(Class.java:1693)
at com.genymobile.scrcpy.wrappers.SurfaceControl.getBuiltInDisplay(SurfaceControl.java:80)
... 5 more

@rom1v
Copy link
Collaborator

rom1v commented Sep 19, 2020

Which scrcpy version? Which Android version?

@sandeepkumardev-zz
Copy link

Which scrcpy version? Which Android version?

Scrcpy v1.9 and Android 10. plz help 🙏

@rom1v
Copy link
Collaborator

rom1v commented Sep 19, 2020

Scrcpy v1.9

That's very old. Just use the latest version.

@sandeepkumardev-zz
Copy link

Scrcpy v1.9

That's very old. Just use the latest version.

which one ??

@sandeepkumardev-zz
Copy link

Scrcpy v1.9

That's very old. Just use the latest version.

'ctrl + o' does not work in scrcpy (v1.16)

@rom1v
Copy link
Collaborator

rom1v commented Sep 19, 2020

Since v1.15, the shortcuts are bound to Alt by default, so it's Alt+o.

@sandeepkumardev-zz
Copy link

Since v1.15, the shortcuts are bound to Alt by default, so it's Alt+o.

Thankyou 😊😊 'alt + o' work in v1.16. but how i can screen turned on.

@rom1v
Copy link
Collaborator

rom1v commented Sep 19, 2020

Please read the doc: https://github.com/Genymobile/scrcpy#shortcuts

@sandeepkumardev-zz
Copy link

Please read the doc: https://github.com/Genymobile/scrcpy#shortcuts

Thank you so much 😊😊

@sandeepkumardev-zz
Copy link

sandeepkumardev-zz commented Sep 19, 2020

Please read the doc: https://github.com/Genymobile/scrcpy#shortcuts

sir where can i find it 32bit version.

@npes87184
Copy link
Contributor

Please read the doc: https://github.com/Genymobile/scrcpy#shortcuts

sir where can i find it 32bit version.

You can find 32bit version in release page.

@sandeepkumardev-zz
Copy link

Please read the doc: https://github.com/Genymobile/scrcpy#shortcuts

sir where can i find it 32bit version.

You can find 32bit version in release page.

I'm sorry, but maybe it's not safe. Here is the Virustotal report.

@rom1v
Copy link
Collaborator

rom1v commented Sep 28, 2020

@repositories-hub #1102

@sandeepkumardev-zz
Copy link

@rom1v ThankYou 🙏 😊

@Yaniv-Aviran
Copy link

This feature stopped working on Android 14

@rom1v
Copy link
Collaborator

rom1v commented Oct 13, 2023

This feature stopped working on Android 14

#3927

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