Quick Start
Tango is a TypeScript re-implementation of ADB (Android Debug Bridge) client.
Pre-requisites
Tango runs on both Node.js and Web browsers. It requires the following features:
- Web Streams API.
ReadableStream
,WritableStream
andTransformStream
must be available onglobalThis
. If not, a polyfill likeweb-streams-polyfill
can be used. - BigInt. This can't be polyfilled.
- Promise
Recent versions of Node.js and Web browsers should have all these features.
Installation
Tango is split into multiple packages to handle different runtimes. First, install the two core packages:
@yume-chan/adb
: The platform-independent ADB client implementation@yume-chan/stream-extra
: Type definitions and utilities for Web Streams API.
- npm
- Yarn
- pnpm
npm i @yume-chan/adb @yume-chan/stream-extra
yarn add @yume-chan/adb @yume-chan/stream-extra
pnpm add @yume-chan/adb @yume-chan/stream-extra
Depending on the runtime and connection type, additional packages are required to communicate with devices (see below).
Direct Connection Transport
ADB Daemon is a program running on Android devices (when Developer Options are enabled) that handles ADB commands.
In this mode, Tango connects to the ADB daemon directly. This means it can run on devices without Google ADB (not installed, or not available, for example on mobile devices).
Direct connection mode supports three connection methods:
-
USB connection: requires a Web browser with WebUSB support (currently, only Chromium-based ones), or Node.js with
usb
package. Note that only one program (or Tango instance) can connect to a device at a time, so it's not compatible with Google ADB server. -
ADB over Wi-Fi: uses TCP sockets, thus not available in Web browsers. In Node.js, it can be implemented using the built-in
net
module. Note that this refers to the oldadb tcpip
mode, not the new Wireless Debugging/adb pair
mode added in Android 11. -
In addition, Tango also accepts custom connection implementations. For example, a WebSocket connection can forward TCP connections from a Node.js server to a Web browser.
Google ADB Client Transport
Google ADB server is a program running on PC that manages devices and allows sharing a device with multiple clients.
In this mode, Tango talks to a Google ADB server, which can either run on the same machine or on a remote machine.
Google ADB server is traditionally the only way to connect to the ADB daemon running on Android devices, so this mode is compatible with other programs that use ADB, such as Android Studio.
Because Google ADB server listens on a TCP socket, this mode is only available in Node.js. In Web browsers, a custom connector is required to forward TCP sockets from backend server.
Custom Transport
ADB protocol is a stream multiplexing protocol, where each ADB command is a logical stream, called ADB socket. The goal of both the Direct Connection Transport and Google ADB Client Transport is to manage ADB sockets.
Tango also supports custom transports that works directly on ADB socket level. For example, a mock transport can be used in tests, or a WebSocket transport to access devices on a server over the Internet.