support genymotion emulator

This commit is contained in:
2024-11-14 21:51:59 +01:00
parent 1aec686c0b
commit 3e374f10fa
3 changed files with 22 additions and 16 deletions
+13 -4
View File
@@ -2,6 +2,7 @@ const {exec} = require("child_process");
// DEVICE_REGEX = "(^[a-z0-9A-Z]*) .* model:([a-z0-9A-Z_]+)"
DEVICE_REGEX = "(^[a-z0-9A-Z-.:]*) .* model:([a-z0-9A-Z_]+)"
// DEVICE_REGEX = "(^[a-z0-9A-Z-]*) .* model:([a-z0-9A-Z_]+)"
@@ -26,10 +27,11 @@ async function devices() {
const o = currentLine.split('\t')
findResult = currentLine.match(DEVICE_REGEX)
console.log(findResult)
try{
result.push(new AndroidDevice(findResult[1], findResult[2]));}
catch(e){
console.log(e)}
try {
result.push(new AndroidDevice(findResult[1], findResult[2]));
} catch (e) {
console.log(e)
}
console.log(result[i])
}
}
@@ -60,6 +62,13 @@ class AndroidDevice {
}
}
async clearApp(packageName) {
let cmd = `adb -s ${this.serial} shell pm clear ${packageName}`
console.log("cmd is " + cmd)
await exec(cmd);
}
shell(cmd) {
return new Promise((resolve, reject) => {
exec("adb -s " + this.serial + " shell " + cmd, (error, stdout, stderr) => {