(
&self,
id: &str,
max_depth: Option<usize>,
)
| 716 | } |
| 717 | |
| 718 | pub fn accessibility_tree( |
| 719 | &self, |
| 720 | id: &str, |
| 721 | max_depth: Option<usize>, |
| 722 | ) -> Result<Value, AppError> { |
| 723 | let serial = self.serial_for_id(id)?; |
| 724 | let max_depth = max_depth.unwrap_or(80).min(80); |
| 725 | let mut last_error = None; |
| 726 | for attempt in 1..=ANDROID_UIAUTOMATOR_DUMP_ATTEMPTS { |
| 727 | match self.android_accessibility_tree_for_serial(&serial, max_depth) { |
| 728 | Ok(tree) => return Ok(tree), |
| 729 | Err(error) => last_error = Some(error), |
| 730 | } |
| 731 | if attempt < ANDROID_UIAUTOMATOR_DUMP_ATTEMPTS { |
| 732 | thread::sleep(ANDROID_UIAUTOMATOR_DUMP_RETRY_DELAY); |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | Err(last_error.unwrap_or_else(|| { |
| 737 | AppError::native("Unable to capture Android UIAutomator hierarchy.") |
| 738 | })) |
| 739 | } |
| 740 | |
| 741 | fn android_accessibility_tree_for_serial( |
| 742 | &self, |
no test coverage detected