Utilize QtScrcpy and ToDesk to control Android Q remotely

Remote control is never easy job, but it’s really rigid demand in certain situation. There are many ready-to-use paid services, here I would like to share a free way to realize it.

Final achievement:

Control android device wirelessly at anytime and anywhere

Requirments:

  1. Android mobile phone you want to control with wireless adb debug enabled.
  2. Win11(or other system support QtScrcpy) PC connected to the same wifi point as the phone.
  3. ToDesk client installed on the PC and device you want to perform the control.

Basically, you should make QtScrcpy working locally on the PC wirelessly, fllowing this instruction. And if you closed the remote window, the mobile phone will automatically locked and screened off. After a while, you may find that the remote window can’t be launched again, even though the device ID is valid though adb devices, and the device is already connected.

1
2
3
4
5
6
7
8
9
10
11
adb devices
adb run
AdbProcessImpl::out:List of devices attached
192.168.10.48:5555 device

wireless connect...
adb run
AdbProcessImpl::out:already connected to 192.168.10.48:5555

start server...
AdbProcessImpl::out:C:/app/QtScrcpy-win-x64-v2.2.1/scrcpy-server: 1 file pushed, 0 skipped. 102.2 MB/s (69007 bytes in 0.001s)

If this is the situation, you can try to light up the phone though adb shell input keyevent 26, which simulatively trigger the power button. After that, you may launch the device again.

adb run
start server...
AdbProcessImpl::out:C:/app/QtScrcpy-win-x64-v2.2.1/scrcpy-server: 1 file pushed, 0 skipped. 60.7 MB/s (69007 bytes in 0.001s)
AdbProcessImpl::out:[server] INFO: Device: [OnePlus] OnePlus HD1900 (Android 10)

server start finish in 1.431s

AdbProcessImpl::out:[server] DEBUG: Using video encoder: 'OMX.qcom.video.encoder.avc'
[server] DEBUG: Display: using SurfaceControl API

Alternatively, you can create a script file on desktop to facilitate the process.

cd /d C:\app\QtScrcpy-win-x64-v2.2.1
adb connect 192.168.10.48:5555
adb shell input keyevent 26
adb shell input swipe 540 1800 540 200 1000
adb shell input text "25901028"
pause

Now, If you tested the process remotely through ToDesk, while the laptop lid or monitor closed, you will get a white screen(白屏)after launched. This is mostly due to the energy-saving mode of graphics card. To solve this, you can purchase a video card spoofer (显卡欺骗器), or install a virtual display tool on PC.

Here I choose nomi-san/parsec-vdd, which is pretty simple to setup. After create a virtual display and restart QtScrcpy, you should resolve the white screen problem.

Last thing. Normally you have to reconnect with usb to start adb wifi and open 5555 listening port while the device is rebooted. To solve this, you can try to write config rule to /system/build.prop like this:

service .adb.tcp.port=5555 // open port
persist,servicea.adb.enable=1 // enable adbd

Or, install a adb wifi app to make it happen. Here I use RikkaApps/WADB。Remember to disable battery optimization and lock it to ensure background running before rebooting.