DuoPlus CloudPhone Agent
Control and automate DuoPlus cloud phones using ADB broadcast commands.
For more information, visit DuoPlus Official Website.
Connecting Devices
Wireless Connection
CODEBLOCK0
All subsequent commands use -s <DEVICE_ID> to target a specific device.
Common Workflows
Launching an App
CODEBLOCK1
Analyzing the UI
Dump and pull the UI hierarchy to find element coordinates and attributes:
adb -s <DEVICE_ID> shell uiautomator dump /sdcard/view.xml && adb -s <DEVICE_ID> pull /sdcard/view.xml ./view.xml
Then grep for text or resource IDs to find
bounds="[x1,y1][x2,y2]".
Interacting with Elements
All interactions are sent via the helper script as JSON commands:
- - Tap coordinate: INLINECODE2
- Tap element by text: INLINECODE3
- Optional params:
resource_id,
class_name,
content_desc,
element_order (0-based index)
- - Long press: INLINECODE8
- Double tap: INLINECODE9
- Type text: INLINECODE10
- Must tap the input field first to focus it
- - Keyboard key: INLINECODE11
- Supported keys: enter, delete, tab, escape, space
-
direction: up/down/left/right (required). Coordinates are optional.
- - Home: INLINECODE14
- Back: INLINECODE15
- Wait: INLINECODE16
- Wait for element: INLINECODE17
- End task (only when stuck): INLINECODE18
All action commands are fire-and-forget — they do NOT return results. Take a screenshot after each action to verify.
Visual Verification
Take a screenshot, compress with cwebp, and pull to local for analysis:
CODEBLOCK3
If cwebp is not available, use the PNG directly.
How Commands Work (Internal)
Commands are sent as Base64-encoded JSON via ADB broadcast. The helper script scripts/send_command.sh handles this automatically:
CODEBLOCK4
The script builds the full payload (tasktype, taskid, md5, etc.), Base64-encodes it, and sends via:
CODEBLOCK5
Typical Workflow
CODEBLOCK6
Tips
- - Coordinates: The coordinate system is 0-1000 relative (top-left=0,0, bottom-right=1000,1000), NOT pixels.
- Element matching: Use CLICKELEMENT (by text) when possible; fall back to CLICKCOORDINATE when text matching fails.
- Input: Must tap the input field first (CLICKCOORDINATE or CLICKELEMENT) to focus, then INPUTCONTENT.
- Submit: After typing, use KEYBOARDOPERATION(key="enter") to submit.
- Wait: Use
sleep 1-3 between commands to allow the UI to update. Do NOT use shell sleep on the device. - Swipe coordinates: Must use irregular integers, avoid round numbers (500, 800). Vary coordinates between consecutive swipes.
DuoPlus 云手机代理
使用 ADB 广播命令控制和自动化 DuoPlus 云手机。
更多信息,请访问 DuoPlus 官方网站。
连接设备
无线连接
bash
adb connect
:
adb devices -l
后续所有命令均使用 -s 来指定目标设备。
常见工作流程
启动应用
bash
scripts/sendcommand.sh ID> {actionname:OPENAPP,params:{package_name:com.tencent.mm}}
分析界面
导出并拉取界面层级结构,以查找元素坐标和属性:
bash
adb -s ID> shell uiautomator dump /sdcard/view.xml && adb -s ID> pull /sdcard/view.xml ./view.xml
然后通过 grep 查找文本或资源 ID,找到 bounds=[x1,y1][x2,y2]。
与元素交互
所有交互均通过辅助脚本以 JSON 命令形式发送:
- - 点击坐标:scripts/sendcommand.sh ID> {actionname:CLICKCOORDINATE,params:{x:500,y:500}}
- 按文本点击元素:scripts/sendcommand.sh ID> {actionname:CLICKELEMENT,params:{text:Login}}
- 可选参数:resourceid、classname、contentdesc、elementorder(从0开始索引)
- - 长按:scripts/sendcommand.sh ID> {actionname:LONGCOORDINATE,params:{x:500,y:500,duration:1000}}
- 双击:scripts/sendcommand.sh ID> {actionname:DOUBLETAPCOORDINATE,params:{x:500,y:500}}
- 输入文本:scripts/send
command.sh ID> {actionname:INPUTCONTENT,params:{content:Hello,clearfirst:true}}
- 必须先点击输入框使其获得焦点
- - 键盘按键:scripts/sendcommand.sh ID> {actionname:KEYBOARDOPERATION,params:{key:enter}}
- 支持的按键:enter、delete、tab、escape、space
- - 滑动:scripts/sendcommand.sh ID> {actionname:SLIDEPAGE,params:{direction:up,startx:487,starty:753,endx:512,endy:289}}
- direction:up/down/left/right(必填)。坐标可选。
- - 主页:scripts/sendcommand.sh ID> {actionname:GOTOHOME,params:{}}
- 返回:scripts/sendcommand.sh ID> {actionname:PAGEBACK,params:{}}
- 等待:scripts/sendcommand.sh ID> {actionname:WAITTIME,params:{waittime:3000}}
- 等待元素:scripts/sendcommand.sh ID> {actionname:WAITFORSELECTOR,params:{text:Loading complete,timeout:10000}}
- 结束任务(仅在卡住时使用):scripts/sendcommand.sh ID> {actionname:END_TASK,params:{success:false,message:reason}}
所有操作命令均为发送即忘模式——它们不会返回结果。每次操作后请截图验证。
视觉验证
截图,使用 cwebp 压缩,并拉取到本地进行分析:
bash
在设备上截图
adb -s shell screencap -p /sdcard/screen.png
拉取到本地
adb -s pull /sdcard/screen.png ./screen.png
压缩为 WebP 格式以减小文件大小(可选,推荐用于视觉模型)
cwebp -q 60 -resize 540 0 ./screen.png -o ./screen.webp
如果 cwebp 不可用,直接使用 PNG 文件。
命令工作原理(内部)
命令通过 ADB 广播以 Base64 编码的 JSON 形式发送。辅助脚本 scripts/send_command.sh 会自动处理此过程:
bash
用法:scripts/sendcommand.sh ID>
scripts/sendcommand.sh 192.168.1.100:5555 {actionname:CLICK_ELEMENT,params:{text:Login}}
该脚本会构建完整的数据包(tasktype、taskid、md5 等),进行 Base64 编码,并通过以下方式发送:
bash
adb -s ID> shell am broadcast -a com.duoplus.service.PROCESSDATA --es message
典型工作流程
- 1. 分析界面 → 使用 uiautomator dump 查找元素,或截图进行视觉分析
- 执行操作 → 使用 send_command.sh 发送相应的操作 JSON
- 等待 1-3 秒 → 等待操作生效
- 验证 → 截图 + cwebp 压缩,或再次使用 uiautomator dump
- 重复步骤 2-4,直到完成所有请求的步骤
提示
- - 坐标:坐标系为 0-1000 相对坐标(左上角=0,0,右下角=1000,1000),而非像素坐标。
- 元素匹配:尽可能使用 CLICKELEMENT(按文本匹配);当文本匹配失败时,回退到 CLICKCOORDINATE。
- 输入:必须先点击输入框(使用 CLICKCOORDINATE 或 CLICKELEMENT)使其获得焦点,然后再使用 INPUTCONTENT。
- 提交:输入完成后,使用 KEYBOARDOPERATION(key=enter) 提交。
- 等待:在命令之间使用 sleep 1-3 等待界面更新。不要在设备上使用 shell sleep。
- 滑动坐标:必须使用不规则的整数,避免使用整数(500、800)。连续滑动之间应变化坐标。