UNPKG

multi-automator

Version:
114 lines (113 loc) 3.11 kB
/// <reference types="node" /> /** * @desc: adb * @author: john_chen * @date: 2025.02.22 */ import adbkit from 'bat-adbkit'; import { DevicesMap, ScreenSize } from '../types'; /** * 初始化 adb client * * @param {string} bin * @param {string} host * @param {number} port * @returns {Object} adb */ export declare function init(bin?: string, host?: string, port?: number): ReturnType<typeof adbkit.createClient>; /** * 获取 adb client * * @returns {Object} adb */ export declare function getAdb(): ReturnType<typeof adbkit.createClient> | null; /** * 执行 shell 命令 */ export declare function shell(deviceId: string, command: string): Promise<string>; /** * 异步执行 shell 命令 */ export declare function shellAsync(deviceId: string, command: string): Promise<any>; /** * 获取当前在连的设备列表 * * @return {Promise<DevicesMap>} deviceConnectMap */ export declare function devices(): Promise<DevicesMap>; /** * 检查设备是否可用 */ export declare function checkConnect(deviceId: string): Promise<void>; /** * 检查设备是否开启 USB 调试模式 */ export declare function checkDeviceSet(deviceId: string): Promise<void>; /** * 检查应用是否安装 */ export declare function isInstalled(deviceId: string, packageName: string): Promise<boolean>; /** * 检查文件是否存在 */ export declare function fileExist(deviceId: string, path: string): Promise<boolean>; /** * Forwards socket connections from the ADB server host (local) to the device (remote). */ export declare function forward(deviceId: string, local: string, remote: string): Promise<void>; /** * 获取本机 IP */ export declare function ip(deviceId: string): Promise<string>; /** * 返回主页 */ export declare function home(deviceId: string): Promise<string>; /** * 启动 Activity */ export declare function startActivity(deviceId: string, options: any): Promise<unknown>; /** * 安装应用 */ export declare function install(deviceId: string, appPath: string): Promise<void>; /** * 卸载应用 */ export declare function uninstall(deviceId: string, appId: string): Promise<void>; /** * 检查进程是否存在 */ export declare function isAppProcessExist(deviceId: string, processName: string): Promise<boolean>; /** * 终止 APP 进程 */ export declare function killAppProcess(deviceId: string, processName: string): Promise<void>; /** * 拉取文件 */ export declare function pull(deviceId: string, path: string): Promise<Buffer>; /** * 截图 */ export declare function screenshot(deviceId: string): Promise<Buffer>; /** * 获取设备屏幕尺寸 */ export declare function getScreenSize(deviceId: string): Promise<ScreenSize>; /** * 获取默认输入法 */ export declare function getDefaultKeyboard(deviceId: string): Promise<string>; /** * 切换输入法 */ export declare function changeKeyboard(deviceId: string, keyboard?: string): Promise<string>; /** * 回车 */ export declare function enter(deviceId: string): Promise<boolean>; /** * 返回 */ export declare function back(deviceId: string): Promise<boolean>;