scrcpy
scrcpy copied to clipboard
When I am connected by wifi and lock the phone the terminal closes.
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.
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.
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.
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.