(state: AppState, udid: String, generation: u64)
| 3403 | } |
| 3404 | |
| 3405 | async fn warm_accessibility_cache(state: AppState, udid: String, generation: u64) { |
| 3406 | if android::is_android_id(&udid) { |
| 3407 | return; |
| 3408 | } |
| 3409 | let session = match state.registry.get_or_create_async(&udid).await { |
| 3410 | Ok(session) => session, |
| 3411 | Err(error) => { |
| 3412 | tracing::debug!("AX warmup skipped session creation for {udid}: {error}"); |
| 3413 | return; |
| 3414 | } |
| 3415 | }; |
| 3416 | if let Err(error) = session.ensure_started_async().await { |
| 3417 | tracing::debug!("AX warmup skipped display start for {udid}: {error}"); |
| 3418 | } |
| 3419 | |
| 3420 | for (max_depth, interactive_only) in [(Some(8), true)] { |
| 3421 | let Ok(snapshot) = native_ax_accessibility_tree_value( |
| 3422 | state.clone(), |
| 3423 | udid.clone(), |
| 3424 | max_depth, |
| 3425 | false, |
| 3426 | interactive_only, |
| 3427 | ) |
| 3428 | .await |
| 3429 | else { |
| 3430 | continue; |
| 3431 | }; |
| 3432 | state.accessibility_cache.insert_if_generation( |
| 3433 | AccessibilitySnapshotCacheKey { |
| 3434 | udid: udid.clone(), |
| 3435 | source: AccessibilitySource::NativeAX.as_query_value().to_owned(), |
| 3436 | max_depth, |
| 3437 | include_hidden: false, |
| 3438 | interactive_only, |
| 3439 | }, |
| 3440 | &snapshot, |
| 3441 | generation, |
| 3442 | ); |
| 3443 | if interactive_only { |
| 3444 | state.accessibility_cache.insert_if_generation( |
| 3445 | AccessibilitySnapshotCacheKey { |
| 3446 | udid: udid.clone(), |
| 3447 | source: AccessibilitySource::Auto.as_query_value().to_owned(), |
| 3448 | max_depth, |
| 3449 | include_hidden: false, |
| 3450 | interactive_only, |
| 3451 | }, |
| 3452 | &snapshot, |
| 3453 | generation, |
| 3454 | ); |
| 3455 | } |
| 3456 | } |
| 3457 | |
| 3458 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 3459 | if state.accessibility_cache.generation(&udid) != generation { |
| 3460 | return; |
| 3461 | } |
| 3462 | let Ok(snapshot) = |
no test coverage detected