droidVNC-NG icon indicating copy to clipboard operation
droidVNC-NG copied to clipboard

Add possibility to start server when usb cable is plugged in

Open godfuture opened this issue 3 years ago • 7 comments

Hi, my phone display was broken due to water. After some time, the display came back, but I guess this was simply luck. In case you want to have a backup when display is damaged, it would help to start VNC server only when USB is connected.

Still, if someone wants the server to be started all the time, the option requested here could be disabled.

Many thanks

godfuture avatar Sep 30 '21 23:09 godfuture

If you just want to copy files from your phone, use adb pull/push commands. Would that work for this case?

gitgrub avatar Oct 01 '21 00:10 gitgrub

Not really, main focus is to operate the phone when the display is not available. VNC is a great assist in such cases. For example to save the phone in urgency case like activating USB debugging (very important) or to do backups or using authentication apps (exception: Microsoft Authenticator showed only black screen. Do you know why?). Or simply to install other apps to help with whatever problems occur.

If the server is always started, this is not only a security problem, but also costs battery. On usb cable, energy does not play a very big role.

Edit: my idea was to start the server when usb is plugged in, but also to stop when usb is unplugged. Is it maybe possible to have some kind of wait time for the shutdown? Otherwise the server would start and stop with every connect and disconnect of the usb cable. I have quite some attempts to connect the usb cable. So it might happen that I connect/disconnect my phone several times in short moment.

godfuture avatar Oct 01 '21 00:10 godfuture

Got your point, interesting idea. Concerning the usb plug/unplug attempts, a way to go could be to start the server via adb command when the usb connection is stable. Otherwise the server would always been started when charging - security problem? This is an emergency scenario, you dont want that every time when charging. I am not against that idea, just thinking about it, guessing it would be a configurable option via checkbox.

It reminds me about a situation when a PC didnt show the screen, the graphic card was dead. As VNC was running there, I tried it this way, but that did not work. That was a disappointing moment. I think thats because VNC grabs the screen from graphic cards frame buffer. So the scenario would only work if the display is broken, not the graphic environment, if I understood that correctly.

PS: glad to hear your device is alive again, even when sunken into the ocean :-)

gitgrub avatar Oct 01 '21 08:10 gitgrub

Concerning the usb plug/unplug attempts, a way to go could be to start the server via adb command when the usb connection is stable.

Nice idea. I guess there is no usb debugging required?!

godfuture avatar Oct 01 '21 08:10 godfuture

Would https://stackoverflow.com/questions/13380590/is-it-possible-to-start-activity-through-adb-shell be it? I don't know though if usb debugging would need to be enabled or not...

bk138 avatar Oct 01 '21 08:10 bk138

I think usb debugging has to be enabled to use adb. Look at https://developer.android.com/studio/command-line/adb Here is an example list of adb commands, not complete for sure, but to see a bit whats possible: https://gist.github.com/Pulimet/5013acf2cd5b28e55036c82c91bd56d8

gitgrub avatar Oct 01 '21 09:10 gitgrub

I think usb debugging has to be enabled to use adb.

It does on my phone... Galaxy S8. Newer ones have USB debugging over wifi option (from articles I read when I first discovered this project) but this one you have to connect to USB first then can use over wifi after a adb tcpip port.

However if Android lets you detect/read the ARP, a list of "acceptable" MAC addresses to start/stop in droidVNC-NG could be used to start and stop the server just using TCP/IP... I haven't twiddled with that much but it might be an idea for better security.

Martii avatar Oct 01 '21 16:10 Martii

Can now be done via automation apps like MacroDroid, Automate or Tasker, see https://github.com/bk138/droidVNC-NG#remote-control-via-the-intent-interface

bk138 avatar Jun 13 '23 10:06 bk138