Introducing AdbOrc

Photo by Guido Coppa on Unsplash

Introducing AdbOrc

Easily create a distributed network of remotely accessible Android devices

I used to work as a Software Engineer at Qualcomm, where they maintained a fleet of mobile devices for development and testing. Typically, developers had these devices connected to their setups and sharing them with other members of the team was not very convenient. If anyone wanted to use a device not connected to their machine, they would have to check if the device was available and then, either remotely connect to that setup or physically get the device from them. So, even if the actual usage time of each device was very limited, the friction involved in getting hold of a device and using it meant that there was an artificial shortage of these devices. This led to either poor utilization of devices or wasted developer time or both.

This is a common enough problem in many organizations where developers have to share devices for development and debugging. One of the solutions used by many organizations is to create a device lab where all the devices are centrally managed and shared among the developers. This solves the problem of sharing devices remotely, but if developers need physical access to the devices then they still have to go to the device lab to get the devices and return them once done. This also isn't very convenient or even possible in many cases. Not to mention the cost of maintaining a device lab is not feasible for small teams. Another alternative is to use cloud device farms, but that is not always an option for many organizations.

So, I built a tool that would make it easy to share devices remotely within a private network. The primary requirement was that the devices connected to different machines on the network be discoverable and accessible to users remotely without an explicit connection between the machines. The device network should also be easily extensible and scalable to support any number of devices and users.

Today, I am open-sourcing AdbOrc, a tool that makes it easy to create a pseudo-distributed network of android devices that can be shared securely with other users on your network for testing, debugging or development.

What is AdbOrc?

AdbOrc is a tool that enables the creation of a network where any user on the network can supply their android devices to the network and any other user can reserve and use those devices, all without explicitly connecting to the supplying user's setup or even knowing who the supplying user is. Think of it as a means to create a virtual device lab where devices are not physically centralized, but are still discoverable and accessible to all users on the network. Consider the following example of supplying and consuming devices between two users on the network:

supply devices

Here, the supplying user is adding a device connected to their computer to the AdbOrc network. Once the device is added to the network, it is no longer available to be used at the default ADB port on the supplier's computer.

consume devices

In the above illustration, a consuming user is querying for all available devices in the network and reserving an available device. Once a device is reserved, it is transparently accessible to the reserving user via ADB, and the user can even mirror and control the device screen remotely.

How does it work?

There are three modes of operation for a network node in AdbOrc:

  1. Supplier - A machine on the network that has one or more android devices attached to it. Supplier, as the name implies, supplies devices to the network. There can be any number of Suppliers on the network.

  2. Consumer - A machine on the network that wants to use one or more android devices. Consumer, as the name implies, consumes devices from the network. There can be any number of Consumers on the network.

  3. MarketMaker - A machine on the network that acts as a middleman between Suppliers and Consumers. MarketMaker is responsible for matching Suppliers and Consumers and handling all the metadata of the network. There is exactly one MarketMaker on the network. A network is initialized when a MarketMaker is started.

Once a network is initialized, any machine can join the network as a Supplier or a Consumer, or both. When a Supplier decides to supply devices, AdbOrc starts a unique ADB server for each supplied device and shares metadata related to the device with the MarketMaker. When a Consumer wants to use a device, it queries the MarketMaker for available devices and then connects to the ADB server of the device it wants to use. All the communication between the MarketMaker and the Supplier/Consumer is encrypted and authenticated following the noise protocol. By default, device communication using ADB is unencrypted. The Supplier can optionally choose to force encryption and authentication of the device communication by joining the network in secure mode. In this mode, the ADB server of the supplied device will only listen on the local interface and an encrypted tunnel will be established so that only authenticated consumer who has reserved the device will be able to communicate with the ADB server of the device from any other interface.

It uses scrcpy for mirroring and controlling the device screen remotely. To use this feature, the consumer must have scrcpy installed on their machine. The bundled release of AdbOrc, which is available for windows currently, is a batteries-included release that includes scrcpy and ADB binaries. If you are building AdbOrc from source, you will need to install scrcpy and ADB on your machine.

How to use it?

Start the network by starting MarketMaker on a machine:

$ adborc marketmaker start

Join the network as a Supplier from another machine:

$ adborc supplier start <MarketMaker_IP/Hostname>

# Or, if you wish to enable secure mode
$ adborc supplier start <MarketMaker_IP> --secure

# Supply specific devices to the network
$ adborc supplier supply --devices "<android_serial1>,<android_serial2>,..."

# Or, supply all connected devices
$ adborc supplier supply

Join the network as a Consumer from another machine:

$ adborc consumer start <MarketMaker_IP/Hostname>

# List available devices
$ adborc consumer list-available

# Reserve devices
$ adborc consumer reserve <device_id>

# Use the devices via adb
$ adb shell

# Or, mirror and control the devices via scrcpy
$ adborc consumer scrcpy <device_id>

Limitations

AdbOrc does not provide any kind of device management or device health monitoring. It is just a tool that makes it easy to share devices on a network. It is up to the user to manage the devices and ensure that they are in a good state before supplying them to the network. It is also not intended to be used as a replacement for cloud device farms. There are many cloud providers and even open source projects that provide this functionality.

Where can I get it?

It is now open source and available on GitHub!

If you are using Windows, you can download the latest pre-release from the releases page.

MacOS and Linux are also supported, but we have not yet released binaries for those platforms. You can build from source for those platforms.

Documentation for AdbOrc is available here. Let me know what you think and any feedback is welcome! I am also looking for contributors to help improve AdbOrc and make it more useful. If you are interested, open a PR or an issue on GitHub, or reach out to me at shubham at mobinex dot io.