android 封装的规则,macaca-android驱动封装规则

Macaca Version:

Macaca Doctor Logs:

Operate System:

Programming Language:

查看macaca-android源代码发现,有的操作是直接通过adb操作进行的,比如截图getScreenshot,而有的是通过uiautomator-bootstramp在手机上启动服务端发送指令来实现的,请问这两者使用的规则是什么呢?哪种操作会使用adb直连进行操作?哪种操作需要走uiautomator服务端进行操作

getScreenshot截图走adb

controllers.getScreenshot = function *() {

const swapFilePath = temp.path({

prefix: `${pkg.name}-screenshot`,

suffix: '.png'

});

const remoteFile = `${this.adb.getTmpDir()}/screenshot.png`;

const cmd = `/system/bin/rm ${remoteFile}; /system/bin/screencap -p ${remoteFile}`;

yield this.adb.shell(cmd);

yield this.adb.pull(remoteFile, swapFilePath);

var base64 = null;

try {

let data = fs.readFileSync(swapFilePath);

base64 = new Buffer(data).toString('base64');

} catch (e) {

throw new errors.NoSuchWindow();

}

_.rimraf(swapFilePath);

return base64;

};

getSource获取dump先走uiautomator后走adb

controllers.getSource = function *() {

yield this.send({

cmd: 'getSource',

args: {

}

});

var tmpDir = this.adb.getTmpDir();

var xml = yield this.adb.shell(`cat ${tmpDir}/macaca-dump.xml`);

var xml_hack = yield this.adb.shell(`cat ${tmpDir}/local/tmp/macaca-dump.xml`);

return xml.length > xml_hack.length ? xml : xml_hack;

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值