MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / describe_ui_snapshot

Function describe_ui_snapshot

packages/server/src/main.rs:5581–5636  ·  view source on GitHub ↗
(
    bridge: &NativeBridge,
    udid: &str,
    point: Option<(f64, f64)>,
    source: AccessibilitySource,
    max_depth: Option<usize>,
    include_hidden: bool,
    interactive_only: bool,
    dir

Source from the content-addressed store, hash-verified

5579
5580#[allow(clippy::too_many_arguments)]
5581fn describe_ui_snapshot(
5582 bridge: &NativeBridge,
5583 udid: &str,
5584 point: Option<(f64, f64)>,
5585 source: AccessibilitySource,
5586 max_depth: Option<usize>,
5587 include_hidden: bool,
5588 interactive_only: bool,
5589 direct: bool,
5590 server_url: &str,
5591) -> anyhow::Result<Value> {
5592 if !direct {
5593 if let Some((x, y)) = point {
5594 if matches!(
5595 source,
5596 AccessibilitySource::Auto
5597 | AccessibilitySource::NativeAX
5598 | AccessibilitySource::AndroidUiautomator
5599 ) {
5600 match fetch_service_accessibility_point(udid, x, y, server_url) {
5601 Ok(snapshot) => return Ok(snapshot),
5602 Err(error) if source != AccessibilitySource::Auto => return Err(error),
5603 Err(_) => {}
5604 }
5605 }
5606 } else {
5607 match fetch_service_accessibility_tree(
5608 udid,
5609 source,
5610 max_depth,
5611 include_hidden,
5612 interactive_only,
5613 server_url,
5614 ) {
5615 Ok(snapshot) => return Ok(snapshot),
5616 Err(error) if source != AccessibilitySource::Auto => return Err(error),
5617 Err(_) => {}
5618 }
5619 }
5620 }
5621
5622 if source != AccessibilitySource::Auto && source != AccessibilitySource::NativeAX {
5623 anyhow::bail!(
5624 "The `{}` hierarchy source requires a running SimDeck service. Start it with `simdeck service start --port 4311`, or use --source native-ax.",
5625 source.as_query_value()
5626 );
5627 }
5628
5629 let snapshot =
5630 bridge.accessibility_snapshot_with_options(udid, point, max_depth, interactive_only)?;
5631 Ok(if interactive_only && point.is_none() {
5632 interactive_accessibility_snapshot(&snapshot)
5633 } else {
5634 snapshot
5635 })
5636}
5637
5638fn fetch_service_accessibility_tree(

Callers 1

mainFunction · 0.85

Tested by

no test coverage detected