yingyongbao_auto/data/logs/probe_a11y.js
2026-10-17 10:46:29 +08:00

44 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 诊断:无障碍服务能否提供前台应用(getWindows / rootInActiveWindow 的包名)。
function dumpWindows(tag) {
try {
var svc = auto.service;
if (!svc) {
console.log("[probe_a11y] " + tag + " 无 auto.service");
return;
}
var ws = svc.getWindows();
var n = ws ? ws.size() : 0;
console.log("[probe_a11y] " + tag + " windows=" + n);
for (var i = 0; i < n && i < 12; i++) {
var w = ws.get(i);
console.log("[probe_a11y] " + tag + " win" + i +
" pkg=" + w.getPackageName() +
" active=" + w.isActive() +
" focused=" + w.isFocused() +
" layer=" + w.getLayer() +
" type=" + w.getType());
}
} catch (e) {
console.log("[probe_a11y] " + tag + " windows err=" + e);
}
try {
var root = auto.rootInActiveWindow;
console.log("[probe_a11y] " + tag + " rootInActiveWindow=" + root +
(root ? " pkg=" + root.getPackageName() + " cls=" + root.getClassName() : ""));
} catch (e) {
console.log("[probe_a11y] " + tag + " root err=" + e);
}
}
console.log("[probe_a11y] start");
dumpWindows("AutoJS前台");
try {
app.launchPackage("com.tencent.android.qqdownloader");
console.log("[probe_a11y] 已请求启动应用宝");
} catch (e) {
console.log("[probe_a11y] launch err=" + e);
}
sleep(8000);
dumpWindows("应用宝前台");
console.log("[probe_a11y] done");