Optional
options: AdbClientOptionsPrivate
optionsPrivate
awaitRetrieves current battery status.
Analogous to adb -s <serial> shell dumpsys battery
.
Connects to device over local network.
adb.map(async (device) => {
await device.tcpip();
const [ip] = await device.getIpAddress();
await adb.connect(ip);
});
Private
connectionCopies data with srcPath
to destPath
parameter.
Analogous to adb shell cp <src> <dest>
.
Enables to execute any custom command.
Rest
...args: Pclass MyCommand extends Command<number> {
protected autoEnd = true;
private arg: string;
constructor(connection: Connection, arg: string) {
super(connection);
this.arg = arg;
}
async execute(): Promise<number> {
const reply = await this.initExecute(this.arg);
switch (reply) {
case Reply.OKAY:
const value = await this.parser.readValue();
return parseInt(value.toString(), 10);
case Reply.FAIL:
throw await this.parser.readError();
default:
return parseInt(reply, 10);
}
}
}
Enables to execute any custom transport command.
Rest
...args: Pclass MyCommand extends TransportCommand<null> {
protected keepAlive = false;
private arg: string;
constructor(connection: Connection, serial: string, arg: string) {
super(connection, serial);
this.arg = arg;
}
protected get Cmd() {
return 'test '.concat(this.arg);
}
protected postExecute(): null {
return null;
}
}
Private
deleteSends draganddrop input command to the device shell.
Analogous to adb shell input touchscreen draganddrop x1 y1 x2 y2
.
Default input source is touchscreen
.
Horizontal starting coordinate.
Vertical starting coordinate.
Horizontal ending coordinate.
Vertical ending coordinate.
Private
execForwards socket connections from the ADB server host (local) to the device (remote).
Analogous to adb forward <local> <remote>
.
adb.forward('serial', 'tcp:9222', 'localabstract:chrome_devtools_remote')
Gets property from the device.
Analogues to adb shell getprop <prop>
.
Gets setting from the device.
Analogues to adb shell settings get <mode> <name>
.
Installs an apk to the device.
Analogous to adb install <pkg>
.
Extra arguments. E.g. --fastdeploy
flag.
Private
installPrivate
ipSends keyevent input command to the device shell.
Analogous to adb shell input keyboard keyevent <code>
.
Default input source is keyboard
.
Key code to send.
Lists features of the device.
Analogous to adb shell pm list features
.
Lists all forwarded connections.
Analogous to adb forward --list
.
Lists properties of the device.
Analogous to adb shell getprop
.
Lists all reversed connections.
Analogous to adb reverse --list
.
Lists settings of the device.
Analogues to adb shell settings list <mode>
.
Creates directory specified by path
parameter.
Analogous to adb shell mkdir <path>
.
Moves data with srcPath
to destPath
parameter.
Analogous to adb shell mv <src> <dest>
.
Opens logcat.
Analogous to adb logcat
.
LogcatReader
and LogcatOptions
for more details.
import { Client, Priority } from 'adb-ts';
const adb = new Client();
const logcat = await adb.openLogcat('serial', {
filter: (entry) => entry.priority > Priority.INFO
});
logcat.on('entry', (entry) => {
console.log(entry);
});
Opens a direct TCP connection to specified port on the device.
Analogous to adb tcp <port>:<host>
.
const socket = await adb.openTcp('serial', 5555);
// socket.write(...)
Sends roll input command to the device shell.
Analogous to adb shell input trackball press
.
Default input source is trackball
.
Gets a PullTransfer instance.
PullTransfer
let data = '';
const transfer = await adb.pull('serial', '/path')
transfer.on('data', (chunk) => {
data += chunk.toString();
});
transfer.on('end', () => {
console.log(data);
});
Wraps pull method, reads the file content and resolves with the output.
Wraps pull method, reads the content of file on the device and write it to a file on the machine.
Gets a PushTransfer instance.
PushTransfer
const transfer = await adb.push('serial', '/path-src', '/path-dest')
transfer.on('end', () => { });
Wraps push method, provides API for quick data writing.
Wraps push method, reads the content of file on the host to a file on the device.
Private
pushPuts setting on the device.
Analogues to adb shell settings put <mode> <name> <value>
.
Reverses socket connections from the device (remote) to the ADB server host (local).
Analogous to adb reverse <remote> <local>
.
adb.reverse('serial', 'localabstract:chrome_devtools_remote', 'tcp:9222')
Removes file/folder specified by path
parameter.
Analogous to adb shell rm <path>
.
Sends roll input command to the device shell.
Analogous to adb shell input trackball roll <x> <y>
.
Default input source is trackball
.
Horizontal coordinate.
Vertical coordinate.
Sets property on the device.
Analogues to adb shell setprop <prop> <value>
.
Starts a new activity with options.
Analogous to adb shell am start <pkg./activity>
.
Starts a new service with options.
Analogous to adb shell am startservice <pkg> <service>
.
Sends swipe input command to the device shell.
Analogous to adb shell input touchscreen swipe x1 y1 x2 y2
.
Default input source is touchscreen
.
Horizontal starting coordinate.
Vertical starting coordinate.
Horizontal ending coordinate.
Vertical ending coordinate.
Private
syncSends tap input command to the device shell.
Analogous to adb shell input touchscreen tap <x> <y>
.
Default input source is touchscreen
.
Horizontal coordinate.
Vertical coordinate.
Sends text input command to the device shell.
Analogous to adb shell input touchscreen text '<text>'
.
Default input source is touchscreen
.
Updates access and modification times of file specified by path
parameter, or creates a new file.
Analogous to adb shell touch <filename>
.
Uninstalls a package from the device.
Analogous to adb uninstall
.
Waits until the device is in the given state.
Analogous to adb wait-for-<transport>-<state>
.
see AdbClientOptions for more details