root

root

冰狐支持在已经被root过的手机上使用root权限开发自动化脚本 。isRootedenableAccessibilityscreenshotclickswipehomebackrecentAppsenterkeyexecCmd
// 例子:使用root功能 实现点击
function main() {
    root.click(750, 650)
}

isRooted

判断设备是否已经被root,返回boolean。
参数:
参数名 类型 必填 说明

enableAccessibility

开启无障碍权限。
参数:
参数名 类型 必填 说明
serviceName string 选填 服务名:packageName/FullServiceName,比如:com.libra.aznfz/com.libra.sar.robot.RobotService

screenshot

截屏。
参数:
参数名 类型 必填 说明
path string 必填 截屏后存储的目标图片文件

click

点击。
参数:
参数名 类型 必填 说明
x integer 必填 x坐标
y integer 必填 y坐标

swipe

滑动。
参数:
参数名 类型 必填 说明
startX integer 必填 开始x坐标
startY integer 必填 开始y坐标
endX integer 必填 结束x坐标
endY integer 必填 结束y坐标
duration integer 选填 滑动时间,单位毫秒,默认:800

home

按下home按键。
参数:
参数名 类型 必填 说明

back

按下back按键。
参数:
参数名 类型 必填 说明

recentApps

按下最近任务按键。
参数:
参数名 类型 必填 说明

enter

按下回车按键。
参数:
参数名 类型 必填 说明

key

按键。
参数:
参数名 类型 必填 说明
keyCode integer 必填 按键代码

execCmd

使用root权限执行adb命令,返回string。
参数:
参数名 类型 必填 说明
cmd string 必填 adb命令