KDEConnect/Android Emulator

< KDEConnect
Revision as of 15:25, 27 November 2018 by Erik Duisters (talk | contribs) (Desktop setup)
Jump to: navigation, search
Under construction.png
 
Under Construction
This is a new page, currently under construction!

Running kdeconnect in an emulator

The android emulator uses the default qemu User Networking (SLIRP) backend which does not allow the emulator to be directly accessible from the host nor the local network, which prevents kdeconnect running on the desktop from seeing kdeconnect running in an emulator. In order to get a fully working network in the emulator it needs to be configured to use the tap networking backend which as an added bonus offers much better performance than the default user backend.

Running the emulator with the tap backend will create a virtual network device on the host machine that can than be configured as if it is a real ethernet card allowing you to create virtually any type of network topology. The most straightforward topology that can be created is the public bridge setup. In this setup we simply put both the emulators virtual interface and the desktops lan interface into a bridge so they will share the same network space (e.g. single IP-subnet). Another topology that can be used is the Routing with iptables setup this involves a little more work but will work in situations where your lan device does not support bridging (eg. some wireless drivers)

The public bridge setup

First you will have to unconfigure your lan interface, create the bridge, add your lan interface to it and assign the bridge an ip address. Assuming your lan interface is eth0 and the bridge interface you want to create is br0:

sudo ifconfig eth0 0.0.0.0
sudo ip link add br0 type bridge
sudo ip link set eth0 master br0
dhclient br0

To make the above changes permanent do the following: taken from kvm docs and reboot your system

System Changes
RedHat/Fedora
  1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0
    • comment out BOOTPROTO
    • Add BRIDGE=br0
  2. Create /etc/sysconfig/network-scripts/ifcfg-br0
    • The contents should be:
DEVICE=br0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge
STP=no
ZONE=<the same zone as eth0 is in>
Debian Edit /etc/network/interfaces
# Replace old eth0 config with br0
auto eth0 br0
# Use old eth0 config for br0 and configure the bridge
iface br0 inet dhcp
    bridge_ports   eth0
    bridge_stp     off
    bridge_maxwait 0
    bridge_fd      0
SuSE
  • Start YaST
  • Got to Network Configuration
  • Add new device -> Bridge
  • Tick your existing network device
  • done


Next you have to allow qemu-bridge-helper to add tap interfaces to this bridge, using your favorite text editor:

sudo vi /etc/qemu/bridge.conf
and add the following line:
allow br0

You can now start the emulator using the following command replacing <avd_name> with the name of an existing emulator:

emulator -avd <avd_name> -qemu --device virtio-net-pci,netdev=n1 -netdev tap,id=n1,"helper=/usr/libexec/qemu-bridge-helper --br=br0"&

To list available devices to use as <avd_name> use:

emulator -list-avds

The routing with iptables setup

Note-box-icon.png
Note
TODO

Content is available under Creative Commons License SA 4.0 unless otherwise noted.