node-android-devices
v0.1.1
Published
JavaScript library, designed to facilitate communication with Android devices. The library’s interface is Promise-based.
Downloads
2
Readme
JavaScript library, designed to facilitate communication with Android devices. The library’s interface is Promise-based.
Usage
import { getAdbDevices, execAdbCmdSync, execAdbCmdAsync, execAdbCmd } from 'node-android-devices'
/**
* get adb devices list
*/
cosnt list = await getAdbDevices()
// list: [ { sn: '0e2e40071d40xxxx', status: 'device' } ]
/**
* use sync method to run adb commamnd, will return a string
*/
const res = execAdbCmdSync('adb devices');
// res: List of devices attached
/**
* use async method to run adb commamnd, will return a string
*/
const res = await execAdbCmdAsync('adb devices');
// res: List of devices attached
// 0e2e40071d40xxxx device
/**
* use exec method to run adb commamnd, will return a ChildProcess
* so than you can control the adb process more finely
*/
const adbShell = execAdbCmd('adb shell')
adbShell.stdin.write('ls /data/tmp \n')
adbShell.stdin.write('ls /data/tmp/dir \n')
/**
* use spawn method to run adb commamnd, will return a ChildProcess
* so than you can control the adb process more finely
*/
const adbShell = spawnAdbCmd('adb', ['shell'])
adbShell.stdin.write('ls /data/tmp \n')
adbShell.stdin.write('ls /data/tmp/dir \n')
Apk
declare function isApkInstalled(
sn: string,
apkName: string
): Promise<{
status: boolean,
msg: string,
}>;
declare function installApk(
sn: string,
apkPath: string
): Promise<{
status: boolean,
msg: string,
}>;
declare function uninstallApk(
sn: string,
apkName: string
): Promise<{
status: boolean,
msg: string,
}>;