Skip to main content
Version: 2.1.0

Create transport

Create transport for a device

declare class AdbServerClient {
createTransport(
device: AdbServerClient.DeviceSelector
): Promise<AdbTransport>;
}

The AdbServerClient#createTransport method creates an AdbTransport for the specified device. The device's state must be device.

It accepts a device selector value to specify the target device. Device selectors allow you to select a specific device in multiple ways.

In this tutorial, we will use the AdbServerClient.Device object we got from the previous step as a device selector. In fact, this is the best (most precise) way to select a device.

note

See device selector page for details.

This process is asynchronous, because AdbServerClient needs to fetch some extra information about the device from ADB Server.

import { AdbTransport } from "@yume-chan/adb";

const transport: AdbTransport = await client.createTransport(device);

Create an Adb instance

The transport object only contains the lower-level logic to communicate with devices, the Adb class provides a higher-level abstraction over ADB protocol and ADB commands.

const adb: Adb = new Adb(transport);

Or you can use the AdbServerClient.prototype.createAdb method directly:

import type { Adb, AdbServerClient } from "@yume-chan/adb";

declare const client: AdbServerClient;

const adb: Adb = await client.createAdb(device);
Next Step

See API section for all supported ADB and ADB Server commands.