scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

When I am connected by wifi and lock the phone the terminal closes.

Open Buhos-Dev opened this issue 2 years ago • 2 comments

When I am connected by Wi-Fi and I lock the phone, the terminal closes and I have to reconnect it, please allow it to work by Wi-Fi too, since with the cable connected that does not happen.

Buhos-Dev avatar Jun 17 '22 01:06 Buhos-Dev

If it closes, the adb connection is closed.

Open adb shell or adb logcat in a separate terminal, and keep it open. Does the command terminate at the same time as scrcpy when you lock your phone?

It's a behavior from your device, which is not expected. Maybe you could avoid this disconnection by switching the "USB mode" to another value (MTP, PTP, charging only…). This is typically configurable from your device settings or via a notification when you plug the device over USB.

rom1v avatar Jun 17 '22 02:06 rom1v

I have exactly the same issue, and tested what @rom1v mentioned, i kept an adb shell open with ping running toward the router, when the screen goes into lock mode a few seconds later the connection is lost.

I will try changing the USB mode, but i would require a bit more of details, because it seems there are at least two places where you might find the MTP/PTP etc strings, could someone give more info about this? because it gets pretty annoying.

arangaran avatar Mar 26 '23 09:03 arangaran

What devices and Android versions are you using? Old versions of Android (and some custom ROMs) have an option to turn off WiFi when screen is locked.

Again, only some devices require MTP/PTP mode to enable USB debugging. If you plug in your device and it just works, then you don't need to worry. If it doesn't work, the USB mode selection dialog should automatically pop up when it's connected to a PC via a USB cable. Or it can be found in the notification panel. Or, some later versions of Android have a "default USB mode" option in Developer Settings menu.

yume-chan avatar Oct 23 '23 12:10 yume-chan