常用示例
可直接复制的日常任务写法,涵盖 Python、Node.js、C# 和 shell:从全新启动应用、关闭弹窗,到读取列表、重试、一次性验证码和获取新的 IP 地址。
本页为译文。如与英文版不一致,以英文版为准。 English
每个示例解决一个常见任务。选择一次语言,页面上的所有示例都会随之切换。示例假设 d 是一部已连接的手机(Python 中为 d = connect(),Node.js 中为 const d = await connect(),C# 中为 await using var d = await DroidlineClient.ConnectAsync());在 shell 中,每条 droidline 命令都会自己找到手机。
确认手机已就绪
唤醒屏幕,并检查它没有被 PIN 锁住,因为 Droidline 无法解锁 PIN:
d.wake()
if d.locked():
raise SystemExit("Unlock the phone, or turn off its screen lock, first")
if d.battery()["level"] < 15:
print("Battery is low")await d.wake();
if (await d.locked()) throw new Error("Unlock the phone, or turn off its screen lock, first");
if ((await d.battery()).level < 15) console.log("Battery is low");await d.WakeAsync();
if (await d.LockedAsync())
throw new InvalidOperationException("Unlock the phone, or turn off its screen lock, first");
if ((await d.BatteryAsync()).Level < 15)
Console.WriteLine("Battery is low");droidline wake
if [ "$(droidline locked)" = "true" ]; then
echo "Unlock the phone first" >&2; exit 1
fi从干净的状态启动应用
launch 会把应用带到前台,停在它上次离开的地方。要从第一个界面开始,先强行停止它。要像刚安装一样开始,就清除它的数据。这两件事都在 Android 的设置应用里完成,所以它们是用普通命令组合出来的示例,见下文:
force_stop(d, "com.example.shop") # 下文示例中的函数
d.launch("com.example.shop")
clear_data(d, "com.example.shop") # 也会清除登录状态和设置
d.launch("com.example.shop")await forceStop(d, "com.example.shop"); // 下文示例中的函数
await d.launch("com.example.shop");
await clearData(d, "com.example.shop"); // 也会清除登录状态和设置
await d.launch("com.example.shop");await ForceStopAsync(d, "com.example.shop"); // 下文示例中的函数
await d.LaunchAsync("com.example.shop");
await ClearDataAsync(d, "com.example.shop"); // 也会清除登录状态和设置
await d.LaunchAsync("com.example.shop");在设备所有者模式下,clear_data(package) 不打开设置,直接清除数据。droidline apps 会列出包名。
关闭可能出现也可能不出现的弹窗
广告、评分请求和提示时有时无。用条件逐一检查,条件从不等待,也从不失败:
for text in ["Not now", "Close ad", "Skip", "Later"]:
if d.exists("text", text):
d.touch("text", text)for (const text of ["Not now", "Close ad", "Skip", "Later"]) {
if (await d.exists("text", text)) await d.touch("text", text);
}foreach (var text in new[] { "Not now", "Close ad", "Skip", "Later" })
{
if (await d.ExistsAsync("text", text))
await d.TouchAsync("text", text);
}for text in "Not now" "Close ad" "Skip" "Later"; do
if [ "$(droidline exists text "$text")" = "true" ]; then
droidline touch text "$text"
fi
done如果弹窗在界面打开之后片刻才出现,就像下一个示例那样,用 which 等待最先出现的那一个。
处理结果不确定的步骤
点击之后,应用可能显示下一个界面、一条错误或一个弹窗。which 等待几个候选项中最先出现的那一个,并告诉你出现的是哪一个:
d.touch("text", "Pay")
result = d.which([("text", "Payment complete"),
("textContains", "declined"),
("text", "Confirm")], timeout=30)
if result == 2:
d.touch("text", "Confirm")
elif result != 0:
d.screenshot("payment-problem.png")await d.touch("text", "Pay");
const result = await d.which([["text", "Payment complete"],
["textContains", "declined"],
["text", "Confirm"]], { timeout: 30 });
if (result === 2) await d.touch("text", "Confirm");
else if (result !== 0) await d.screenshot("payment-problem.png");await d.TouchAsync("text", "Pay");
var result = await d.WhichAsync(new object[]
{
("text", "Payment complete"),
("textContains", "declined"),
("text", "Confirm"),
}, timeout: 30);
if (result == 2)
await d.TouchAsync("text", "Confirm");
else if (result != 0)
await d.ScreenshotAsync("payment-problem.png");droidline touch text Pay
result=$(droidline which text="Payment complete" textContains=declined text=Confirm --timeout 30)
case "$result" in
2) droidline touch text Confirm ;;
0) ;;
*) droidline screenshot payment-problem.png ;;
esac等待某件事完成
等待加载动画或“Loading”标签消失,或者等待结果出现:
d.wait_gone("id", "progress", 60)
d.wait("textContains", "Upload complete", 120)await d.waitGone("id", "progress", 60);
await d.wait("textContains", "Upload complete", 120);await d.WaitGoneAsync("id", "progress", 60);
await d.WaitAsync("textContains", "Upload complete", 120);droidline wait_gone id progress 60
droidline wait textContains "Upload complete" 120如果没有特定的元素可等,例如列表正在填充或页面正在滑入,就等到界面不再变化,而不是固定地 sleep 一段时间:
d.touch("text", "搜索")
d.wait_idle() # 500 毫秒内没有新的绘制
d.wait_idle(1000, 20) # 安静 1 秒,20 秒后放弃await d.touch("text", "搜索");
await d.waitIdle();
await d.waitIdle(1000, 20);await d.TouchAsync("text", "搜索");
await d.WaitIdleAsync(); // 500 毫秒内没有新的绘制
await d.WaitIdleAsync(1000, 20); // 安静 1 秒,20 秒后放弃droidline touch text 搜索
droidline wait_idle一直在动的界面,例如视频或永不停止的加载动画,会以 TIMEOUT 结束;在这种界面上请等待特定的元素。
输入文字和按键
input 填写输入框,替换原有内容;append=True 则改为追加。sendkey 按下一个键,例如按 Enter 提交搜索:
d.input("id", "search", "android automation")
d.sendkey("enter")
d.input("id", "note", " and more", append=True)
d.clear("id", "note")await d.input("id", "search", "android automation");
await d.sendkey("enter");
await d.input("id", "note", " and more", { append: true });
await d.clear("id", "note");await d.InputAsync("id", "search", "android automation");
await d.SendkeyAsync("enter");
await d.InputAsync("id", "note", " and more", append: true);
await d.ClearAsync("id", "note");droidline input id search "android automation"
droidline sendkey enter任何语言和文字都可以输入,包括韩文、中文和 emoji。键名包括 enter、tab、del、space、escape、back 和 home。
读取列表中的每一项
dump 返回整棵树,所以用几行普通代码就能收集其中的值:
def texts(node):
if node.get("text"):
yield node["text"]
for child in node.get("children", []):
yield from texts(child)
screen = d.dump()
print(list(texts(screen["tree"])))function* texts(node) {
if (node.text) yield node.text;
for (const child of node.children ?? []) yield* texts(child);
}
const screen = await d.dump();
console.log([...texts(screen.tree)]);static IEnumerable<string> Texts(Node node)
{
var text = node.Get<string>("text");
if (!string.IsNullOrEmpty(text))
yield return text;
foreach (var child in node.Get<List<Node>>("children") ?? new())
foreach (var t in Texts(child))
yield return t;
}
var screen = await d.DumpAsync();
Console.WriteLine(string.Join(", ", Texts(screen.Tree)));droidline dump | jq -r '.. | .text? // empty | select(. != "")'如果各项使用相同的 id,find_all 会直接把它们交给你,并且可以在每一项里面继续查找:
for row in d.find_all("id", "item_row"):
print(row.find("id", "title").text, row.find("id", "price").text)for (const row of await d.findAll("id", "item_row")) {
console.log((await row.find("id", "title")).text, (await row.find("id", "price")).text);
}foreach (var row in await d.FindAllAsync("id", "item_row"))
{
var title = await row.FindAsync("id", "title");
var price = await row.FindAsync("id", "price");
Console.WriteLine($"{title.Text} {price.Text}");
}对于很长的列表,收集一次,向上滑动,再收集,直到没有新内容出现为止:
seen = []
while True:
new = [t for t in texts(d.dump()["tree"]) if t not in seen]
if not new:
break
seen += new
d.swipe("up")
print(seen)const seen = [];
for (;;) {
const fresh = [...texts((await d.dump()).tree)].filter((t) => !seen.includes(t));
if (fresh.length === 0) break;
seen.push(...fresh);
await d.swipe("up");
}
console.log(seen);var seen = new List<string>();
while (true)
{
var fresh = Texts((await d.DumpAsync()).Tree).Where(t => !seen.Contains(t)).ToList();
if (fresh.Count == 0)
break;
seen.AddRange(fresh);
await d.SwipeAsync("up");
}
Console.WriteLine(string.Join(", ", seen));失败时保留截图
把一次运行包起来,这样任何失败都会留下一张截图和一份界面转储:
from datetime import datetime
from droidline import DroidlineError
try:
run_my_steps(d)
except DroidlineError:
stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
d.screenshot(f"fail-{stamp}.png")
d.dump(f"fail-{stamp}.json")
raisetry {
await runMySteps(d);
} catch (e) {
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
await d.screenshot(`fail-${stamp}.png`);
await d.dump(`fail-${stamp}.json`);
throw e;
}try
{
await RunMyStepsAsync(d);
}
catch (DroidlineException)
{
var stamp = DateTime.Now.ToString("yyyyMMdd-HHmmss");
await d.ScreenshotAsync($"fail-{stamp}.png");
await d.DumpAsync($"fail-{stamp}.json");
throw;
}trap 'droidline screenshot "fail-$(date +%s).png"' ERR在测试套件中不必自己写这些:可选的 pytest 插件和 Node.js 辅助函数以及 .NET 的 Testing.SaveFailureAsync 会为每个失败的测试保存截图、界面树和发给手机的最近命令。
重试偶尔失败的步骤
错误会说明重试是否可能有用。只重试这类错误:
import time
from droidline import DroidlineError
for attempt in range(3):
try:
d.touch("text", "Refresh")
break
except DroidlineError as e:
if not e.retryable or attempt == 2:
raise
time.sleep(2)import { DroidlineError } from "droidline";
for (let attempt = 0; ; attempt++) {
try {
await d.touch("text", "Refresh");
break;
} catch (e) {
if (!(e instanceof DroidlineError) || !e.retryable || attempt === 2) throw e;
await new Promise((r) => setTimeout(r, 2000));
}
}for (var attempt = 0; ; attempt++)
{
try
{
await d.TouchAsync("text", "Refresh");
break;
}
catch (DroidlineException e) when (e.Retryable && attempt < 2)
{
await Task.Delay(2000);
}
}for attempt in 1 2 3; do
droidline touch text Refresh && break
sleep 2
done打开网页或深层链接
d.chrome.go("droidline.dev") # 在 Chrome 的当前标签页中打开
d.open_url("https://droidline.dev/docs/") # 在默认浏览器中打开
d.open_url("myapp://orders/42") # 直接进入支持深层链接的应用中的某个界面await d.chrome.go("droidline.dev");
await d.openUrl("https://droidline.dev/docs/");
await d.openUrl("myapp://orders/42");await d.Chrome.GoAsync("droidline.dev"); // 在 Chrome 的当前标签页中打开
await d.OpenUrlAsync("https://droidline.dev/docs/"); // 在默认浏览器中打开
await d.OpenUrlAsync("myapp://orders/42"); // 直接进入支持深层链接的应用中的某个界面droidline chrome.go droidline.dev
droidline open_url https://droidline.dev/docs/对于 launch 无法直接打开的界面,深层链接往往是唯一的到达途径。像设置页面这样允许其他应用按 intent action 打开的界面,可以用 intent 打开;设置应用示例用的就是这种方式。
等待通知中的验证码
先允许应用的通知发送到电脑(只需一次,用 notify_filter 或在应用的状态标签页中设置)。然后等待消息,并取出其中的数字:
import re
d.notify_filter(["com.google.android.apps.messaging"])
n = d.wait_notification("textContains", "code", 120)
code = re.search(r"\d{4,8}", n["text"]).group()
d.input("id", "otp", code)await d.notifyFilter(["com.google.android.apps.messaging"]);
const n = await d.waitNotification("textContains", "code", 120);
const code = n.text.match(/\d{4,8}/)[0];
await d.input("id", "otp", code);using System.Text.RegularExpressions;
await d.NotifyFilterAsync(new[] { "com.google.android.apps.messaging" });
var n = await d.WaitNotificationAsync("textContains", "code", 120);
var code = Regex.Match(n.Get<string>("text") ?? "", @"\d{4,8}").Value;
await d.InputAsync("id", "otp", code);code=$(droidline --json wait_notification textContains code 120 | jq -r '.value.text' | grep -oE '[0-9]{4,8}' | head -1)
droidline input id otp "$code"通过剪贴板复制和粘贴
d.clipboard("text to paste")
d.long_touch("id", "message") # 输入框的菜单中有 Paste
d.touch("text", "Paste")
print(d.clipboard()) # 再读取出来await d.clipboard("text to paste");
await d.longTouch("id", "message");
await d.touch("text", "Paste");
console.log(await d.clipboard());await d.ClipboardAsync("text to paste");
await d.LongTouchAsync("id", "message"); // 输入框的菜单中有 Paste
await d.TouchAsync("text", "Paste");
Console.WriteLine(await d.ClipboardAsync()); // 再读取出来droidline clipboard "text to paste"
droidline clipboard在 Android 10 及以上版本上读取剪贴板,需要把 Droidline 键盘设为当前键盘。
设置应用:强行停止、清除数据、切换网络
强行停止应用、清除应用数据,以及切换 Wi-Fi、移动数据或飞行模式,都在 Android 的设置应用里完成。intent 直接打开对应的设置界面,再用普通命令点击按钮。设置应用因手机厂商、Android 版本和系统语言而异,所以这些功能以示例的形式提供,而不是命令。
这些示例共用几个选择器。textMatches 接受正则表达式,所以一个模式可以同时包含多种语言的文字。android:id/button1 是 Android 对话框的标准确认按钮,在任何语言下 id 都相同。
FORCE_STOP = {"textMatches": "Force stop|강제 중지|强行停止"}
STORAGE = {"textMatches": "Storage.*|저장공간.*|存储.*"}
CLEAR = {"textMatches": "Clear (data|storage)|데이터 삭제|清除(数据|存储空间)"}
OK = ("id", "android:id/button1") # Android 对话框的确认按钮,与语言无关const FORCE_STOP = { textMatches: "Force stop|강제 중지|强行停止" };
const STORAGE = { textMatches: "Storage.*|저장공간.*|存储.*" };
const CLEAR = { textMatches: "Clear (data|storage)|데이터 삭제|清除(数据|存储空间)" };
const OK = ["id", "android:id/button1"]; // Android 对话框的确认按钮,与语言无关var forceStop = new { textMatches = "Force stop|강제 중지|强行停止" };
var storage = new { textMatches = "Storage.*|저장공간.*|存储.*" };
var clear = new { textMatches = "Clear (data|storage)|데이터 삭제|清除(数据|存储空间)" };
var ok = new { id = "android:id/button1" }; // Android 对话框的确认按钮,与语言无关FORCE_STOP='{"textMatches":"Force stop|강제 중지|强行停止"}'
STORAGE='{"textMatches":"Storage.*|저장공간.*|存储.*"}'
CLEAR='{"textMatches":"Clear (data|storage)|데이터 삭제|清除(数据|存储空间)"}'强行停止应用
android.settings.APPLICATION_DETAILS_SETTINGS 会打开应用信息页面。强行停止按钮显示为灰色,说明应用没有在运行,无需停止:
def force_stop(d, package):
d.intent("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + package)
d.wait_idle()
button = d.find(FORCE_STOP)
if button["enabled"]: # 应用未运行时按钮为灰色
button.click()
d.touch(*OK)async function forceStop(d, pkg) {
await d.intent("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + pkg);
await d.waitIdle();
const button = await d.find(FORCE_STOP);
if (button.node.enabled) { // 应用未运行时按钮为灰色
await button.click();
await d.touch(...OK);
}
}async Task ForceStopAsync(Device d, string package)
{
await d.IntentAsync("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + package);
await d.WaitIdleAsync();
var button = await d.FindAsync(forceStop);
if (button["enabled"] is true) // 应用未运行时按钮为灰色
{
await button.ClickAsync();
await d.TouchAsync(ok);
}
}droidline intent android.settings.APPLICATION_DETAILS_SETTINGS package:com.example.shop
droidline wait_idle
if [ "$(droidline --json find "$FORCE_STOP" | jq -r '.value.enabled')" = "true" ]; then
droidline touch "$FORCE_STOP"
droidline touch id android:id/button1
fi清除应用数据
这也会清除登录状态和设置。在设备所有者模式下,clear_data(package) 不打开设置,直接清除。不在设备所有者模式时,就经过应用的存储页面:
def clear_data(d, package): # 在设备所有者模式下,d.clear_data(package) 会直接完成
d.intent("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + package)
d.wait_idle()
d.scroll_to(STORAGE)
d.touch(STORAGE)
d.wait_idle()
d.touch(CLEAR)
d.touch(*OK)async function clearData(d, pkg) { // 在设备所有者模式下,d.clearData(pkg) 会直接完成
await d.intent("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + pkg);
await d.waitIdle();
await d.scrollTo(STORAGE);
await d.touch(STORAGE);
await d.waitIdle();
await d.touch(CLEAR);
await d.touch(...OK);
}// 在设备所有者模式下,d.ClearDataAsync(package) 会直接完成
async Task ClearDataAsync(Device d, string package)
{
await d.IntentAsync("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" + package);
await d.WaitIdleAsync();
await d.ScrollToAsync(storage);
await d.TouchAsync(storage);
await d.WaitIdleAsync();
await d.TouchAsync(clear);
await d.TouchAsync(ok);
}droidline intent android.settings.APPLICATION_DETAILS_SETTINGS package:com.example.shop
droidline wait_idle
droidline scroll_to "$STORAGE"
droidline touch "$STORAGE"
droidline wait_idle
droidline touch "$CLEAR"
droidline touch id android:id/button1Chrome 等部分应用在存储页面上显示的是管理空间,而不是清除按钮。这类应用请在应用内清除数据,或使用设备所有者模式。
关闭再打开 Wi-Fi
网络关闭期间,手机收不到命令。把关闭和打开放进同一个 batch,并传入 cuts_network=True:手机先回复 {"accepted": true},离线时自行执行这些步骤,重新连上后再发回结果。传入 wait=True 时,调用会等待这个结果再返回。概念一页有更详细的说明。
d.intent("android.settings.WIFI_SETTINGS")
d.wait_idle()
switch = {"class": "android.widget.Switch", "visible": True} # 页面上的第一个开关
d.batch([("touch", switch), ("sleep", 3000), ("touch", switch)], cuts_network=True, wait=True)await d.intent("android.settings.WIFI_SETTINGS");
await d.waitIdle();
const sw = { class: "android.widget.Switch", visible: true }; // 页面上的第一个开关
await d.batch([["touch", sw], ["sleep", 3000], ["touch", sw]], { cuts_network: true, wait: true });await d.IntentAsync("android.settings.WIFI_SETTINGS");
await d.WaitIdleAsync();
var sw = new { @class = "android.widget.Switch", visible = true }; // 页面上的第一个开关
await d.BatchAsync(new object[] { ("touch", sw), ("sleep", 3000), ("touch", sw) }, cutsNetwork: true, wait: true);droidline intent android.settings.WIFI_SETTINGS
droidline wait_idle
SWITCH='["touch",{"class":"android.widget.Switch","visible":true}]'
droidline batch "[$SWITCH,[\"sleep\",3000],$SWITCH]" --cuts_network --wait关闭再打开移动数据
三星手机在关闭和重新打开移动数据时都会要求确认,所以这个 batch 在每次点击开关后都会点击对话框的确认按钮。在不要求确认的手机上,去掉 ok 步骤:
d.intent("android.settings.DATA_USAGE_SETTINGS")
d.wait_idle()
data = {"class": "android.widget.Switch", "row": {"textMatches": "Mobile data|모바일 데이터|移动数据"}}
ok = ("touch", "id", "android:id/button1")
d.batch([("touch", data), ok, ("sleep", 3000), ("touch", data), ok], cuts_network=True, wait=True)await d.intent("android.settings.DATA_USAGE_SETTINGS");
await d.waitIdle();
const data = { class: "android.widget.Switch", row: { textMatches: "Mobile data|모바일 데이터|移动数据" } };
const ok = ["touch", "id", "android:id/button1"];
await d.batch([["touch", data], ok, ["sleep", 3000], ["touch", data], ok], { cuts_network: true, wait: true });await d.IntentAsync("android.settings.DATA_USAGE_SETTINGS");
await d.WaitIdleAsync();
var data = new { @class = "android.widget.Switch", row = new { textMatches = "Mobile data|모바일 데이터|移动数据" } };
var ok = ("touch", "id", "android:id/button1");
await d.BatchAsync(new object[] { ("touch", data), ok, ("sleep", 3000), ("touch", data), ok }, cutsNetwork: true, wait: true);droidline intent android.settings.DATA_USAGE_SETTINGS
droidline wait_idle
DATA='["touch",{"class":"android.widget.Switch","row":{"textMatches":"Mobile data|모바일 데이터|移动数据"}}]'
OK='["touch","id","android:id/button1"]'
droidline batch "[$DATA,$OK,[\"sleep\",3000],$DATA,$OK]" --cuts_network --wait获取新的移动 IP 地址
使用移动数据时,开关一次飞行模式通常会让运营商分配一个新地址。做法就是在飞行模式页面上套用 Wi-Fi 示例:
d.intent("android.settings.AIRPLANE_MODE_SETTINGS")
d.wait_idle()
switch = {"class": "android.widget.Switch", "visible": True} # 页面上的第一个开关
d.batch([("touch", switch), ("sleep", 3000), ("touch", switch)], cuts_network=True, wait=True)
print(d.network()) # {'type': 'mobile', 'airplane': False, 'metered': True}await d.intent("android.settings.AIRPLANE_MODE_SETTINGS");
await d.waitIdle();
const sw = { class: "android.widget.Switch", visible: true }; // 页面上的第一个开关
await d.batch([["touch", sw], ["sleep", 3000], ["touch", sw]], { cuts_network: true, wait: true });
console.log(await d.network());await d.IntentAsync("android.settings.AIRPLANE_MODE_SETTINGS");
await d.WaitIdleAsync();
var sw = new { @class = "android.widget.Switch", visible = true }; // 页面上的第一个开关
await d.BatchAsync(new object[] { ("touch", sw), ("sleep", 3000), ("touch", sw) }, cutsNetwork: true, wait: true);
Console.WriteLine(await d.NetworkAsync());droidline intent android.settings.AIRPLANE_MODE_SETTINGS
droidline wait_idle
SWITCH='["touch",{"class":"android.widget.Switch","visible":true}]'
droidline batch "[$SWITCH,[\"sleep\",3000],$SWITCH]" --cuts_network --wait如果你手机上这个页面的第一个开关不是飞行模式,就像移动数据示例那样按所在行选择开关。飞行模式关闭后,手机会自行重新连接电脑。
在每部手机上运行相同的步骤
from concurrent.futures import ThreadPoolExecutor
from droidline import Droidline
dl = Droidline()
names = [p["name"] for p in dl.devices() if p["online"]]
def job(name):
d = dl.device(name)
d.launch("com.android.chrome")
return name, d.current()["package"]
with ThreadPoolExecutor(len(names) or 1) as pool:
print(list(pool.map(job, names)))import { Droidline } from "droidline";
const dl = new Droidline();
const online = (await dl.devices()).filter((p) => p.online);
console.log(await Promise.all(online.map(async (p) => {
const d = dl.device(p.name);
await d.launch("com.android.chrome");
return [p.name, (await d.current()).package];
})));using Droidline;
using var client = new DroidlineClient();
var online = (await client.DevicesAsync()).Where(p => p.Get<bool>("online"));
var results = await Task.WhenAll(online.Select(async p =>
{
var d = client.Device(p.Get<string>("name"));
await d.LaunchAsync("com.android.chrome");
return (p.Get<string>("name"), (await d.CurrentAsync()).Package);
}));
Console.WriteLine(string.Join(", ", results));for name in $(droidline --json devices | jq -r '.value[] | select(.online) | .name'); do
droidline -d "$name" launch com.android.chrome &
done
wait多部手机一页介绍了更多内容:命名、为每部手机设置代理,以及让一整架手机保持正常运行。