@buaa_smat/hometrans 26.0.0 → 26.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/package.json +11 -82
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +1 -1
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
- package/skills/a2h-batch-ui-align/references/step3-capture.md +3 -3
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +1 -1
- package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +11 -6
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +59 -21
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -3
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +1 -1
- package/skills/a2h-utg-explorer/SKILL.md +1 -1
- package/skills/a2h-utg-explorer/references/architecture.md +2 -2
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +36 -11
- package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +64 -8
- package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
- package/skills/a2h-utg-explorer/scripts/recover_b.mjs +8 -1
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +89 -7
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +173 -4
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +82 -14
- package/skills/a2h-utg-static/SKILL.md +1 -1
- package/skills/a2h-utg-static/references/view-interactions.md +1 -1
- package/skills/a2h-utg-static/scripts/assemble.mjs +6 -3
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
- package/skills/a2h-utg-static/scripts/static_prior.mjs +2 -1
- package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
- package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
- package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
- package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
- package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
- package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
- package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
- package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
- package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
- package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
- package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
- package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
- package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +83 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
- package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
- package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
- package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
- package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
- package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
- package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
- package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
- package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
- package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
- package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
- package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
- package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
- package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
- package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
|
@@ -197,6 +197,11 @@ const ALLOWED = new Set(['resource_id', 'resource_name', 'text', 'content_desc',
|
|
|
197
197
|
'focused', 'actionable', 'within', 'index']);
|
|
198
198
|
const bkey = (n) => { const b = or(get(n, 'bounds'), [0, 0]); return b.length >= 2 ? [b[1], b[0]] : b.slice(0, 2).reverse(); };
|
|
199
199
|
|
|
200
|
+
/** True for the "type into whatever holds focus" selector `{focused: true}`. */
|
|
201
|
+
export function isFocusOnly(selector) {
|
|
202
|
+
return isDict(selector) && Object.keys(selector).length === 1 && selector.focused === true;
|
|
203
|
+
}
|
|
204
|
+
|
|
200
205
|
/** matching(nodes, selector): visible, enabled nodes matching every field (within/index scopes). */
|
|
201
206
|
export function matching(nodes, selector) {
|
|
202
207
|
if (!truthy(selector) || !isDict(selector)) { throw new AdapterError('A nonempty exact selector is required'); }
|
|
@@ -614,6 +619,17 @@ export function secureFocus(dump) {
|
|
|
614
619
|
return false;
|
|
615
620
|
}
|
|
616
621
|
|
|
622
|
+
/**
|
|
623
|
+
* True when the default display's focused window is the system input-method picker. A device whose
|
|
624
|
+
* only enabled IME cannot serve the focused field (measured, coolmall login on an emulator with only
|
|
625
|
+
* Google voice input: tapping a password TextField focused `Window{... IME Switcher Menu}`) shows it
|
|
626
|
+
* over the app; the dump then holds systemui's picker alone and every app selector matches 0.
|
|
627
|
+
*/
|
|
628
|
+
export function imeSwitcherFocus(dump) {
|
|
629
|
+
const m = /mCurrentFocus=Window\{\w+ (?:u\d+ )?([^}\n]*)\}/.exec(defaultDisplay(liveWindowDump(dump)));
|
|
630
|
+
return !!m && /^(?:IME Switcher Menu|Select input method|Choose input method)$/i.test(m[1].trim());
|
|
631
|
+
}
|
|
632
|
+
|
|
617
633
|
/**
|
|
618
634
|
* The all-windows hierarchy `xml` cut to its first (topmost) window root owned by `pkg`, or null.
|
|
619
635
|
* Root order is the server's window order, topmost first.
|
|
@@ -758,6 +774,47 @@ export class DeviceAdapter {
|
|
|
758
774
|
return binary ? proc.stdout : decodeReplace(proc.stdout);
|
|
759
775
|
}
|
|
760
776
|
|
|
777
|
+
/** True when the soft keyboard is shown, i.e. some view holds input focus (dumpsys input_method). */
|
|
778
|
+
_imeShown() {
|
|
779
|
+
let out;
|
|
780
|
+
try { out = pyStr(this._shell('dumpsys', 'input_method')); } catch (e) { if (e instanceof AdapterError) { return false; } throw e; }
|
|
781
|
+
return /\bmInputShown=true\b|\bisInputViewShown=true\b|\bmIsInputViewShown=true\b/.test(out);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Give the field at (x, y) input focus, proven: a shown keyboard says some view has focus, not
|
|
786
|
+
* which, and `input text` types into that view (a password into a focused username field). So
|
|
787
|
+
* the keyboard is hidden first (Back closes only the IME) and the tap must bring it back.
|
|
788
|
+
* The keyboard's show/hide animation and `dumpsys input_method` lag behind the key, so each
|
|
789
|
+
* state is polled for up to `ime_wait_seconds` (default 2) rather than read once.
|
|
790
|
+
*/
|
|
791
|
+
_focusByTap(x, y) {
|
|
792
|
+
const step = Math.max(0.05, toFloat(get(this.config, 'settle_seconds', 0.3)));
|
|
793
|
+
const wait = Math.max(step, toFloat(get(this.config, 'ime_wait_seconds', 2)));
|
|
794
|
+
const until = (shown) => {
|
|
795
|
+
for (let t = 0; ; t += step) {
|
|
796
|
+
time.sleep(step);
|
|
797
|
+
if (this._imeShown() === shown) { return true; }
|
|
798
|
+
if (t + step >= wait) { return false; }
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
if (this._imeShown()) {
|
|
802
|
+
this._shell('input', 'keyevent', 'KEYCODE_BACK');
|
|
803
|
+
if (!until(false)) { throw new AdapterError('Focus input explicitly and re-observe before typing'); }
|
|
804
|
+
}
|
|
805
|
+
this._shell('input', 'tap', x, y);
|
|
806
|
+
if (!until(true)) { throw new AdapterError('Focus input explicitly and re-observe before typing'); }
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/** `adb shell input text` of action.value / action.value_env (ASCII only). */
|
|
810
|
+
_typeText(action) {
|
|
811
|
+
const text = Object.hasOwn(action, 'value_env') ? (process.env[action.value_env] ?? null) : get(action, 'value');
|
|
812
|
+
if (text === null || text === undefined || !reFullmatch(pyRe('[\\x20-\\x7e]*'), pyStr(text))) {
|
|
813
|
+
throw new AdapterError('ADB text input supports ASCII here; use an IME adapter for other text');
|
|
814
|
+
}
|
|
815
|
+
this._shell('input', 'text', pyStr(text).replaceAll(' ', '%s'));
|
|
816
|
+
}
|
|
817
|
+
|
|
761
818
|
/** _shell(*args): POSIX-quoted remote command, persistent shell when configured. */
|
|
762
819
|
_shell(...args) {
|
|
763
820
|
const command = args.map((a) => shlexQuote(pyStr(a))).join(' ');
|
|
@@ -999,7 +1056,22 @@ export class DeviceAdapter {
|
|
|
999
1056
|
observe(environmentId) {
|
|
1000
1057
|
const capture = pJoin(this.artifact_dir, uuid4Hex());
|
|
1001
1058
|
pMkdir(capture);
|
|
1002
|
-
|
|
1059
|
+
let [component, focus] = this._foreground();
|
|
1060
|
+
// Back closes the picker only; the field keeps focus, so a following `input` still types into it.
|
|
1061
|
+
// The picker is re-checked right before Back (one that closed by itself would let Back reach the
|
|
1062
|
+
// app), and the app's activity is compared after it: the observation records what happened
|
|
1063
|
+
// (`ime_switcher_dismissed`: 'closed', or 'navigated' when the app moved), and the runner logs it.
|
|
1064
|
+
let imeSwitcherDismissed = null;
|
|
1065
|
+
if (imeSwitcherFocus(focus)) {
|
|
1066
|
+
[component, focus] = this._foreground();
|
|
1067
|
+
if (imeSwitcherFocus(focus)) {
|
|
1068
|
+
const under = component;
|
|
1069
|
+
this._shell('input', 'keyevent', 'KEYCODE_BACK');
|
|
1070
|
+
time.sleep(Math.max(0.0, toFloat(get(this.config, 'settle_seconds', 0.3))) + 0.5);
|
|
1071
|
+
[component, focus] = this._foreground();
|
|
1072
|
+
imeSwitcherDismissed = component === under ? 'closed' : 'navigated';
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1003
1075
|
const slash = component.indexOf('/');
|
|
1004
1076
|
const pkg = component.slice(0, slash);
|
|
1005
1077
|
let activity = component.slice(slash + 1);
|
|
@@ -1032,6 +1104,7 @@ export class DeviceAdapter {
|
|
|
1032
1104
|
if (bar !== null) { result.device_info.status_bar_px = bar; }
|
|
1033
1105
|
if (shown !== pkg) { result.component_package = pkg; }
|
|
1034
1106
|
if (secureFocus(focus)) { result.screen_blocked = 'flag-secure'; }
|
|
1107
|
+
if (imeSwitcherDismissed) { result.ime_switcher_dismissed = imeSwitcherDismissed; }
|
|
1035
1108
|
result.identity = resolveIdentity(result, this.config);
|
|
1036
1109
|
writeJson(pJoin(capture, 'observation.json'), result);
|
|
1037
1110
|
return result;
|
|
@@ -1044,6 +1117,9 @@ export class DeviceAdapter {
|
|
|
1044
1117
|
/** act(action, before=None): one atomic device action. */
|
|
1045
1118
|
act(action, before = null) {
|
|
1046
1119
|
const kind = get(action, 'type');
|
|
1120
|
+
// the point the action just before this one tapped, if it was a plain tap (see _focusByTap)
|
|
1121
|
+
const lastTap = this._lastTap ?? null;
|
|
1122
|
+
this._lastTap = null;
|
|
1047
1123
|
const candidateKinds = { click_candidates: 'click', long_click_candidates: 'long_click', double_tap_candidates: 'double_tap' };
|
|
1048
1124
|
if (Object.hasOwn(candidateKinds, kind)) {
|
|
1049
1125
|
const errors = [];
|
|
@@ -1061,18 +1137,23 @@ export class DeviceAdapter {
|
|
|
1061
1137
|
const hidden = occludedIndices(before.nodes);
|
|
1062
1138
|
const live = before.nodes.map((n, i) => (!hidden.has(i) ? n : { visible: false }));
|
|
1063
1139
|
const hits = matching(live, get(action, 'selector'));
|
|
1140
|
+
// Compose TextFields often never report `focused` in the dump even while they hold the IME
|
|
1141
|
+
// (measured: coolmall login, `input {focused: true}` matched 0 after the field was tapped).
|
|
1142
|
+
// Only right after a tap: the field that tap hit is focused again and proven to own the
|
|
1143
|
+
// keyboard, so a tap that missed it does not send the text to whichever field had focus.
|
|
1144
|
+
if (kind === 'input' && isFocusOnly(get(action, 'selector')) && hits.length === 0 && lastTap) {
|
|
1145
|
+
this._focusByTap(...lastTap);
|
|
1146
|
+
this._typeText(action);
|
|
1147
|
+
return null;
|
|
1148
|
+
}
|
|
1064
1149
|
if (hits.length !== 1) { throw new AdapterError(`Selector must resolve uniquely; matched ${hits.length} elements`); }
|
|
1065
1150
|
const node = hits[0];
|
|
1066
1151
|
const b = get(node, 'bounds', []);
|
|
1067
1152
|
if (b.length !== 4 || b[2] <= b[0] || b[3] <= b[1]) { throw new AdapterError('Selector has invalid or invisible bounds'); }
|
|
1068
1153
|
const [x, y] = this._center(b);
|
|
1069
1154
|
if (kind === 'input') {
|
|
1070
|
-
if (!truthy(get(node, 'focused'))) {
|
|
1071
|
-
|
|
1072
|
-
if (text === null || text === undefined || !reFullmatch(pyRe('[\\x20-\\x7e]*'), pyStr(text))) {
|
|
1073
|
-
throw new AdapterError('ADB text input supports ASCII here; use an IME adapter for other text');
|
|
1074
|
-
}
|
|
1075
|
-
this._shell('input', 'text', pyStr(text).replaceAll(' ', '%s'));
|
|
1155
|
+
if (!truthy(get(node, 'focused'))) { this._focusByTap(x, y); }
|
|
1156
|
+
this._typeText(action);
|
|
1076
1157
|
} else if (kind === 'long_click') {
|
|
1077
1158
|
this._shell('input', 'swipe', x, y, x, y, toInt(get(action, 'duration_ms', 700)));
|
|
1078
1159
|
} else if (kind === 'double_tap') {
|
|
@@ -1081,6 +1162,7 @@ export class DeviceAdapter {
|
|
|
1081
1162
|
this._shell('input', 'tap', x, y);
|
|
1082
1163
|
} else {
|
|
1083
1164
|
this._shell('input', 'tap', x, y);
|
|
1165
|
+
this._lastTap = [x, y];
|
|
1084
1166
|
}
|
|
1085
1167
|
} else if (kind === 'click_point' || kind === 'long_click_point') {
|
|
1086
1168
|
const x = toInt(mget(action, 'x')); const y = toInt(mget(action, 'y'));
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* Exports: ANDROID, normalized, buildCatalog, _selectorHits, learnedRuleMatches,
|
|
6
6
|
* occludedIndices, treePackage, resolvePage, _SCREEN_KINDS, _shareRowContainer,
|
|
7
7
|
* _hostCompatible, _toolbarTitleCandidates, _selectedTabCandidates,
|
|
8
|
-
* _ownWidgetCandidates,
|
|
8
|
+
* _ownWidgetCandidates, _overlayLeadTitleCandidates, OVERLAY_KINDS, androidUnescape, androidValue, decodeAndroidString,
|
|
9
|
+
* panelHost, observationMatchesStatic
|
|
9
10
|
*
|
|
10
11
|
* Python sets become JS Sets in insertion order. Where Python iterated a set of strings to
|
|
11
12
|
* build an ordered result (only `_toolbarTitleCandidates`, whose order Python leaves to the
|
|
@@ -41,6 +42,61 @@ export function normalized(text) {
|
|
|
41
42
|
|
|
42
43
|
const isBuildPath = (p, project) => (pRelativeParts(p, project) ?? []).includes('build');
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* aapt's backslash escapes in an (already entity-decoded) strings.xml value: `\n`, `\t`, `\'`, `\"`,
|
|
47
|
+
* `\@`, `\uXXXX`. Only `\'` was undone before, so a title such as `你好,\n欢迎注册青商城` kept a literal
|
|
48
|
+
* backslash-n and never equalled the rendered two-line text.
|
|
49
|
+
*/
|
|
50
|
+
export function androidUnescape(value) {
|
|
51
|
+
return S(value).replace(/\\(u[0-9a-fA-F]{4}|[\s\S])/g, (m, c) => {
|
|
52
|
+
if (c.length === 5) { return String.fromCharCode(parseInt(c.slice(1), 16)); }
|
|
53
|
+
return c === 'n' ? '\n' : c === 't' ? '\t' : c;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* aapt's one pass over an (already entity-decoded, markup-free) strings.xml value: an unescaped
|
|
59
|
+
* `"` toggles a quoted run and is dropped (`Tap "OK" now` shows `Tap OK now`); outside quotes
|
|
60
|
+
* whitespace runs collapse to one space and the ends are trimmed; a backslash escape is always
|
|
61
|
+
* literal (`"C:\\"` shows `C:\`). Same rule as a2h-utg-static label_resolve.aaptText (a test
|
|
62
|
+
* compares the two), so the explorer catalog and the static UTG read every value alike.
|
|
63
|
+
*/
|
|
64
|
+
export function androidValue(value) {
|
|
65
|
+
const s = S(value);
|
|
66
|
+
let out = ''; let quoted = false; let space = false;
|
|
67
|
+
for (let i = 0; i < s.length; i++) {
|
|
68
|
+
const c = s[i];
|
|
69
|
+
if (c === '\\' && i + 1 < s.length) {
|
|
70
|
+
const u = /^u([0-9a-fA-F]{4})/.exec(s.slice(i + 1, i + 6));
|
|
71
|
+
if (u) { out += String.fromCharCode(parseInt(u[1], 16)); i += 5; }
|
|
72
|
+
else { const d = s[i + 1]; out += d === 'n' ? '\n' : d === 't' ? '\t' : d; i += 1; }
|
|
73
|
+
space = false;
|
|
74
|
+
} else if (c === '"') {
|
|
75
|
+
quoted = !quoted;
|
|
76
|
+
} else if (!quoted && /\s/.test(c)) {
|
|
77
|
+
if (out && !space) { out += ' '; space = true; }
|
|
78
|
+
} else {
|
|
79
|
+
out += c; space = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return space ? out.slice(0, -1) : out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const _XML_ENTITY = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" };
|
|
86
|
+
|
|
87
|
+
/** A raw strings.xml value (CDATA, inline markup, entities) as aapt renders it. */
|
|
88
|
+
export function decodeAndroidString(raw) {
|
|
89
|
+
// one pass: CDATA content is literal text, untouched by the markup strip and entity decoding
|
|
90
|
+
const s = S(raw).replace(/<!\[CDATA\[([\s\S]*?)\]\]>|<[^>]*>|&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g, (m, cdata, e) => {
|
|
91
|
+
if (cdata !== undefined) { return cdata; }
|
|
92
|
+
if (e === undefined) { return ''; }
|
|
93
|
+
if (e[0] !== '#') { return _XML_ENTITY[e]; }
|
|
94
|
+
const cp = e[1] === 'x' ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
|
|
95
|
+
return Number.isFinite(cp) && cp >= 0 && cp <= 0x10ffff ? String.fromCodePoint(cp) : m;
|
|
96
|
+
});
|
|
97
|
+
return androidValue(s);
|
|
98
|
+
}
|
|
99
|
+
|
|
44
100
|
/** build_catalog(graph, project=None, locale='en'). */
|
|
45
101
|
const _STRING_ROW = /<string\s+name="([^"]+)"[^>]*>([\s\S]*?)<\/string>/g;
|
|
46
102
|
|
|
@@ -54,7 +110,7 @@ export function _variantOverrides(project) {
|
|
|
54
110
|
let text;
|
|
55
111
|
try { text = readText(file); } catch { continue; }
|
|
56
112
|
for (const m of text.matchAll(_STRING_ROW)) {
|
|
57
|
-
const v = m[2]
|
|
113
|
+
const v = decodeAndroidString(m[2]).trim();
|
|
58
114
|
if (!v) { continue; }
|
|
59
115
|
const tbl = set === 'main' ? main : other;
|
|
60
116
|
if (!tbl.has(m[1])) { tbl.set(m[1], new Set()); }
|
|
@@ -99,7 +155,7 @@ export function buildCatalog(graph, project = null, locale = 'en') {
|
|
|
99
155
|
try { root = etParse(file); } catch (e) { if (e instanceof XmlParseError) { continue; } throw e; }
|
|
100
156
|
for (const el of root) {
|
|
101
157
|
// a nameless <string> lands under None in Python: unreachable by any str key
|
|
102
|
-
if (el.tag === 'string' && el.get('name') !== null) { dset(strings, el.get('name'), [...el.itertext()].join('')
|
|
158
|
+
if (el.tag === 'string' && el.get('name') !== null) { dset(strings, el.get('name'), androidValue([...el.itertext()].join(''))); }
|
|
103
159
|
}
|
|
104
160
|
}
|
|
105
161
|
}
|
|
@@ -327,6 +383,29 @@ export function buildCatalog(graph, project = null, locale = 'en') {
|
|
|
327
383
|
item.shared_titles = titleShare(ident);
|
|
328
384
|
item.shared_texts = textShare(ident);
|
|
329
385
|
}
|
|
386
|
+
// Overlay titles no screen renders (as title, row, hint or own body text, before the unique-claim
|
|
387
|
+
// filter below): a sheet / dialog whose window shows such a title first is that overlay
|
|
388
|
+
// (_overlayLeadTitleCandidates). A title a screen also renders (the opener's "领取优惠券" button)
|
|
389
|
+
// is no proof of the overlay.
|
|
390
|
+
const screenTexts = new Map();
|
|
391
|
+
for (const [ident, item] of Object.entries(catalog)) {
|
|
392
|
+
if (OVERLAY_KINDS.includes(item.kind)) { continue; }
|
|
393
|
+
for (const t of [...item.titles, ...item.hint_titles, ...item.row_titles].map(normalized).concat(item.body_titles)) {
|
|
394
|
+
if (!screenTexts.has(t)) { screenTexts.set(t, new Set()); }
|
|
395
|
+
screenTexts.get(t).add(ident);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// An overlay's own body text leads its window too (ThemeModeModal: title 「夜间模式」 is a Text, its
|
|
399
|
+
// `title_any` holds the options). A lead a screen also renders -- the opener's row, coolmall
|
|
400
|
+
// Settings 「主题颜色」 / 「夜间模式」 -- goes to `lead_shared` with those screens: it names the
|
|
401
|
+
// overlay only in a dump that shows none of their other texts (the overlay's own window).
|
|
402
|
+
for (const item of Object.values(catalog)) {
|
|
403
|
+
if (!OVERLAY_KINDS.includes(item.kind)) { continue; }
|
|
404
|
+
const leads = new Set([...item.titles.map(normalized), ...item.body_titles].filter((t) => [...t].length >= 2));
|
|
405
|
+
item.lead_titles = sortedStr([...leads].filter((t) => !screenTexts.has(t)));
|
|
406
|
+
item.lead_shared = Object.fromEntries(sortedStr([...leads].filter((t) => screenTexts.has(t)))
|
|
407
|
+
.map((t) => [t, sortedStr(screenTexts.get(t))]));
|
|
408
|
+
}
|
|
330
409
|
// A body text is an anchor only for its single claimant, and never one that is some page's title.
|
|
331
410
|
const claims = new Map();
|
|
332
411
|
for (const item of Object.values(catalog)) {
|
|
@@ -348,6 +427,43 @@ export function buildCatalog(graph, project = null, locale = 'en') {
|
|
|
348
427
|
|
|
349
428
|
/** Fewest body anchors that identify a page: two, or one of at least this many characters. */
|
|
350
429
|
export const BODY_ANCHOR_MIN_CHARS = 4;
|
|
430
|
+
/** Shared source texts of the same page that must be on screen to back one short own text. */
|
|
431
|
+
export const BODY_CORROBORATION = 2;
|
|
432
|
+
|
|
433
|
+
/** Catalog kinds shown in a window of their own over a page. */
|
|
434
|
+
export const OVERLAY_KINDS = ['dialog', 'sheet', 'menu'];
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Overlays whose catalog `lead_titles` holds the dump's first visible text. A Compose bottom sheet
|
|
438
|
+
* (ModalBottomSheet) or dialog is its own window: the dump is the overlay alone, title first, and has
|
|
439
|
+
* no `alertTitle` / `dialog_title` id for the modal branch to read. Measured (coolmall): the goods
|
|
440
|
+
* page's coupon sheet showed "领取优惠券" first, matched no rule, and its 5 captures stayed unmapped.
|
|
441
|
+
* Only the FIRST text counts: an option row (ThemeModeModal's "深色模式") a settings page may also
|
|
442
|
+
* show as its current value is never the lead.
|
|
443
|
+
*/
|
|
444
|
+
export function _overlayLeadTitleCandidates(nodes, catalog, observation) {
|
|
445
|
+
const first = nodes.find((n) => vis(n) && truthy(g(n, 'text')) && !isInputNode(n));
|
|
446
|
+
if (!first) { return []; }
|
|
447
|
+
const lead = normalized(g(first, 'text'));
|
|
448
|
+
const shown = new Set(nodes.filter((n) => vis(n)).flatMap((n) => [g(n, 'text'), g(n, 'content_desc')])
|
|
449
|
+
.filter((t) => truthy(t)).map(normalized));
|
|
450
|
+
const screenShown = (sid) => {
|
|
451
|
+
const p = g(catalog, sid, {});
|
|
452
|
+
return [...g(p, 'titles', []), ...g(p, 'hint_titles', []), ...g(p, 'row_titles', [])].map(normalized)
|
|
453
|
+
.concat(g(p, 'body_titles', [])).some((t) => t !== lead && shown.has(t));
|
|
454
|
+
};
|
|
455
|
+
const out = [];
|
|
456
|
+
for (const [ident, page] of Object.entries(catalog)) {
|
|
457
|
+
if (!OVERLAY_KINDS.includes(g(page, 'kind'))) { continue; }
|
|
458
|
+
const owners = g(g(page, 'lead_shared', {}) ?? {}, lead);
|
|
459
|
+
const own = (g(page, 'lead_titles', []) || []).includes(lead);
|
|
460
|
+
if (!own && !(Array.isArray(owners) && owners.length && !owners.some(screenShown))) { continue; }
|
|
461
|
+
if (_hostCompatible(page, catalog, observation)) {
|
|
462
|
+
out.push({ static_id: ident, reason: own ? 'overlay-lead-title' : 'overlay-lead-title-alone', anchors: [lead] });
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return out;
|
|
466
|
+
}
|
|
351
467
|
|
|
352
468
|
/**
|
|
353
469
|
* _body_text_candidates(nodes, catalog, observation): pages whose own fixed source texts are on
|
|
@@ -367,7 +483,17 @@ export function _bodyTextCandidates(nodes, catalog, observation) {
|
|
|
367
483
|
if (!hits.length) { continue; }
|
|
368
484
|
if (!_hostCompatible(page, catalog, observation)) { continue; }
|
|
369
485
|
if (hits.length < 2 && !hits.some((t) => [...t.replace(/…$/, '')].length >= BODY_ANCHOR_MIN_CHARS)) {
|
|
370
|
-
|
|
486
|
+
// A short own text (the splash's 3-character app name "青商城") still identifies the page when
|
|
487
|
+
// BODY_CORROBORATION of the page's own source texts that other pages also render are on screen
|
|
488
|
+
// with it (its "Logo" and copyright line, shared with About). Alone it stays weak: an empty
|
|
489
|
+
// cart shows "购物车", the goods page's short own text, and nothing else of that page.
|
|
490
|
+
const backing = (g(page, 'shared_texts', []) || []).filter((t) => shown.has(normalized(t)));
|
|
491
|
+
if (backing.length < BODY_CORROBORATION) {
|
|
492
|
+
weak.push({ static_id: ident, reason: 'weak-body-text', anchors: sortedStr(hits) });
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
// ranked by its own texts only: the shared backing must not outrank a page with two own texts
|
|
496
|
+
scored.push([hits.length, ident, sortedStr([...hits, ...backing.map(normalized)])]);
|
|
371
497
|
continue;
|
|
372
498
|
}
|
|
373
499
|
scored.push([hits.length, ident, sortedStr(hits)]);
|
|
@@ -607,8 +733,10 @@ export function resolvePage(observation, catalog, configuredIdentity = null, opt
|
|
|
607
733
|
}
|
|
608
734
|
}
|
|
609
735
|
if (!candidates.length) { candidates = _selectedTabCandidates(nodes, catalog, observation); }
|
|
736
|
+
if (!candidates.length) { candidates = _tabTitleCandidates(nodes, catalog, observation); }
|
|
610
737
|
if (!candidates.length) { candidates = _toolbarTitleCandidates(nodes, catalog, observation); }
|
|
611
738
|
if (!candidates.length) { candidates = _ownWidgetCandidates(nodes, catalog, observation); }
|
|
739
|
+
if (!candidates.length) { candidates = _overlayLeadTitleCandidates(nodes, catalog, observation); }
|
|
612
740
|
if (!candidates.length) {
|
|
613
741
|
candidates = _bodyTextCandidates(nodes, catalog, observation);
|
|
614
742
|
if (candidates.length === 1 && candidates[0].weak) {
|
|
@@ -871,6 +999,47 @@ export function _selectedTabCandidates(nodes, catalog, observation) {
|
|
|
871
999
|
return [{ static_id: hits[0], reason: 'selected-tab', anchors: [cap] }];
|
|
872
1000
|
}
|
|
873
1001
|
|
|
1002
|
+
/** Fewest labels a bottom row needs to be a tab bar. */
|
|
1003
|
+
export const TAB_BAR_MIN_LABELS = 3;
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* A top-level tab page of a Compose pager: a centered top-bar title (no back icon, so not a bar
|
|
1007
|
+
* title by _composeTopBarTitle) that is also one label of the bottom tab row. A Compose
|
|
1008
|
+
* NavigationBar reports no `selected`, so the bar title is what names the current tab. Measured
|
|
1009
|
+
* (coolmall 2026-11-08): 「分类」 / 「购物车」 tabs captured with only server data on screen stayed
|
|
1010
|
+
* unmapped. Among the pages titled that way, pager pages win: the standalone route sharing the
|
|
1011
|
+
* title (compose-route:Cart, with a back icon) does not show the tab row.
|
|
1012
|
+
*/
|
|
1013
|
+
export function _tabTitleCandidates(nodes, catalog, observation) {
|
|
1014
|
+
const [width, height] = _extent(nodes);
|
|
1015
|
+
if (!(width > 0 && height > 0)) { return []; }
|
|
1016
|
+
const free = (n) => {
|
|
1017
|
+
let idx = parentOf(n);
|
|
1018
|
+
for (let k = 0; k < 8 && inRange(idx, nodes); k++) { if (truthy(g(nodes[idx], 'scrollable'))) { return false; } idx = parentOf(nodes[idx]); }
|
|
1019
|
+
return true;
|
|
1020
|
+
};
|
|
1021
|
+
const texts = nodes.filter((n) => vis(n) && truthy(g(n, 'text')) && bnds(n).length === 4);
|
|
1022
|
+
// The tab row sits outside the pager; the title is the page's own, inside the (scrollable) pager.
|
|
1023
|
+
const bottom = texts.filter((n) => bnds(n)[1] >= (1 - TOP_BAR_BAND) * height && free(n));
|
|
1024
|
+
const mid = (n) => (bnds(n)[1] + bnds(n)[3]) / 2;
|
|
1025
|
+
const tabs = new Set();
|
|
1026
|
+
for (const n of bottom) {
|
|
1027
|
+
const row = bottom.filter((c) => Math.abs(mid(c) - mid(n)) <= 0.01 * height);
|
|
1028
|
+
if (row.length >= TAB_BAR_MIN_LABELS) { row.forEach((c) => tabs.add(normalized(c.text))); }
|
|
1029
|
+
}
|
|
1030
|
+
if (!tabs.size) { return []; }
|
|
1031
|
+
const titles = new Set(texts.filter((n) => bnds(n)[3] <= TOP_BAR_BAND * height
|
|
1032
|
+
&& Math.abs((bnds(n)[0] + bnds(n)[2]) / 2 - width / 2) <= CENTERED_TITLE_TOLERANCE * width)
|
|
1033
|
+
.map((n) => normalized(n.text)).filter((t) => tabs.has(t)));
|
|
1034
|
+
if (titles.size !== 1) { return []; }
|
|
1035
|
+
const title = [...titles][0];
|
|
1036
|
+
const hits = Object.keys(catalog).filter((ident) => g(catalog[ident], 'kind') === 'pager-page'
|
|
1037
|
+
&& [...g(catalog[ident], 'titles', []), ...g(catalog[ident], 'hint_titles', []), g(catalog[ident], 'tab_label')]
|
|
1038
|
+
.some((t) => truthy(t) && normalized(t) === title)
|
|
1039
|
+
&& _hostCompatible(catalog[ident], catalog, observation));
|
|
1040
|
+
return hits.length === 1 ? [{ static_id: hits[0], reason: 'tab-bar-title', anchors: [title] }] : [];
|
|
1041
|
+
}
|
|
1042
|
+
|
|
874
1043
|
const setKey = (xs) => JSON.stringify(sortedStr(new Set(xs)));
|
|
875
1044
|
|
|
876
1045
|
/** _own_widget_candidates(nodes, catalog, observation): identify a page by ids only its layout declares. */
|
|
@@ -385,6 +385,12 @@ export function prefixKey(task, n) {
|
|
|
385
385
|
{ sort_keys: true }), 'utf8')).slice(0, 16);
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
/** The page a launch landed on, for the prefix memo: its static id (page:…), else its activity. */
|
|
389
|
+
export function landingOf(observation) {
|
|
390
|
+
const res = or(get(observation, 'static_resolution'), {});
|
|
391
|
+
return get(res, 'status') === 'verified' ? res.static_id : `activity:${get(observation, 'activity') ?? ''}`;
|
|
392
|
+
}
|
|
393
|
+
|
|
388
394
|
/** Raised instead of replaying a prefix that already failed this run. */
|
|
389
395
|
export class PrefixFailed extends AdapterError {
|
|
390
396
|
constructor(memo, key) {
|
|
@@ -542,6 +548,12 @@ export class Runner {
|
|
|
542
548
|
*/
|
|
543
549
|
capture({ acceptLoading = false } = {}) {
|
|
544
550
|
const observation = this.device.observe(this.env);
|
|
551
|
+
// The adapter pressed Back to close an input-method picker before this capture: a device
|
|
552
|
+
// action the transition chain must show (a 'navigated' one also moved the app).
|
|
553
|
+
if (get(observation, 'ime_switcher_dismissed')) {
|
|
554
|
+
this.emit('ime_switcher_dismissed', { observation_id: get(observation, 'observation_id'),
|
|
555
|
+
outcome: observation.ime_switcher_dismissed, action: { type: 'back', automatic: true } });
|
|
556
|
+
}
|
|
545
557
|
const resolution = resolveTwinByOpener(
|
|
546
558
|
deps.resolvePage(observation, this.catalog, get(observation, 'identity'), { app_package: get(this.config, 'package') }),
|
|
547
559
|
this.current, this.catalog);
|
|
@@ -1321,21 +1333,49 @@ export class Runner {
|
|
|
1321
1333
|
let launch = { ...(or(get(task, 'source_launch'), {})) };
|
|
1322
1334
|
if (!truthy(launch)) { launch = { type: 'launch', component: mget(this.config, 'launch_component'), restart: true }; }
|
|
1323
1335
|
// A prefix that already failed this run fails the same way again: report it without replaying.
|
|
1336
|
+
// Only from the same landing: a first-run page (Guide) comes and goes with app data, and a prefix
|
|
1337
|
+
// that failed past it (Home, 「跳过」 gone) replays fine on a fresh install, and the reverse
|
|
1338
|
+
// (measured, coolmall 2026-11-08: a failure on Home cut 23 tasks that a cleared start would run).
|
|
1339
|
+
// A failure is keyed by the start (`fresh`: data cleared for this task, else `warm`) and the
|
|
1340
|
+
// landing: the page the launch settles on past its own splash, before launchBridge walks a Guide
|
|
1341
|
+
// on to Main (that would make a fresh and a warm start look the same).
|
|
1342
|
+
// The check runs before the clear and launch (each costs actions) when the landing is
|
|
1343
|
+
// predictable: a fresh start always lands the same; a warm one keeps landing where the last warm
|
|
1344
|
+
// one did once that is a page of the launch chain, or (no chain) the last two warm starts agreed.
|
|
1345
|
+
// A first-run page off the chain gives way once its flag is stored, so it is checked after launch.
|
|
1324
1346
|
const memo = truthy(get(this.config, 'prefix_memo', true)) ? (this._prefixFailures ??= new Map()) : null;
|
|
1325
1347
|
const replay = mget(task, 'replay');
|
|
1326
|
-
|
|
1348
|
+
const start = this.resetsBetweenTasks() && this._clearedFor !== task.task_id ? 'fresh' : 'warm';
|
|
1349
|
+
const memoHit = (landing) => {
|
|
1350
|
+
if (!memo || landing === undefined) { return; }
|
|
1327
1351
|
for (let n = 1; n <= replay.length; n++) {
|
|
1328
1352
|
const k = prefixKey(task, n);
|
|
1329
|
-
|
|
1353
|
+
const e = memo.get(k);
|
|
1354
|
+
if (e && e.start === start && e.landing === landing) { throw new PrefixFailed(e, k); }
|
|
1330
1355
|
}
|
|
1331
|
-
}
|
|
1356
|
+
};
|
|
1357
|
+
const last = (this._lastLanding ??= {})[start];
|
|
1358
|
+
const chain = or(get(task, 'launch_chain'), []);
|
|
1359
|
+
if (last && (start === 'fresh' || (chain.length ? chain.includes(last.landing) : last.repeated))) { memoHit(last.landing); }
|
|
1332
1360
|
this.resetBetweenTasks(task.task_id);
|
|
1333
1361
|
this.atom(launch, task.task_id, 'recover');
|
|
1334
|
-
this.
|
|
1362
|
+
this.waitLaunchPage(task);
|
|
1363
|
+
this._landing = landingOf(this.current);
|
|
1364
|
+
this._start = start;
|
|
1365
|
+
this._lastLanding[start] = { landing: this._landing, repeated: last?.landing === this._landing };
|
|
1366
|
+
memoHit(this._landing);
|
|
1367
|
+
this.launchBridge(task, { waited: true });
|
|
1335
1368
|
const attested = new Set();
|
|
1369
|
+
let passedSoFar = 0;
|
|
1336
1370
|
for (let i = 0; i < replay.length; i++) {
|
|
1337
1371
|
const step = replay[i];
|
|
1338
1372
|
const stepStart = get(or(this.current, {}), 'observation_id');
|
|
1373
|
+
// only the leading hops: no replay gesture has run since the launch
|
|
1374
|
+
if (passedSoFar === i && this.replayStepPassed(step)) {
|
|
1375
|
+
passedSoFar += 1;
|
|
1376
|
+
this.emit('replay_step_passed', { task_id: task.task_id, replay_index: i, target_id: step.target_id, observation_id: stepStart });
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1339
1379
|
try {
|
|
1340
1380
|
const stepResult = this.seek(step, task.task_id, 'replay');
|
|
1341
1381
|
if (truthy(get(step, 'intermediate')) || !truthy(get(step, 'target_id'))) { continue; }
|
|
@@ -1348,7 +1388,7 @@ export class Runner {
|
|
|
1348
1388
|
} catch (e) {
|
|
1349
1389
|
const msg = errStr(e);
|
|
1350
1390
|
if (memo && e instanceof AdapterError && PREFIX_FAILURES.some((r) => msg.startsWith(r))) {
|
|
1351
|
-
memo.set(prefixKey(task, i + 1), { reason: msg, task_id: task.task_id, replay_index: i,
|
|
1391
|
+
memo.set(prefixKey(task, i + 1), { reason: msg, task_id: task.task_id, replay_index: i, start: this._start, landing: this._landing,
|
|
1352
1392
|
observation_id: get(or(this.current, {}), 'observation_id'), before_id: stepStart });
|
|
1353
1393
|
}
|
|
1354
1394
|
throw e;
|
|
@@ -1368,6 +1408,38 @@ export class Runner {
|
|
|
1368
1408
|
}
|
|
1369
1409
|
}
|
|
1370
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* A replay tap whose target page is already on screen and whose control is not: a first-run hop
|
|
1413
|
+
* the path carries as a gesture (coolmall Guide 「跳过」 → Main) is shown only until it stores its
|
|
1414
|
+
* flag, so a relaunch without a data clear lands past it. Measured (coolmall 2026-11-08): a sweep
|
|
1415
|
+
* relaunch stood on Home, 「跳过」 was searched for by scrolling Home, and the prefix memo failed
|
|
1416
|
+
* 23 of 40 p0-fresh tasks with it. A control still visible is tapped as before.
|
|
1417
|
+
* Not a control of the target page itself (its own label in the catalog): there an absent control
|
|
1418
|
+
* is below the fold, behind a reveal or still loading, and the gesture is still owed. The caller
|
|
1419
|
+
* offers only the leading hops, before any replay gesture ran.
|
|
1420
|
+
*/
|
|
1421
|
+
replayStepPassed(step) {
|
|
1422
|
+
if (!Object.hasOwn(CANDIDATE_KINDS, get(step, 'type')) && !['click', 'long_click'].includes(get(step, 'type'))) { return false; }
|
|
1423
|
+
if (truthy(get(step, 'intermediate')) || !truthy(get(step, 'target_id')) || !this.at(step.target_id)) { return false; }
|
|
1424
|
+
const labels = [get(step, 'static_label'), ...or(get(step, 'static_label_alt'), [])].filter(truthy).map((l) => pyStr(l).trim());
|
|
1425
|
+
const own = Object.values(or(get(this.catalog, step.target_id), {})).flatMap((v) => (Array.isArray(v) ? v : [v]))
|
|
1426
|
+
.filter((v) => typeof v === 'string').map((v) => v.trim());
|
|
1427
|
+
if (labels.some((l) => own.includes(l))) { return false; }
|
|
1428
|
+
try { return !this.choose(step); } catch (e) { if (e instanceof AdapterError) { return false; } throw e; }
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* A launch still standing on its own page (`launch_page`, a Splash whose timer outlasts the
|
|
1433
|
+
* settle) is watched for up to `launch_chain_wait_seconds` (default 6) until it leaves it.
|
|
1434
|
+
*/
|
|
1435
|
+
waitLaunchPage(task) {
|
|
1436
|
+
const chain = or(get(task, 'launch_chain'), []);
|
|
1437
|
+
const first = get(task, 'launch_page');
|
|
1438
|
+
if (!chain.length || !truthy(first) || chain.includes(first)) { return; }
|
|
1439
|
+
const deadline = monotonic() + Math.max(0, toFloat(get(this.config, 'launch_chain_wait_seconds', 6)));
|
|
1440
|
+
while (this.at(first) && !chain.some((p) => this.at(p)) && monotonic() < deadline) { sleep(0.5); this.capture(); }
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1371
1443
|
/**
|
|
1372
1444
|
* The launch reached another page (a first-run Guide) instead of the ones it opens by itself
|
|
1373
1445
|
* (`launch_chain`, Splash → Main): take that page's compiled exit into the chain. This runs on
|
|
@@ -1375,18 +1447,14 @@ export class Runner {
|
|
|
1375
1447
|
* launches stop landing there and the bridge stops firing.
|
|
1376
1448
|
* Measured (coolmall 2026-10-29): without it every cold launch stayed on Guide, every task
|
|
1377
1449
|
* behind Main failed source-unverified, and Guide was the only page captured.
|
|
1378
|
-
* A launch still
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1450
|
+
* A launch still on its own page is waited out first (waitLaunchPage): deciding on Splash would
|
|
1451
|
+
* miss the Guide that comes after it. `waited`: the caller already waited (source() does, to take
|
|
1452
|
+
* the landing), so a splash that outlasts the wait is not waited on twice.
|
|
1381
1453
|
*/
|
|
1382
|
-
launchBridge(task) {
|
|
1454
|
+
launchBridge(task, { waited = false } = {}) {
|
|
1383
1455
|
const chain = or(get(task, 'launch_chain'), []);
|
|
1384
1456
|
if (!chain.length) { return; }
|
|
1385
|
-
|
|
1386
|
-
if (truthy(first) && !chain.includes(first)) {
|
|
1387
|
-
const deadline = monotonic() + Math.max(0, toFloat(get(this.config, 'launch_chain_wait_seconds', 6)));
|
|
1388
|
-
while (this.at(first) && !chain.some((p) => this.at(p)) && monotonic() < deadline) { sleep(0.5); this.capture(); }
|
|
1389
|
-
}
|
|
1457
|
+
if (!waited) { this.waitLaunchPage(task); }
|
|
1390
1458
|
if (get(this.current, 'package') !== get(this.config, 'package') || chain.some((p) => this.at(p))) { return; }
|
|
1391
1459
|
const exit = get(this.doc, 'tasks', []).find((t) => get(t, 'status') === 'compiled' && chain.includes(get(t, 'target_static'))
|
|
1392
1460
|
&& !chain.includes(get(t, 'source_static')) && !truthy(get(t, 'replay')) && !truthy(get(get(t, 'action'), 'automatic'))
|
|
@@ -251,7 +251,7 @@ node scripts/nl_hints.mjs extract <ws> <project> # → nl_hints_worklist.json
|
|
|
251
251
|
# Agent fills each item with `nl_hint`, `action_override`, evidence; saves as nl_hints_answers.json
|
|
252
252
|
node scripts/nl_hints.mjs apply <ws> # → merges into click_paths.json
|
|
253
253
|
```
|
|
254
|
-
Evidence mandatory: `file:line` where claim was read. Write hints in app's own UI language (measured from graph text).
|
|
254
|
+
Evidence mandatory: `file:line` where claim was read. Write hints in app's own UI language (measured from graph text). Before returning, run `node <a2h-utg-explorer>/scripts/hint_check.mjs --project <project> <answers file>` and fix every line: a quoted target must be the literal on-screen text (a string-resource value or code string literal, never a KDoc/comment description), and a target shown only on a later pager position (引导页最后一页的「开始体验」) needs a first-position alternative, 点击「开始体验」(或点击「跳过」).
|
|
255
255
|
|
|
256
256
|
Items keyed `edge|<source>|<target>|<trigger>` (`reasons: ["off-path"]`) are label-less edges no click path ends with: the gesture is performed on `parent_id`, not on the target's path. Typical case: a first-run page whose only way out is a button (Guide → Main, while Splash → Main is automatic). `apply` writes them to `click_paths.json` `edge_hints`, which `a2h-utg-explorer` compile_tasks reads. Without an answer the edge compiles to `needs_external`, and when it is the only exit from a page a cold launch lands on, every task behind it fails `source-unverified`. A `not_clickable` answer (with evidence) is kept in `edge_hints` too, not in `nl_hints_vetoes.json` (that file is keyed `label|target`); the edge then compiles with issue `edge-not-clickable`.
|
|
257
257
|
|
|
@@ -188,7 +188,7 @@ reviewed panel source`). Pair it with the `open` above:
|
|
|
188
188
|
clause names its target as quoted on-screen text (「设置」, “Settings”), as
|
|
189
189
|
`〔id:<resource_name>〕`, or as an any-row phrase (任意一个…条目 / the first row);
|
|
190
190
|
explanation goes in parentheses. Run `node <a2h-utg-explorer>/scripts/hint_check.mjs
|
|
191
|
-
<answers file>` before returning and fix every line it prints. Instructions
|
|
191
|
+
--project <Android source root> <answers file>` before returning and fix every line it prints. Instructions
|
|
192
192
|
describe the actual gesture in the app's UI language; the quoted target is the
|
|
193
193
|
locator the explorer taps, so quote what is on screen. New surface labels are
|
|
194
194
|
also descriptive, not asserted screen text. `observable` must distinguish arrival
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
pyStrSetOrder, pySetIter, deepCopy, isFloat, PyFloat, asFloat, floatRepr, time, IS_WIN, SP, W, WC, osRelpath,
|
|
40
40
|
} from './_py.mjs';
|
|
41
41
|
import { readTextSmart } from './io_utils.mjs';
|
|
42
|
-
import { loadProjectStrings, pageOwnTitle } from './label_resolve.mjs';
|
|
42
|
+
import { decodeAndroidString, loadProjectStrings, pageOwnTitle } from './label_resolve.mjs';
|
|
43
43
|
import { allLayoutNames, declaresOwnLayout, _osWalk } from './layout_resolve.mjs';
|
|
44
44
|
import { fnRanges } from './scope_utils.mjs';
|
|
45
45
|
import { isDefensive } from './guard_subjects.mjs';
|
|
@@ -1759,7 +1759,7 @@ export function _loadBaseStrings(project) {
|
|
|
1759
1759
|
if (norm.split('/').at(-1) !== 'values' || !(norm + '/').includes('/res/')) { continue; }
|
|
1760
1760
|
let t;
|
|
1761
1761
|
try { t = readTextSmart(osJoin(dirpath, 'strings.xml')); } catch { continue; }
|
|
1762
|
-
for (const [k, v] of reFindall(strRe, t)) { setdefault(merged, k, squash(v)); }
|
|
1762
|
+
for (const [k, v] of reFindall(strRe, t)) { setdefault(merged, k, squash(decodeAndroidString(v))); }
|
|
1763
1763
|
}
|
|
1764
1764
|
return merged;
|
|
1765
1765
|
}
|
|
@@ -2060,8 +2060,11 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
2060
2060
|
const doc = { directed: true, multigraph: true, nodes: nodeList, links: edges };
|
|
2061
2061
|
writeText(osJoin(ws, 'utg.json'), jsonDumps(doc, { ensure_ascii: false, indent: 2 }));
|
|
2062
2062
|
|
|
2063
|
+
// Labels come from decoded string resources: a `"` would end the quoted label and a newline the
|
|
2064
|
+
// line. Mermaid takes `#quot;` / `<br/>` inside a quoted label.
|
|
2065
|
+
const mermaidLabel = (s) => pyStr(s).replace(/"/g, '#quot;').replace(/\r?\n/g, '<br/>');
|
|
2063
2066
|
const lines = ['graph LR'];
|
|
2064
|
-
for (const n of nodeList) { lines.push(` ${sid(n.id)}["${
|
|
2067
|
+
for (const n of nodeList) { lines.push(` ${sid(n.id)}["${mermaidLabel(get(n, 'label', n.id))}"]`); }
|
|
2065
2068
|
for (const e of edges) { lines.push(` ${sid(e.source)} -->|${pyStr(get(e, 'mechanism', ''))}| ${sid(e.target)}`); }
|
|
2066
2069
|
writeText(osJoin(ws, 'utg.mermaid'), lines.join('\n'));
|
|
2067
2070
|
|