(
state: AppState,
udid: String,
source: Option<&str>,
max_depth: Option<usize>,
include_hidden: bool,
interactive_only: bool,
)
| 3479 | } |
| 3480 | |
| 3481 | async fn accessibility_tree_value( |
| 3482 | state: AppState, |
| 3483 | udid: String, |
| 3484 | source: Option<&str>, |
| 3485 | max_depth: Option<usize>, |
| 3486 | include_hidden: bool, |
| 3487 | interactive_only: bool, |
| 3488 | ) -> Result<Value, AppError> { |
| 3489 | if android::is_android_id(&udid) { |
| 3490 | let requested_source = source |
| 3491 | .filter(|source| *source != "auto") |
| 3492 | .map(|source| source.to_owned()); |
| 3493 | return run_android_action(state, move |android| { |
| 3494 | let mut tree = android.accessibility_tree(&udid, max_depth)?; |
| 3495 | if include_hidden { |
| 3496 | tree["includeHidden"] = Value::Bool(true); |
| 3497 | } |
| 3498 | if let Some(source) = requested_source { |
| 3499 | tree["requestedSource"] = Value::String(source); |
| 3500 | } |
| 3501 | if interactive_only { |
| 3502 | tree = interactive_accessibility_snapshot(&tree); |
| 3503 | } |
| 3504 | Ok(tree) |
| 3505 | }) |
| 3506 | .await; |
| 3507 | } |
| 3508 | let requested_source = AccessibilitySource::parse(source).map_err(AppError::bad_request)?; |
| 3509 | if requested_source == AccessibilitySource::AndroidUiautomator { |
| 3510 | return Err(AppError::bad_request( |
| 3511 | "`android-uiautomator` source is only available for Android emulator IDs.", |
| 3512 | )); |
| 3513 | } |
| 3514 | let max_depth = max_depth.map(|depth| depth.min(80)); |
| 3515 | |
| 3516 | if requested_source == AccessibilitySource::NativeAX |
| 3517 | || (interactive_only && requested_source == AccessibilitySource::Auto) |
| 3518 | { |
| 3519 | return native_ax_accessibility_tree_value( |
| 3520 | state, |
| 3521 | udid, |
| 3522 | max_depth, |
| 3523 | include_hidden, |
| 3524 | interactive_only, |
| 3525 | ) |
| 3526 | .await; |
| 3527 | } |
| 3528 | |
| 3529 | match inspector_session_for_state(&state, &udid).await { |
| 3530 | Ok(session) => { |
| 3531 | let hierarchy_source = match requested_source { |
| 3532 | AccessibilitySource::Auto => InAppHierarchySource::Automatic, |
| 3533 | AccessibilitySource::NativeScript => InAppHierarchySource::Automatic, |
| 3534 | AccessibilitySource::ReactNative => InAppHierarchySource::Automatic, |
| 3535 | AccessibilitySource::Flutter => InAppHierarchySource::Automatic, |
| 3536 | AccessibilitySource::SwiftUI => InAppHierarchySource::Automatic, |
| 3537 | AccessibilitySource::UIKit => InAppHierarchySource::UIKit, |
| 3538 | AccessibilitySource::NativeAX => unreachable!(), |
no test coverage detected