///
///
import { AdbClientOptions, InputDurationOptions, CommandConstruct, CpOptions, ForwardsObject, IDevice, InputSource, InstallOptions, KeyEventOptions, LogcatOptions, MkDirOptions, MvOptions, ReversesObject, RmOptions, SettingsMode, PrimitiveType, StartActivityOptions, StartServiceOptions, TouchOptions, UninstallOptions, WaitForState, PropertyMap, NonEmptyArray, WaitForType, PropertyValue, TransportCommandConstruct, KeyCode } from './util';
import { SyncMode } from './sync';
import { Device } from './device';
import { Connection } from './connection';
import { FileStat } from './filestats';
import { LogcatReader } from './logcat/reader';
import { Monkey } from './monkey/client';
import { PullTransfer } from './sync/pulltransfer';
import { PushTransfer } from './sync/pushtransfer';
import { Readable } from 'stream';
import SyncEntry from './sync/entry';
import { Tracker } from './tracker';
export declare class Client {
private options;
/**
* @param {AdbClientOptions} options see AdbClientOptions for more details
*/
constructor(options?: AdbClientOptions);
/**
* Starts adb server if not running.
*/
startServer(): Promise;
private connection;
transport(serial: string): Promise;
/**
* Gets the adb server version.
*/
version(): Promise;
private ipConnect;
/**
* Connects to device over local network.
* @example
* adb.map(async (device) => {
* await device.tcpip();
* const [ip] = await device.getIpAddress();
* await adb.connect(ip);
*});
*/
connect(host: string): Promise;
connect(host: string, port: number): Promise;
/**
* Disconnects from the given device.
*/
disconnect(host: string): Promise;
disconnect(host: string, port: number): Promise;
/**
* Gets the list of currently connected devices and emulators.
*/
listDevices(): Promise;
/**
* Tracks connection status of devices.
*/
trackDevices(): Promise;
/**
* Kills the adb server.
*/
kill(): Promise;
/**
* Gets the serial number of the device.
* Meant for getting serial number of local devices.
* Analogous to `adb shell getprop ro.serialno`.
*/
getSerialNo(serial: string): Promise;
/**
* Gets the device path of the device identified by the device.
*/
getDevicePath(serial: string): Promise;
/**
* Lists properties of the device.
* Analogous to `adb shell getprop`.
*/
listProperties(serial: string): Promise;
/**
* Lists features of the device.
* Analogous to `adb shell pm list features`.
*/
listFeatures(serial: string): Promise;
/**
* Lists installed packages.
* Analogous to `adb shell pm list packages`.
*/
listPackages(serial: string): Promise;
/**
* Gets the ipv4 addresses of default wlan interface.
*/
getIpAddress(serial: string): Promise;
/**
* Forwards socket connections from the ADB server host (local) to the device (remote).
* Analogous to `adb forward `.
* @example
* adb.forward('serial', 'tcp:9222', 'localabstract:chrome_devtools_remote')
*/
forward(serial: string, local: string, remote: string): Promise;
/**
* Lists all forwarded connections.
* Analogous to `adb forward --list`.
*/
listForwards(serial: string): Promise;
/**
* Reverses socket connections from the device (remote) to the ADB server host (local).
* Analogous to `adb reverse `.
* @example
* adb.reverse('serial', 'localabstract:chrome_devtools_remote', 'tcp:9222')
*/
reverse(serial: string, local: string, remote: string): Promise;
/**
* Lists all reversed connections.
* Analogous to `adb reverse --list`.
*/
listReverses(serial: string): Promise;
private deleteApk;
/**
* Reboots the device.
* Analogous to `adb reboot`.
*/
reboot(serial: string): Promise;
/**
* Shuts the device down.
* Analogous to `adb reboot -p`.
*/
shutdown(serial: string): Promise;
/**
* Attempts to remount the `/system` partition in read-write mode.
* Can be done on a rooted device. Analogous to `adb remount`.
* Analogous to `adb remount`
*/
remount(serial: string): Promise;
/**
* Attempts to which the device to the root mode.
* Analogous to `adb root`.
*/
root(serial: string): Promise;
/**
* Takes a screenshot on the specified device.
* Analogous to `adb shell screencap -p`.
*/
screenshot(serial: string): Promise;
/**
* Opens a direct TCP connection to specified port on the device.
* Analogous to `adb tcp :`.
* @example
* const socket = await adb.openTcp('serial', 5555);
* // socket.write(...)
*/
openTcp(serial: string, port: number): Promise;
openTcp(serial: string, port: number, host: string): Promise;
/**
* Sends roll input command to the device shell.
* Analogous to `adb shell input trackball roll `.
* Default input source is `trackball`.
* @param x Horizontal coordinate.
* @param y Vertical coordinate.
*/
roll(serial: string, x: number, y: number): Promise;
roll(serial: string, x: number, y: number, source: InputSource): Promise;
/**
* Sends roll input command to the device shell.
* Analogous to `adb shell input trackball press`.
* Default input source is `trackball`.
*/
press(serial: string): Promise;
press(serial: string, source: InputSource): Promise;
/**
* Sends draganddrop input command to the device shell.
* Analogous to `adb shell input touchscreen draganddrop x1 y1 x2 y2`.
* Default input source is `touchscreen`.
* @param x1 Horizontal starting coordinate.
* @param y1 Vertical starting coordinate.
* @param x2 Horizontal ending coordinate.
* @param y2 Vertical ending coordinate.
*/
dragAndDrop(serial: string, x1: number, y1: number, x2: number, y2: number): Promise;
dragAndDrop(serial: string, x1: number, y1: number, x2: number, y2: number, options: InputDurationOptions): Promise;
/**
* Sends swipe input command to the device shell.
* Analogous to `adb shell input touchscreen swipe x1 y1 x2 y2`.
* Default input source is `touchscreen`.
* @param x1 Horizontal starting coordinate.
* @param y1 Vertical starting coordinate.
* @param x2 Horizontal ending coordinate.
* @param y2 Vertical ending coordinate.
*/
swipe(serial: string, x1: number, y1: number, x2: number, y2: number): Promise;
swipe(serial: string, x1: number, y1: number, x2: number, y2: number, options: InputDurationOptions): Promise;
/**
* Sends keyevent input command to the device shell.
* Analogous to `adb shell input keyboard keyevent `.
* Default input source is `keyboard`.
* @param code Key code to send.
*/
keyEvent(serial: string, code: KeyCode | NonEmptyArray): Promise;
keyEvent(serial: string, code: number | NonEmptyArray): Promise;
keyEvent(serial: string, code: KeyCode | NonEmptyArray, options: KeyEventOptions): Promise;
/**
* Sends tap input command to the device shell.
* Analogous to `adb shell input touchscreen tap `.
* Default input source is `touchscreen`.
* @param x Horizontal coordinate.
* @param y Vertical coordinate.
*/
tap(serial: string, x: number, y: number): Promise;
tap(serial: string, x: number, y: number, source: InputSource): Promise;
/**
* Sends text input command to the device shell.
* Analogous to `adb shell input touchscreen text ''`.
* Default input source is `touchscreen`.
*/
text(serial: string, text: string): Promise;
text(serial: string, text: string, source: InputSource): Promise;
/**
* Opens logcat.
* Analogous to `adb logcat`.
* @see `LogcatReader` and `LogcatOptions` for more details.
* @example
* 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);
* });
*/
openLogcat(serial: string): Promise;
openLogcat(serial: string, options: LogcatOptions): Promise;
private syncService;
/**
* Deletes all data associated with a package from the device.
* Analogous to `adb shell pm clear `.
*/
clear(serial: string, pkg: string): Promise;
private installRemote;
/**
* Installs an apk to the device.
* Analogous to `adb install `.
*/
install(serial: string, apk: string | Readable): Promise;
install(serial: string, apk: string | Readable, options: InstallOptions): Promise;
/**
* @param args Extra arguments. E.g. `--fastdeploy` flag.
*/
install(serial: string, apk: string | Readable, options: InstallOptions, args: string): Promise;
/**
* Uninstalls a package from the device.
* Analogous to `adb uninstall`.
*/
uninstall(serial: string, pkg: string): Promise;
uninstall(serial: string, pkg: string, options: UninstallOptions): Promise;
/**
* Tells if a package is installed or not.
*/
isInstalled(serial: string, pkg: string): Promise;
/**
* Starts a new activity with options.
* Analogous to `adb shell am start `.
*/
startActivity(serial: string, pkg: string, activity: string): Promise;
startActivity(serial: string, pkg: string, activity: string, options: StartActivityOptions): Promise;
/**
* Starts a new service with options.
* Analogous to `adb shell am startservice `.
*/
startService(serial: string, pkg: string, service: string): Promise;
startService(serial: string, pkg: string, service: string, options: StartServiceOptions): Promise;
/**
* Reads given directory.
* The path should start with `/`.
*/
readDir(serial: string, path: string): Promise;
/**
* Gets a PullTransfer instance.
* @see `PullTransfer`
* @example
* let data = '';
* const transfer = await adb.pull('serial', '/path')
* transfer.on('data', (chunk) => {
* data += chunk.toString();
* });
* transfer.on('end', () => {
* console.log(data);
* });
*/
pull(serial: string, path: string): Promise;
/**
* Gets a PushTransfer instance.
* @see `PushTransfer`
* @example
* const transfer = await adb.push('serial', '/path-src', '/path-dest')
* transfer.on('end', () => { });
*/
push(serial: string, srcPath: string | Readable, destPath: string): Promise;
push(serial: string, srcPath: string | Readable, destPath: string, mode: SyncMode): Promise;
private awaitActiveDevice;
/**
* Puts the device ADB daemon into tcp mode.
* Afterwards it is possible to use `connect` method.
* Analogous to `adb tcpip 5555`.
*/
tcpip(serial: string): Promise;
tcpip(serial: string, port: number): Promise;
/**
* Sets the device transport back to usb.
*/
usb(serial: string): Promise;
/**
* Waits until the device has finished booting.
*/
waitBootComplete(serial: string): Promise;
/**
* Waits until the device is in the given state.
* Analogous to `adb wait-for--`.
*/
waitFor(transport: WaitForType, state: WaitForState): Promise;
/**
* Maps through all connected devices.
*/
map(mapper: (device: Device) => Promise | T): Promise;
private pushInternal;
/**
* Wraps {@link push} method, provides API for quick data writing.
*/
pushDataToFile(serial: string, data: string | Buffer | Readable, destPath: string): Promise;
/**
* Wraps {@link push} method, reads the content of file on the host to a file on the device.
*/
pushFile(serial: string, srcPath: string, destPath: string): Promise;
/**
* Wraps {@link pull} method, reads the file content and resolves with the output.
*/
pullDataFromFile(serial: string, srcPath: string): Promise;
/**
* Wraps {@link pull} method, reads the content of file on the device and write it to a file on the machine.
*/
pullFile(serial: string, srcPath: string, destPath: string): Promise;
/**
* Sets property on the device.
* Analogues to `adb shell setprop `.
*/
setProp(serial: string, prop: string, value: PrimitiveType): Promise;
/**
* Gets property from the device.
* Analogues to `adb shell getprop `.
*/
getProp(serial: string, prop: string): Promise;
/**
* Puts setting on the device.
* Analogues to `adb shell settings put `.
*/
putSetting(serial: string, mode: SettingsMode, name: string, value: PrimitiveType): Promise;
/**
* Lists settings of the device.
* Analogues to `adb shell settings list `.
*/
listSettings(serial: string, mode: SettingsMode): Promise;
/**
* Gets setting from the device.
* Analogues to `adb shell settings get `.
*/
getSetting(serial: string, mode: SettingsMode, name: string): Promise;
/**
* Executes a given shell command via adb console interface. Analogous to `adb -s shell `.
*/
shell(serial: string, command: string): Promise;
/**
* Enables to execute any custom command.
* @example
* class MyCommand extends Command {
* protected autoEnd = true;
* private arg: string;
* constructor(connection: Connection, arg: string) {
* super(connection);
* this.arg = arg;
* }
* async execute(): Promise {
* 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);
* }
* }
* }
*/
custom(CustomCommand: CommandConstruct, ...args: P): Promise;
/**
* Enables to execute any custom transport command.
* @example
* class MyCommand extends TransportCommand {
* 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;
* }
* }
*/
customTransport(CustomCommand: TransportCommandConstruct, serial: string, ...args: P): Promise;
/**
* Establishes a new monkey connection on port `1080`.
*/
openMonkey(serial: string): Promise;
/**
* Force stops given package.
* Analogous to `adb shell am force-stop `.
*/
killApp(serial: string, pkg: string): Promise;
private execInternal;
/**
* Executes a given command via adb console interface.
* If cmd contains arguments, they need to be passed as and string[], not string. @see https://github.com/Maaaartin/adb-ts/issues/13
*/
exec(cmd: string | string[]): Promise;
/**
* Executes a given command on specific device via adb console interface.
* Analogous to `adb -s `.
* If cmd contains arguments, they need to be passed as and string[], not string. @see https://github.com/Maaaartin/adb-ts/issues/13
*/
execDevice(serial: string, cmd: string | string[]): Promise;
/**
* Executes a given command on specific device shell via adb console interface.
* Analogous to `adb -s shell ` .
*/
execDeviceShell(serial: string, cmd: string | string[]): Promise;
/**
* Retrieves current battery status.
* Analogous to `adb -s shell dumpsys battery` .
*/
batteryStatus(serial: string): Promise;
/**
* Removes file/folder specified by `path` parameter.
* Analogous to `adb shell rm `.
*/
rm(serial: string, path: string): Promise;
rm(serial: string, path: string, options: RmOptions): Promise;
/**
* Creates directory specified by `path` parameter.
* Analogous to `adb shell mkdir `.
*/
mkdir(serial: string, path: string): Promise;
mkdir(serial: string, path: string, options: MkDirOptions): Promise;
/**
* Updates access and modification times of file specified by `path` parameter, or creates a new file.
* Analogous to `adb shell touch `.
*/
touch(serial: string, path: string): Promise;
touch(serial: string, path: string, options: TouchOptions): Promise;
/**
* Moves data with `srcPath` to `destPath` parameter.
* Analogous to `adb shell mv `.
*/
mv(serial: string, srcPath: string, destPath: string): Promise;
mv(serial: string, srcPath: string, destPath: string, options: MvOptions): Promise;
/**
* Copies data with `srcPath` to `destPath` parameter.
* Analogous to `adb shell cp `.
*/
cp(serial: string, srcPath: string, destPath: string): Promise;
cp(serial: string, srcPath: string, destPath: string, options: CpOptions): Promise;
/**
* Gets file stats for specified path.
* Analogous to `adb stat `.
*/
fileStat(serial: string, path: string): Promise;
}