bk138 / droidVNC-NG

VNC server app for Android that does not require root privileges.
GNU General Public License v2.0
1.22k stars 177 forks source link
android mediaprojection remote-desktop rfb server vnc vnc-server

droidVNC-NG

Join the chat at https://gitter.im/droidVNC-NG/community

This is an Android VNC server using contemporary Android 5+ APIs. It therefore does not require root access. In reverence to the venerable droid-VNC-server is is called droidVNC-NG.

If you have a general question, it's best to ask in the community chat. If your concern is about a bug or feature request instead, please use the issue tracker.

<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80"> <img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="80">

Features

How to use

  1. Install the app from either marketplace.
  2. Get it all the permissions required.
  3. Set a good password and consider turning the Start on Boot off.
  4. Connect to your local Wi-Fi. For accepting a connection your device should be connected to some Local Area Network that you can control, normally it is a router. Connections via data networks (i.e. your mobile provider) are not supported.
  5. Click Start and connect to your device.

Keyboard Shortcuts From a VNC Viewer

For accepting connections from outside

  1. You should allow Port Forwarding in your router's Firewall settings. Login to your router's settings (usually open 192.168.1.1 in your browser, some routers have password written on them).

  2. Find Port Forwarding, usually it's somewhere in Network - Firewall - Port Forwards.

  3. Create a new rule, this is an example from OpenWRT firmware.

    Name: VNC forwarding

    Protocol: TCP

    Source zone: wan may be "internet", "modem", something that suggests the external source.

    External port: 5900 by default or whatever you specified in the app.

    Destination zone: lan something that suggests local network.

    Internal IP address: your device's local IP address, leaving any is less secure. The device's address may change over time! You can look it up in your routers' connected clients info.

    Internal port: same as external port.

  4. Apply the settings, sometimes it requires rebooting a router.

  5. Figure out your public adress i.e. https://www.hashemian.com/whoami/.

  6. Use this address and port from above to connect to your device.

How to Pre-seed Preferences

DroidVNC-NG can read a JSON file with default settings that apply if settings were not changed by the user. A file named defaults.json needs to created under <external files directory>/Android/data/net.christianbeier.droidvnc_ng/files/ where depending on your device, <external files directory> is something like /storage/emulated/0 if the device shows two external storages or simply /sdcard if the device has one external storage.

An example defaults.json with completely new defaults (not all entries need to be provided) is:

{
    "port": 5901,
    "portReverse": 5555,
    "portRepeater": 5556,
    "scaling": 0.7,
    "viewOnly": false,
    "showPointers": true,
    "fileTransfer": true,
    "password": "supersecure",
    "accessKey": "evenmoresecure",
    "startOnBoot": true,
    "startOnBootDelay": 0
}

Remote Control via the Intent Interface

droidVNC-NG features a remote control interface by means of Intents. This allows starting the VNC server from other apps or on certain events. It is designed to be working with automation apps like MacroDroid, Automate or Tasker as well as to be called from code.

You basically send an explicit Intent to net.christianbeier.droidvnc_ng.MainService with one of the following Actions and associated Extras set:

The service answers with a Broadcast Intent with its Action mirroring your request:

There is one special case where the service sends a Broadcast Intent with action net.christianbeier.droidvnc_ng.ACTION_STOP without any extras: that is when it is stopped by the system.

Examples

Start a password-protected view-only server on port 5901

Using adb shell am syntax:

adb shell am start-foreground-service \
 -n net.christianbeier.droidvnc_ng/.MainService \
 -a net.christianbeier.droidvnc_ng.ACTION_START \
 --es net.christianbeier.droidvnc_ng.EXTRA_ACCESS_KEY de32550a6efb43f8a5d145e6c07b2cde \
 --es net.christianbeier.droidvnc_ng.EXTRA_REQUEST_ID abc123 \
 --ei net.christianbeier.droidvnc_ng.EXTRA_PORT 5901 \
 --es net.christianbeier.droidvnc_ng.EXTRA_PASSWORD supersecure \
 --ez net.christianbeier.droidvnc_ng.EXTRA_VIEW_ONLY true
Start a server with defaults from Tasker
Make an outbound connection to a listening viewer from the running server

For example from Java code:

See MainActivity.java.

Stop the server again

Using adb shell am syntax again:

adb shell am start-foreground-service \
 -n net.christianbeier.droidvnc_ng/.MainService \
 -a net.christianbeier.droidvnc_ng.ACTION_STOP \
 --es net.christianbeier.droidvnc_ng.EXTRA_ACCESS_KEY de32550a6efb43f8a5d145e6c07b2cde \
 --es net.christianbeier.droidvnc_ng.EXTRA_REQUEST_ID def456

Building

Contributing

Contributions to the project are very welcome and encouraged! They can come in many forms. You can:

Notes