From 2d0e78ccc431515f23ca7c2f907bf9f7b931a4c4 Mon Sep 17 00:00:00 2001 From: gabbuccio Date: Tue, 24 Nov 2026 17:45:45 +0100 Subject: [PATCH 1/4] fix(ddi): mount the classic personalized DDI via mobile_image_mounter on iOS 17-26 On iOS 18 the cryptexd push of the cryptex DDI is reset by the device (device socket io failed), so WDA never starts. Below iOS 27 mount the personalized DDI through mobile_image_mounter instead, read from ICTL_LEGACY_DDI_DIR (Image.dmg, Image.dmg.trustcache, BuildManifest.plist). iOS 27+ keeps the cryptexd path unchanged. Fixes #185 Co-Authored-By: Claude Opus 5.5 --- Cargo.toml | 1 + crates/ictl-daemon/src/supervise.rs | 23 +++++++++++++++++-- crates/ictl-device/src/lib.rs | 34 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6ab2a59..07e0499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ idevice = { version = "=0.1.68", default-features = false, features = [ "core_device", "display_stream", "cryptexd", + "mobile_image_mounter", "tss", "installation_proxy", "springboardservices", diff --git a/crates/ictl-daemon/src/supervise.rs b/crates/ictl-daemon/src/supervise.rs index 23c6051..9f50a41 100644 --- a/crates/ictl-daemon/src/supervise.rs +++ b/crates/ictl-daemon/src/supervise.rs @@ -455,7 +455,7 @@ impl Daemon { g.preparing = Some(tokio::task::spawn_local(then_wake(wake, async move { let _lease = lease; let mut t = device.open_tunnel().await.map_err(|e| (e, false))?; - let r = ensure_ddi(&mut t, &cache, &url, user_dir.as_deref()).await; + let r = ensure_ddi(&device, &mut t, &cache, &url, user_dir.as_deref()).await; let stopped = match (&r, known) { (Ok(_), Some(pid)) => Some((device.udid.clone(), detached::stop(&mut t, pid).await)), _ => None, @@ -617,7 +617,7 @@ impl Daemon { type Ready = (Option, Result, Option); let ddi: Result = async { let mut t = device.open_tunnel().await.map_err(|e| (e, false))?; - let r = ensure_ddi(&mut t, &cache, &url, user_dir.as_deref()).await; + let r = ensure_ddi(&device, &mut t, &cache, &url, user_dir.as_deref()).await; let r = match r { Ok(m) => { // 后台启动前先开系统日志流:认「Enable UI Automation」密码框靠它(见 WdaRunner::attach) @@ -1054,9 +1054,15 @@ fn now_secs() -> u64 { std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() } +/// Whether the phone takes the classic image through mobile_image_mounter (0 = version unreadable: cryptexd, as before) +fn legacy_ddi(major: u32) -> bool { + (1..27).contains(&major) +} + /// 手机重启后开发者镜像可能掉了:没挂就挂上(返回挂上的版本),已挂载时只是一次查询。 /// 错误带上「是不是挂载这一步」(才可能是缓存坏了) async fn ensure_ddi( + device: &Device, t: &mut Tunnel, cache: &std::path::Path, url: &str, @@ -1065,6 +1071,11 @@ async fn ensure_ddi( if t.ddi_mounted().await.map_err(|e| (e, false))?.is_some() { return Ok(None); } + // iOS 17–26: the classic personalized image via mobile_image_mounter; cryptexd is for iOS 27 only + if legacy_ddi(device.info().await.map_err(|e| (e, false))?.major_version()) { + let mounted = device.mount_legacy_ddi().await.map_err(|e| (e, true))?; + return Ok(mounted.then(|| "personalized".to_owned())); + } let dir = match user_dir { Some(d) => ictl_device::ddi::require_complete(d), None => ictl_device::ddi::ensure_cache(cache, url).await, @@ -1099,6 +1110,14 @@ async fn open_log(device: &Device) -> Option { } } +#[cfg(test)] +mod ddi_tests { + #[test] + fn legacy_ddi_below_ios_27_only() { + assert!(super::legacy_ddi(18) && !super::legacy_ddi(27) && !super::legacy_ddi(0)); + } +} + #[cfg(test)] mod display_tests { use super::*; diff --git a/crates/ictl-device/src/lib.rs b/crates/ictl-device/src/lib.rs index 8b3af1d..7cf4060 100644 --- a/crates/ictl-device/src/lib.rs +++ b/crates/ictl-device/src/lib.rs @@ -36,6 +36,7 @@ use idevice::{ installation_proxy::InstallationProxyClient, lockdown::LockdownClient, misagent::MisagentClient, + mobile_image_mounter::ImageMounter, provider::{IdeviceProvider, UsbmuxdProvider}, rsd::RsdHandshake, springboardservices::{InterfaceOrientation, SpringBoardServicesClient}, @@ -424,6 +425,39 @@ impl Device { .await } + /// iOS 17–26: the classic personalized image goes through lockdown's `mobile_image_mounter` (cryptexd stalls + /// there). Skipped when one is already mounted. The files come from `ICTL_LEGACY_DDI_DIR`: `Image.dmg`, + /// `Image.dmg.trustcache`, `BuildManifest.plist`. Returns whether it mounted something + pub async fn mount_legacy_ddi(&self) -> Result { + let dir = std::env::var_os("ICTL_LEGACY_DDI_DIR").map(std::path::PathBuf::from).ok_or_else(|| { + DeviceError::Idevice(ictl_l10n::tr!( + "iOS 17–26 需要经典个性化开发者镜像:把 ICTL_LEGACY_DDI_DIR 设为含 Image.dmg、Image.dmg.trustcache、BuildManifest.plist 的目录", + "iOS 17–26 needs the classic personalized developer disk image: set ICTL_LEGACY_DDI_DIR to a directory with Image.dmg, Image.dmg.trustcache and BuildManifest.plist" + ).into()) + })?; + limit(ictl_l10n::tr!("挂载开发者镜像", "mount the developer disk image"), Duration::from_secs(180), async { + // the chip id first: the mounter must be followed by no lockdown session, but preceded by it is fine + let mut lockdown = LockdownClient::connect(&*self.provider).await?; + let ecid = lockdown + .get_value(Some("UniqueChipID"), None) + .await? + .as_unsigned_integer() + .ok_or_else(|| DeviceError::Idevice("the phone gave no UniqueChipID".into()))?; + let mut mounter = ImageMounter::connect(&*self.provider).await?; + if mounter.lookup_image("Personalized").await.is_ok() { + return Ok(false); + } + let (image, trustcache, manifest) = ( + tokio::fs::read(dir.join("Image.dmg")).await?, + tokio::fs::read(dir.join("Image.dmg.trustcache")).await?, + tokio::fs::read(dir.join("BuildManifest.plist")).await?, + ); + mounter.mount_personalized(&*self.provider, image, trustcache, &manifest, None, ecid).await?; + Ok(true) + }) + .await + } + /// 名称、型号、iOS 版本(不需要配对) pub async fn info(&self) -> Result { limit(ictl_l10n::tr!("读设备信息", "read device info"), QUERY, self.info_inner()).await From 402a7faddd90e260430c34a9a503e7fa4c50d9d8 Mon Sep 17 00:00:00 2001 From: gabbuccio Date: Wed, 25 Nov 2026 00:47:04 +0100 Subject: [PATCH 2/4] fix(ddi): iOS 17-18 only, auto-download the classic personalized image, review fixes - route only iOS 17-18 (1..26) to mobile_image_mounter; 26+, 0 stay on cryptexd - download PersonalizedImages/Xcode_iOS_DDI_Personalized into ddi/personalized/ (sibling of ICTL_DDI_URL), or take it from ICTL_DDI_DIR; no new env var - legacy path skips cryptexd and uses the major from g.info; lookup_image first, NotFound explicit, other errors propagated (NeedsUnlock keeps working) - mount_failed and invalidation only for the cache in use; require_complete names missing files; lockdown dropped before ImageMounter - tests for 0/17/18/26/27 and the personalized cache; regression case #169 Co-Authored-By: Claude Opus 5.5 --- crates/ictl-daemon/src/config.rs | 5 +++ crates/ictl-daemon/src/supervise.rs | 61 ++++++++++++++++++-------- crates/ictl-device/src/ddi.rs | 68 ++++++++++++++++++++++------- crates/ictl-device/src/lib.rs | 59 ++++++++++++++----------- docs/dev/regression-cases.md | 1 + packaging/env.example | 4 +- website/en/guide/configuration.md | 4 +- website/guide/configuration.md | 4 +- 8 files changed, 140 insertions(+), 66 deletions(-) diff --git a/crates/ictl-daemon/src/config.rs b/crates/ictl-daemon/src/config.rs index f4d90f0..dca4f38 100644 --- a/crates/ictl-daemon/src/config.rs +++ b/crates/ictl-daemon/src/config.rs @@ -151,6 +151,11 @@ impl Config { pub fn ddi_cache(&self) -> PathBuf { self.data_dir.join("ddi") } + /// The cache of the image a phone takes: `ddi/personalized/` for the classic personalized image (iOS 17–18), + /// `ddi/` for the cryptex one + pub fn ddi_cache_for(&self, legacy: bool) -> PathBuf { + if legacy { self.ddi_cache().join("personalized") } else { self.ddi_cache() } + } /// 旧版本的锁屏密码:只有一份,不知道是哪台设备的。USB 上只接着一台时归到那台名下(见 /// [`crate::core::Daemon::adopt_legacy_passcode`]),接着多台时不用,免得把一台的密码输进另一台 pub fn legacy_passcode_file(&self) -> PathBuf { diff --git a/crates/ictl-daemon/src/supervise.rs b/crates/ictl-daemon/src/supervise.rs index 9f50a41..a0638af 100644 --- a/crates/ictl-daemon/src/supervise.rs +++ b/crates/ictl-daemon/src/supervise.rs @@ -446,7 +446,9 @@ impl Daemon { if !matches!(g.state, DeviceState::Preparing { .. }) { self.set_state(g, DeviceState::Preparing { last_error: None }); } - let (cache, url, user_dir) = (self.cfg.ddi_cache(), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); + let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); + let (cache, url, user_dir) = + (self.cfg.ddi_cache_for(legacy), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); // a WDA launched in the background before (WDA control earlier): not wanted now, ended once the image is up // (AppService needs it) let known = g.persisted.detached_for(&device.udid); @@ -455,7 +457,7 @@ impl Daemon { g.preparing = Some(tokio::task::spawn_local(then_wake(wake, async move { let _lease = lease; let mut t = device.open_tunnel().await.map_err(|e| (e, false))?; - let r = ensure_ddi(&device, &mut t, &cache, &url, user_dir.as_deref()).await; + let r = ensure_ddi(&device, &mut t, legacy, &cache, &url, user_dir.as_deref()).await; let stopped = match (&r, known) { (Ok(_), Some(pid)) => Some((device.udid.clone(), detached::stop(&mut t, pid).await)), _ => None, @@ -517,7 +519,9 @@ impl Daemon { g.dev.ddi_failures += 1; if g.dev.ddi_failures >= DDI_FAILURES_INVALIDATE { self.log.log(&ictl_l10n::log_trf!("开发者镜像连续 {} 次挂载失败,清掉缓存,下次重新下载", "Mounting the developer disk image failed {} times in a row, clearing the cache to download it again", g.dev.ddi_failures)); - ictl_device::ddi::invalidate(&self.cfg.ddi_cache()); + // the cache of the image this phone takes (the classic personalized one on iOS 17–18) + let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); + ictl_device::ddi::invalidate(&self.cfg.ddi_cache_for(legacy), ddi_files(legacy)); g.dev.ddi_failures = 0; } } @@ -606,7 +610,9 @@ impl Daemon { "The background WDA on the phone (pid {pid}) was launched by an older version and listens on every interface of the phone: launching it again, listening on the phone's loopback only" )); } - let (cache, url, user_dir) = (self.cfg.ddi_cache(), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); + let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); + let (cache, url, user_dir) = + (self.cfg.ddi_cache_for(legacy), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); let Ok(lease) = crate::maintenance::shared() else { return }; let wake = self.wake.clone(); g.starting = Some(tokio::task::spawn_local(then_wake(wake, async move { @@ -617,7 +623,7 @@ impl Daemon { type Ready = (Option, Result, Option); let ddi: Result = async { let mut t = device.open_tunnel().await.map_err(|e| (e, false))?; - let r = ensure_ddi(&device, &mut t, &cache, &url, user_dir.as_deref()).await; + let r = ensure_ddi(&device, &mut t, legacy, &cache, &url, user_dir.as_deref()).await; let r = match r { Ok(m) => { // 后台启动前先开系统日志流:认「Enable UI Automation」密码框靠它(见 WdaRunner::attach) @@ -1054,33 +1060,48 @@ fn now_secs() -> u64 { std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() } -/// Whether the phone takes the classic image through mobile_image_mounter (0 = version unreadable: cryptexd, as before) +/// Whether the phone takes the classic personalized image through mobile_image_mounter: iOS 17–18 (Apple went from +/// 18 to 26; iOS 26 and later mount the cryptex image through cryptexd). 0 = version unreadable: cryptexd, as before fn legacy_ddi(major: u32) -> bool { - (1..27).contains(&major) + (1..26).contains(&major) +} + +/// The files of the image the phone takes (see [`legacy_ddi`]) +fn ddi_files(legacy: bool) -> &'static [&'static str] { + if legacy { &ictl_device::ddi::PERSONALIZED_FILES } else { &ictl_device::ddi::FILES } } /// 手机重启后开发者镜像可能掉了:没挂就挂上(返回挂上的版本),已挂载时只是一次查询。 -/// 错误带上「是不是挂载这一步」(才可能是缓存坏了) +/// 错误带上「是不是挂载这一步」(才可能是缓存坏了)。`legacy`: iOS 17–18 (see [`legacy_ddi`]), `cache` is that +/// image's cache; cryptexd isn't asked on that path async fn ensure_ddi( device: &Device, t: &mut Tunnel, + legacy: bool, cache: &std::path::Path, url: &str, user_dir: Option<&std::path::Path>, ) -> Result, (DeviceError, bool)> { - if t.ddi_mounted().await.map_err(|e| (e, false))?.is_some() { + if legacy { + if device.legacy_ddi_mounted().await.map_err(|e| (e, false))? { + return Ok(None); + } + } else if t.ddi_mounted().await.map_err(|e| (e, false))?.is_some() { return Ok(None); } - // iOS 17–26: the classic personalized image via mobile_image_mounter; cryptexd is for iOS 27 only - if legacy_ddi(device.info().await.map_err(|e| (e, false))?.major_version()) { - let mounted = device.mount_legacy_ddi().await.map_err(|e| (e, true))?; - return Ok(mounted.then(|| "personalized".to_owned())); - } + let files = ddi_files(legacy); let dir = match user_dir { - Some(d) => ictl_device::ddi::require_complete(d), - None => ictl_device::ddi::ensure_cache(cache, url).await, + Some(d) => ictl_device::ddi::require_complete(d, files), + None if legacy => { + ictl_device::ddi::ensure_cache(cache, &ictl_device::ddi::personalized_url(url), files).await + } + None => ictl_device::ddi::ensure_cache(cache, url, files).await, } .map_err(|e| (e, false))?; + if legacy { + device.mount_legacy_ddi(&dir).await.map_err(|e| (e, true))?; + return Ok(Some("personalized".to_owned())); + } Ok(Some(t.mount_ddi(&dir).await.map_err(|e| (e, true))?)) } @@ -1113,8 +1134,12 @@ async fn open_log(device: &Device) -> Option { #[cfg(test)] mod ddi_tests { #[test] - fn legacy_ddi_below_ios_27_only() { - assert!(super::legacy_ddi(18) && !super::legacy_ddi(27) && !super::legacy_ddi(0)); + fn only_ios_17_and_18_take_the_classic_personalized_image() { + use super::{ddi_files, legacy_ddi}; + assert!(legacy_ddi(17) && legacy_ddi(18)); + assert!(!legacy_ddi(26) && !legacy_ddi(27) && !legacy_ddi(0)); + assert_eq!(ddi_files(true), ictl_device::ddi::PERSONALIZED_FILES); + assert_eq!(ddi_files(false), ictl_device::ddi::FILES); } } diff --git a/crates/ictl-device/src/ddi.rs b/crates/ictl-device/src/ddi.rs index 50a57a7..10ece98 100644 --- a/crates/ictl-device/src/ddi.rs +++ b/crates/ictl-device/src/ddi.rs @@ -15,17 +15,31 @@ pub const DEFAULT_BASE_URL: &str = pub const FILES: [&str; 5] = ["BuildManifest.plist", "Image.dmg", "Image.dmg.trustcache", "Image.dmg.cryptex_info", "Image.dmg.root_hash"]; +/// iOS 17–18: the classic personalized image (mounted through `mobile_image_mounter`), next to the cryptex one +/// in the same upstream repository +pub const PERSONALIZED_FILES: [&str; 3] = ["BuildManifest.plist", "Image.dmg", "Image.dmg.trustcache"]; + +/// Where the classic personalized image is downloaded from: the `Xcode_iOS_DDI_Personalized` directory next to +/// the cryptex one (`ICTL_DDI_URL` points at a mirror of the upstream layout) +pub fn personalized_url(base_url: &str) -> String { + let base = base_url.trim_end_matches('/'); + match base.rsplit_once('/') { + Some((parent, _)) => format!("{parent}/Xcode_iOS_DDI_Personalized"), + None => base.to_owned(), + } +} + /// 记录缓存来自哪个下载地址:换了地址就整套重新下载,免得新旧文件混在一起 const SOURCE_STAMP: &str = ".source"; /// 缓存是否完整 -pub fn cache_complete(dir: &Path) -> bool { - FILES.iter().all(|f| dir.join(f).is_file()) +pub fn cache_complete(dir: &Path, files: &[&str]) -> bool { + files.iter().all(|f| dir.join(f).is_file()) } /// 用户自己提供的目录(`ICTL_DDI_DIR`):不下载、不改动,只检查文件齐不齐 -pub fn require_complete(dir: &Path) -> Result { - let missing: Vec<&str> = FILES.iter().copied().filter(|f| !dir.join(f).is_file()).collect(); +pub fn require_complete(dir: &Path, files: &[&str]) -> Result { + let missing: Vec<&str> = files.iter().copied().filter(|f| !dir.join(f).is_file()).collect(); if missing.is_empty() { return Ok(dir.to_owned()); } @@ -41,15 +55,15 @@ pub fn require_complete(dir: &Path) -> Result { } /// 删掉缓存(挂载反复失败时调用,下次重新下载)。只用于守护进程自己下载的缓存目录 -pub fn invalidate(dir: &Path) { - for f in FILES.iter().chain([&SOURCE_STAMP]) { +pub fn invalidate(dir: &Path, files: &[&str]) { + for f in files.iter().chain([&SOURCE_STAMP]) { let _ = std::fs::remove_file(dir.join(f)); } } /// 确保 `dir` 里有完整的 DDI,缺的从 `base_url` 下载;返回该目录。 /// 下载先写临时文件再改名,中途失败不会留下半个文件。 -pub async fn ensure_cache(dir: &Path, base_url: &str) -> Result { +pub async fn ensure_cache(dir: &Path, base_url: &str, files: &[&str]) -> Result { let stamp = std::fs::read_to_string(dir.join(SOURCE_STAMP)).ok(); if stamp.as_deref().is_some_and(|s| s.trim() != base_url) { tracing::info!( @@ -59,9 +73,9 @@ pub async fn ensure_cache(dir: &Path, base_url: &str) -> Result { "The developer disk image download URL changed, downloading again" ) ); - invalidate(dir); + invalidate(dir, files); } - if cache_complete(dir) { + if cache_complete(dir, files) { if stamp.is_none() { // 早期版本下载的缓存没有记录来源:认作当前地址 let _ = std::fs::write(dir.join(SOURCE_STAMP), base_url); @@ -73,7 +87,7 @@ pub async fn ensure_cache(dir: &Path, base_url: &str) -> Result { .timeout(std::time::Duration::from_secs(600)) .build() .map_err(|e| DeviceError::Download(e.to_string()))?; - for name in FILES { + for &name in files { let dest = dir.join(name); if dest.is_file() { continue; @@ -106,14 +120,36 @@ mod tests { for f in &FILES[..4] { std::fs::write(dir.join(f), b"x").unwrap(); } - assert!(!cache_complete(&dir)); + assert!(!cache_complete(&dir, &FILES)); std::fs::write(dir.join(FILES[4]), b"x").unwrap(); - assert!(cache_complete(&dir)); - assert!(require_complete(&dir).is_ok()); - invalidate(&dir); - assert!(!cache_complete(&dir)); - let e = require_complete(&dir).unwrap_err().to_string(); + assert!(cache_complete(&dir, &FILES)); + assert!(require_complete(&dir, &FILES).is_ok()); + invalidate(&dir, &FILES); + assert!(!cache_complete(&dir, &FILES)); + let e = require_complete(&dir, &FILES).unwrap_err().to_string(); assert!(e.contains("BuildManifest.plist") && e.contains("Image.dmg.root_hash"), "{e}"); std::fs::remove_dir_all(&dir).unwrap(); } + + #[test] + fn the_personalized_image_needs_its_three_files_and_sits_next_to_the_cryptex_one() { + let dir = std::env::temp_dir().join(format!("ictl-ddi-personalized-test-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + for f in &PERSONALIZED_FILES[..2] { + std::fs::write(dir.join(f), b"x").unwrap(); + } + let e = require_complete(&dir, &PERSONALIZED_FILES).unwrap_err().to_string(); + assert!(e.contains("Image.dmg.trustcache") && !e.contains("cryptex_info"), "{e}"); + std::fs::write(dir.join(PERSONALIZED_FILES[2]), b"x").unwrap(); + assert!(cache_complete(&dir, &PERSONALIZED_FILES) && !cache_complete(&dir, &FILES)); + std::fs::remove_dir_all(&dir).unwrap(); + assert_eq!( + personalized_url(DEFAULT_BASE_URL), + "https://raw.githubusercontent.com/doronz88/DeveloperDiskImage/main/PersonalizedImages/Xcode_iOS_DDI_Personalized" + ); + assert_eq!( + personalized_url("https://mirror.example/ddi/Xcode_iOS_DDI_Cryptex/"), + "https://mirror.example/ddi/Xcode_iOS_DDI_Personalized" + ); + } } diff --git a/crates/ictl-device/src/lib.rs b/crates/ictl-device/src/lib.rs index 7cf4060..5b065b0 100644 --- a/crates/ictl-device/src/lib.rs +++ b/crates/ictl-device/src/lib.rs @@ -425,35 +425,42 @@ impl Device { .await } - /// iOS 17–26: the classic personalized image goes through lockdown's `mobile_image_mounter` (cryptexd stalls - /// there). Skipped when one is already mounted. The files come from `ICTL_LEGACY_DDI_DIR`: `Image.dmg`, - /// `Image.dmg.trustcache`, `BuildManifest.plist`. Returns whether it mounted something - pub async fn mount_legacy_ddi(&self) -> Result { - let dir = std::env::var_os("ICTL_LEGACY_DDI_DIR").map(std::path::PathBuf::from).ok_or_else(|| { - DeviceError::Idevice(ictl_l10n::tr!( - "iOS 17–26 需要经典个性化开发者镜像:把 ICTL_LEGACY_DDI_DIR 设为含 Image.dmg、Image.dmg.trustcache、BuildManifest.plist 的目录", - "iOS 17–26 needs the classic personalized developer disk image: set ICTL_LEGACY_DDI_DIR to a directory with Image.dmg, Image.dmg.trustcache and BuildManifest.plist" - ).into()) - })?; - limit(ictl_l10n::tr!("挂载开发者镜像", "mount the developer disk image"), Duration::from_secs(180), async { - // the chip id first: the mounter must be followed by no lockdown session, but preceded by it is fine - let mut lockdown = LockdownClient::connect(&*self.provider).await?; - let ecid = lockdown - .get_value(Some("UniqueChipID"), None) - .await? - .as_unsigned_integer() - .ok_or_else(|| DeviceError::Idevice("the phone gave no UniqueChipID".into()))?; + /// iOS 17–18: whether the classic personalized image is mounted (by us, Xcode or `devicectl`). A locked phone + /// or a dropped connection is an error, not «not mounted» + pub async fn legacy_ddi_mounted(&self) -> Result { + limit(ictl_l10n::tr!("查询开发者镜像", "query the developer disk image"), QUERY, async { let mut mounter = ImageMounter::connect(&*self.provider).await?; - if mounter.lookup_image("Personalized").await.is_ok() { - return Ok(false); + match mounter.lookup_image("Personalized").await { + Ok(_) => Ok(true), + Err(IdeviceError::NotFound) => Ok(false), + Err(e) => Err(e.into()), } - let (image, trustcache, manifest) = ( - tokio::fs::read(dir.join("Image.dmg")).await?, - tokio::fs::read(dir.join("Image.dmg.trustcache")).await?, - tokio::fs::read(dir.join("BuildManifest.plist")).await?, - ); + }) + .await + } + + /// iOS 17–18: mounts the classic personalized image from `dir` ([`ddi::PERSONALIZED_FILES`], checked by the + /// caller) through lockdown's `mobile_image_mounter` (cryptexd stalls there) + pub async fn mount_legacy_ddi(&self, dir: &std::path::Path) -> Result<()> { + let (image, trustcache, manifest) = ( + tokio::fs::read(dir.join("Image.dmg")).await?, + tokio::fs::read(dir.join("Image.dmg.trustcache")).await?, + tokio::fs::read(dir.join("BuildManifest.plist")).await?, + ); + limit(ictl_l10n::tr!("挂载开发者镜像", "mount the developer disk image"), Duration::from_secs(180), async { + // the chip id from a lockdown session closed before the mounter connects: idevice's ImageMounter note + // wants any lockdown session opened after the mounter (mount_personalized opens its own) + let ecid = { + let mut lockdown = LockdownClient::connect(&*self.provider).await?; + lockdown + .get_value(Some("UniqueChipID"), None) + .await? + .as_unsigned_integer() + .ok_or_else(|| DeviceError::Idevice("the phone gave no UniqueChipID".into()))? + }; + let mut mounter = ImageMounter::connect(&*self.provider).await?; mounter.mount_personalized(&*self.provider, image, trustcache, &manifest, None, ecid).await?; - Ok(true) + Ok(()) }) .await } diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index 56cc233..9676ff4 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -172,3 +172,4 @@ | 166 | WDA 输入后核对:替换选中的文字(搜索框保留上次的搜索并选中)时读两遍、每遍 4 个请求再等 0.3 秒,往 Spotlight 输入比 main 慢约 1.8 秒(iPad mini 5,`run.py` 第 12 步) | 复读只问聚焦的元素和它的值(2 个请求);读一次就能下结论的(替换了选中的文字)不再读第二遍 | 单测 `typing_over_a_selection_is_judged_after_one_reread` + 真机(iPad 上 `run.py --repeat 5` 和 main 对比) | | 167 | `iphone_scroll_collect` 重复收行:设置的大标题滑动时收起到导航栏,下一屏开头对不上上一屏结尾,几行被收两遍;iPad 分栏界面(WDA)只有一栏在滚,两栏的行交错;同一行的 Cell、文字和 chevron 中心差 1 点,滑动后先后顺序会变;左栏的导航栏和搜索框不动,行从它们底下滑过、夹在行中间。两屏完全对不上,整屏都算新行,滑两三次就到 150 行上限,左栏也滚不到 | 同一行的元素归成一行、行内从左到右;树里有滚动区域时只拿滚动区域里的内容比对,栏等其他元素上一屏没有同样的才算新行;没在滚的那一栏不参与比对,重叠的两头各可隔开几个元素(挪了位置的标题不算新行);`x` 指定在哪一栏滑 | 单测 `a_title_collapsing_into_the_navigation_bar_does_not_repeat_the_overlap`、`a_column_that_did_not_scroll_is_not_collected_again`、`rows_are_matched_in_the_scroll_area_one_row_at_a_time` + 真机(iPhone 设置整页收集无重复;iPad 设置默认在正中滑、`x` 在左栏滑都不重复,`x` 在左栏找到「隐私与安全」) | | 168 | 后台启动 WDA 不带环境变量,WDA 不设 `USE_IP` 时在手机的所有网卡上监听:手机连着 Wi-Fi 时,局域网里谁都能经 8100(没有认证)操作手机、经 9100 看画面 | 后台启动和 XCTest 启动都带 `USE_IP=127.0.0.1`;`state.json` 的 `loopback_wdas` 记下这样启动的进程,旧版本启动的(不在里面)不再接上而是重新启动 | 单测 `the_launch_environment_is_a_dictionary_of_strings`、`only_a_loopback_only_background_wda_is_attached_to_again` + 真机(USB 上 WDA 就绪、工具和控制台 MJPEG 画面照常;手机连 Wi-Fi 时从局域网另一台机器 `curl http://<手机IP>:8100/status`、`:9100` 连不上;升级前已在运行的后台 WDA 被重新启动) | +| 169 | iOS 17–18(#185,iPhone XS,iOS 18.7.12):开发者镜像经 cryptexd 挂载卡住,WDA 起不来。这些版本要经典个性化镜像,走 lockdown 的 `mobile_image_mounter` | iOS 17–18 不问 cryptexd:先 `lookup_image("Personalized")`(已挂上就不读文件;锁屏等其他错误照常报出,不当成没挂),没挂才从 `ddi/personalized/` 缓存(上游 `Xcode_iOS_DDI_Personalized`,自动下载)或 `ICTL_DDI_DIR` 取三个文件再挂;iOS 26 及以后、版本读不出(0)照旧走 cryptexd;连续挂载失败只清掉这台手机用的那份缓存 | 单测 `only_ios_17_and_18_take_the_classic_personalized_image`、`the_personalized_image_needs_its_three_files_and_sits_next_to_the_cryptex_one` + 真机(iPhone XS,iOS 18.7.12:补丁前一版挂上并起了 WDA;本版待重测) | diff --git a/packaging/env.example b/packaging/env.example index afe0236..09faebf 100644 --- a/packaging/env.example +++ b/packaging/env.example @@ -69,9 +69,9 @@ BARK_KEY= # 高级 # 自建 anisette 服务(默认用 Impactor 的第三方服务) ICTL_ANISETTE_URL= -# 开发者镜像下载地址(默认社区维护的 doronz88/DeveloperDiskImage) +# 开发者镜像下载地址(默认社区维护的 doronz88/DeveloperDiskImage 的 Xcode_iOS_DDI_Cryptex;iOS 17–18 用同级的 Xcode_iOS_DDI_Personalized) ICTL_DDI_URL= -# 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个 +# 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个。iOS 17–18 要经典个性化镜像(BuildManifest.plist、Image.dmg、Image.dmg.trustcache) ICTL_DDI_DIR= # 未签名 WDA 的路径。默认是数据目录的 wda/WDA-unsigned.ipa,首次签名前下载 # ICTL_WDA_UNSIGNED=/path/to/WDA-unsigned.ipa diff --git a/website/en/guide/configuration.md b/website/en/guide/configuration.md index 1b1d465..c248ced 100644 --- a/website/en/guide/configuration.md +++ b/website/en/guide/configuration.md @@ -52,8 +52,8 @@ Notification variables: see [Notifications](./notifications). | Variable | Meaning | |---|---| | `ICTL_ANISETTE_URL` | Your own anisette server (the default is a public third-party one; see [Security](./security)) | -| `ICTL_DDI_URL` | Developer Disk Image download URL; the default is a community-maintained mirror | -| `ICTL_DDI_DIR` | A Developer Disk Image directory you extracted from Xcode. The daemon doesn't download anything or delete its files, and the error names any missing file. When unset, the `ddi/` cache in the data directory is used, and it is deleted and downloaded again after 3 failed mounts in a row | +| `ICTL_DDI_URL` | Developer Disk Image download URL; the default is a community-maintained mirror. The classic personalized image for iOS 17–18 is downloaded from the sibling `Xcode_iOS_DDI_Personalized` directory | +| `ICTL_DDI_DIR` | A Developer Disk Image directory you extracted from Xcode. The daemon doesn't download anything or delete its files, and the error names any missing file. iOS 17–18 take the classic personalized image (`BuildManifest.plist`, `Image.dmg`, `Image.dmg.trustcache`). When unset, the `ddi/` cache in the data directory is used (`ddi/personalized/` for iOS 17–18), and it is deleted and downloaded again after 3 failed mounts in a row | | `ICTL_IOS_BACKEND` | How phones on iOS 27 and later are driven. `auto` (the default) and `native`: natively, without WDA: HID for touches, the accessibility service to read the screen, the pasteboard to type. `wda`: still through WDA. iOS 26 and earlier always use WDA | | `ICTL_WDA_UNSIGNED` | Path of the unsigned WDA. Default: `wda/WDA-unsigned.ipa` in the data directory, downloaded before the first signing. A path you set yourself is not downloaded | | `SCREEN_W` / `SCREEN_H` | Screen size in points for the HID fallback, used only while WDA is down and there is no record of this device's size: WDA has never connected, or you switched to a device without one. It applies to every device, so take care with several | diff --git a/website/guide/configuration.md b/website/guide/configuration.md index 093877c..74f4f77 100644 --- a/website/guide/configuration.md +++ b/website/guide/configuration.md @@ -52,8 +52,8 @@ MCP 服务由 AI 客户端拉起,注册时写进去的环境变量优先于设 | 变量 | 含义 | |---|---| | `ICTL_ANISETTE_URL` | 自建 anisette 服务地址(默认用公共的第三方服务,见[安全与隐私](./security)) | -| `ICTL_DDI_URL` | 开发者镜像的下载地址,默认社区维护的镜像仓库 | -| `ICTL_DDI_DIR` | 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个。不设时用数据目录下的 `ddi/` 缓存,连续 3 次挂载失败后清掉重新下载 | +| `ICTL_DDI_URL` | 开发者镜像的下载地址,默认社区维护的镜像仓库。iOS 17–18 的经典个性化镜像从同级的 `Xcode_iOS_DDI_Personalized` 下载 | +| `ICTL_DDI_DIR` | 自己从 Xcode 提取的开发者镜像目录。设了就不下载,也不会删里面的文件;缺文件时报错说明缺哪个。iOS 17–18 要经典个性化镜像(`BuildManifest.plist`、`Image.dmg`、`Image.dmg.trustcache`)。不设时用数据目录下的 `ddi/` 缓存(iOS 17–18 是 `ddi/personalized/`),连续 3 次挂载失败后清掉重新下载 | | `ICTL_IOS_BACKEND` | iOS 27 及以上的手机怎么控制。`auto`(默认)和 `native`:原生,不用 WDA,经 HID 点按、无障碍服务读界面、剪贴板输入;`wda`:仍用 WDA。iOS 26 及以下总是用 WDA | | `ICTL_WDA_UNSIGNED` | 未签名 WDA 的路径。默认是数据目录的 `wda/WDA-unsigned.ipa`,第一次签名前下载。自己指定的路径不会下载 | | `SCREEN_W` / `SCREEN_H` | HID 后备路线换算坐标用的屏幕尺寸(点):WDA 不可用、又没有这台设备的尺寸记录时才用,比如 WDA 从没连上过,或切到记录里没有尺寸的设备。不分设备,接多台时要小心 | From 3cac1ca18d2734e8c62988a109b14e9aabcfdb03 Mon Sep 17 00:00:00 2001 From: gabbuccio Date: Wed, 25 Nov 2026 01:43:25 +0100 Subject: [PATCH 3/4] fix(ddi): second review: debug ddi, DeviceLocked, lockdown session, fresh tunnel - debug ddi: new ensure_cache signature, legacy personalized image on iOS 17-18 - legacy/files_for moved to ictl_device::ddi (shared by daemon and debug) - IdeviceError::DeviceLocked maps to PasswordProtected (NeedsUnlock, not a mount failure) - start a paired lockdown session before reading UniqueChipID - reopen the tunnel after a fresh mount so the RSD service list includes the image's services - personalized_url leaves a bare origin alone; rustfmt - regression case renumbered to #171 after merging main Co-Authored-By: Claude Opus 5.5 --- apps/iphone-control/src/debug.rs | 26 +++++++++++++++-- crates/ictl-daemon/src/supervise.rs | 45 +++++++++-------------------- crates/ictl-device/src/ddi.rs | 22 ++++++++++++-- crates/ictl-device/src/lib.rs | 6 +++- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/apps/iphone-control/src/debug.rs b/apps/iphone-control/src/debug.rs index 4d93833..0b696cb 100644 --- a/apps/iphone-control/src/debug.rs +++ b/apps/iphone-control/src/debug.rs @@ -219,8 +219,16 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> { let screen = ScreenSize { width: args.width, height: args.height }; match args.check { Check::Ddi { restore_dir, url } => { + // iOS 17–18: the classic personalized image through mobile_image_mounter, in `/personalized` + let legacy = ictl_device::ddi::legacy(info.major_version()); + let files = ictl_device::ddi::files_for(legacy); let mut t = device.open_tunnel().await?; - match t.ddi_mounted().await? { + let mounted = if legacy { + device.legacy_ddi_mounted().await?.then(|| "personalized".to_owned()) + } else { + t.ddi_mounted().await? + }; + match mounted { Some(v) => println!( "{}", ictl_l10n::trf!( @@ -229,9 +237,20 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> { ) ), None => { - let dir = ictl_device::ddi::ensure_cache(&restore_dir, &url).await?; let t0 = Instant::now(); - let v = t.mount_ddi(&dir).await?; + let v = if legacy { + let dir = ictl_device::ddi::ensure_cache( + &restore_dir.join("personalized"), + &ictl_device::ddi::personalized_url(&url), + files, + ) + .await?; + device.mount_legacy_ddi(&dir).await?; + "personalized".to_owned() + } else { + let dir = ictl_device::ddi::ensure_cache(&restore_dir, &url, files).await?; + t.mount_ddi(&dir).await? + }; println!( "{}", ictl_l10n::trf!( @@ -242,6 +261,7 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> { ); } } + t.close().await; let t = device.open_tunnel().await?; println!("universalhidservice: {}", t.has_service("com.apple.coredevice.hid.universalhidservice")); } diff --git a/crates/ictl-daemon/src/supervise.rs b/crates/ictl-daemon/src/supervise.rs index 9ebcb4e..6564cb2 100644 --- a/crates/ictl-daemon/src/supervise.rs +++ b/crates/ictl-daemon/src/supervise.rs @@ -446,7 +446,7 @@ impl Daemon { if !matches!(g.state, DeviceState::Preparing { .. }) { self.set_state(g, DeviceState::Preparing { last_error: None }); } - let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); + let legacy = ictl_device::ddi::legacy(g.info.as_ref().map_or(0, |i| i.major_version())); let (cache, url, user_dir) = (self.cfg.ddi_cache_for(legacy), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); // a WDA launched in the background before (WDA control earlier): not wanted now, ended once the image is up @@ -520,8 +520,8 @@ impl Daemon { if g.dev.ddi_failures >= DDI_FAILURES_INVALIDATE { self.log.log(&ictl_l10n::log_trf!("开发者镜像连续 {} 次挂载失败,清掉缓存,下次重新下载", "Mounting the developer disk image failed {} times in a row, clearing the cache to download it again", g.dev.ddi_failures)); // the cache of the image this phone takes (the classic personalized one on iOS 17–18) - let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); - ictl_device::ddi::invalidate(&self.cfg.ddi_cache_for(legacy), ddi_files(legacy)); + let legacy = ictl_device::ddi::legacy(g.info.as_ref().map_or(0, |i| i.major_version())); + ictl_device::ddi::invalidate(&self.cfg.ddi_cache_for(legacy), ictl_device::ddi::files_for(legacy)); g.dev.ddi_failures = 0; } } @@ -610,7 +610,7 @@ impl Daemon { "The background WDA on the phone (pid {pid}) was launched by an older version and listens on every interface of the phone: launching it again, listening on the phone's loopback only" )); } - let legacy = legacy_ddi(g.info.as_ref().map_or(0, |i| i.major_version())); + let legacy = ictl_device::ddi::legacy(g.info.as_ref().map_or(0, |i| i.major_version())); let (cache, url, user_dir) = (self.cfg.ddi_cache_for(legacy), self.cfg.ddi_url.clone(), self.cfg.ddi_dir.clone()); let Ok(lease) = crate::maintenance::shared() else { return }; @@ -626,6 +626,12 @@ impl Daemon { let r = ensure_ddi(&device, &mut t, legacy, &cache, &url, user_dir.as_deref()).await; let r = match r { Ok(m) => { + if m.is_some() { + // a tunnel opened before the image was mounted doesn't list its services + // (dtservicehub): a new one, so WDA starts on the first attempt + t.close().await; + t = device.open_tunnel().await.map_err(|e| (e, false))?; + } // 后台启动前先开系统日志流:认「Enable UI Automation」密码框靠它(见 WdaRunner::attach) let log = open_log(&device).await; Ok((m, prepare_detached(&mut t, known, &bundle).await, log)) @@ -1060,19 +1066,8 @@ fn now_secs() -> u64 { std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() } -/// Whether the phone takes the classic personalized image through mobile_image_mounter: iOS 17–18 (Apple went from -/// 18 to 26; iOS 26 and later mount the cryptex image through cryptexd). 0 = version unreadable: cryptexd, as before -fn legacy_ddi(major: u32) -> bool { - (1..26).contains(&major) -} - -/// The files of the image the phone takes (see [`legacy_ddi`]) -fn ddi_files(legacy: bool) -> &'static [&'static str] { - if legacy { &ictl_device::ddi::PERSONALIZED_FILES } else { &ictl_device::ddi::FILES } -} - /// 手机重启后开发者镜像可能掉了:没挂就挂上(返回挂上的版本),已挂载时只是一次查询。 -/// 错误带上「是不是挂载这一步」(才可能是缓存坏了)。`legacy`: iOS 17–18 (see [`legacy_ddi`]), `cache` is that +/// 错误带上「是不是挂载这一步」(才可能是缓存坏了)。`legacy`: iOS 17–18 (see [`ictl_device::ddi::legacy`]), `cache` is that /// image's cache; cryptexd isn't asked on that path async fn ensure_ddi( device: &Device, @@ -1089,12 +1084,10 @@ async fn ensure_ddi( } else if t.ddi_mounted().await.map_err(|e| (e, false))?.is_some() { return Ok(None); } - let files = ddi_files(legacy); + let files = ictl_device::ddi::files_for(legacy); let dir = match user_dir { Some(d) => ictl_device::ddi::require_complete(d, files), - None if legacy => { - ictl_device::ddi::ensure_cache(cache, &ictl_device::ddi::personalized_url(url), files).await - } + None if legacy => ictl_device::ddi::ensure_cache(cache, &ictl_device::ddi::personalized_url(url), files).await, None => ictl_device::ddi::ensure_cache(cache, url, files).await, } .map_err(|e| (e, false))?; @@ -1131,18 +1124,6 @@ async fn open_log(device: &Device) -> Option { } } -#[cfg(test)] -mod ddi_tests { - #[test] - fn only_ios_17_and_18_take_the_classic_personalized_image() { - use super::{ddi_files, legacy_ddi}; - assert!(legacy_ddi(17) && legacy_ddi(18)); - assert!(!legacy_ddi(26) && !legacy_ddi(27) && !legacy_ddi(0)); - assert_eq!(ddi_files(true), ictl_device::ddi::PERSONALIZED_FILES); - assert_eq!(ddi_files(false), ictl_device::ddi::FILES); - } -} - #[cfg(test)] mod display_tests { use super::*; diff --git a/crates/ictl-device/src/ddi.rs b/crates/ictl-device/src/ddi.rs index 10ece98..a0def74 100644 --- a/crates/ictl-device/src/ddi.rs +++ b/crates/ictl-device/src/ddi.rs @@ -19,13 +19,24 @@ pub const FILES: [&str; 5] = /// in the same upstream repository pub const PERSONALIZED_FILES: [&str; 3] = ["BuildManifest.plist", "Image.dmg", "Image.dmg.trustcache"]; +/// Whether a phone takes the classic personalized image through mobile_image_mounter: iOS 17–18 (Apple went from +/// 18 to 26; iOS 26 and later mount the cryptex image through cryptexd). 0 = version unreadable: cryptexd, as before +pub fn legacy(major: u32) -> bool { + (1..26).contains(&major) +} + +/// The files of the image the phone takes (see [`legacy`]) +pub fn files_for(legacy: bool) -> &'static [&'static str] { + if legacy { &PERSONALIZED_FILES } else { &FILES } +} + /// Where the classic personalized image is downloaded from: the `Xcode_iOS_DDI_Personalized` directory next to /// the cryptex one (`ICTL_DDI_URL` points at a mirror of the upstream layout) pub fn personalized_url(base_url: &str) -> String { let base = base_url.trim_end_matches('/'); match base.rsplit_once('/') { - Some((parent, _)) => format!("{parent}/Xcode_iOS_DDI_Personalized"), - None => base.to_owned(), + Some((parent, _)) if !parent.ends_with(":/") => format!("{parent}/Xcode_iOS_DDI_Personalized"), + _ => base.to_owned(), } } @@ -132,7 +143,7 @@ mod tests { } #[test] - fn the_personalized_image_needs_its_three_files_and_sits_next_to_the_cryptex_one() { + fn only_ios_17_and_18_take_the_personalized_image_with_its_three_files_next_to_the_cryptex_one() { let dir = std::env::temp_dir().join(format!("ictl-ddi-personalized-test-{}", std::process::id())); std::fs::create_dir_all(&dir).unwrap(); for f in &PERSONALIZED_FILES[..2] { @@ -147,6 +158,11 @@ mod tests { personalized_url(DEFAULT_BASE_URL), "https://raw.githubusercontent.com/doronz88/DeveloperDiskImage/main/PersonalizedImages/Xcode_iOS_DDI_Personalized" ); + assert_eq!(personalized_url("https://mirror.example"), "https://mirror.example"); + assert!(legacy(17) && legacy(18)); + assert!(!legacy(26) && !legacy(27) && !legacy(0)); + assert_eq!(files_for(true), PERSONALIZED_FILES); + assert_eq!(files_for(false), FILES); assert_eq!( personalized_url("https://mirror.example/ddi/Xcode_iOS_DDI_Cryptex/"), "https://mirror.example/ddi/Xcode_iOS_DDI_Personalized" diff --git a/crates/ictl-device/src/lib.rs b/crates/ictl-device/src/lib.rs index 5b065b0..243b659 100644 --- a/crates/ictl-device/src/lib.rs +++ b/crates/ictl-device/src/lib.rs @@ -150,7 +150,8 @@ pub(crate) async fn limit(what: &str, d: Duration, f: impl Future for DeviceError { fn from(e: IdeviceError) -> Self { match e { - IdeviceError::PasswordProtected => Self::PasswordProtected, + // lockdown says PasswordProtected, mobile_image_mounter DeviceLocked + IdeviceError::PasswordProtected | IdeviceError::DeviceLocked => Self::PasswordProtected, IdeviceError::DeviceNotFound => Self::NotConnected, IdeviceError::InvalidHostID => Self::NotPaired, IdeviceError::PairingDialogResponsePending => Self::PairingPending, @@ -452,6 +453,9 @@ impl Device { // wants any lockdown session opened after the mounter (mount_personalized opens its own) let ecid = { let mut lockdown = LockdownClient::connect(&*self.provider).await?; + // asked without a session, lockdown may answer GetProhibited + let pairing = idevice::provider::IdeviceProvider::get_pairing_file(&*self.provider).await?; + lockdown.start_session(&pairing).await?; lockdown .get_value(Some("UniqueChipID"), None) .await? From b66d53ce293f9e1c7918dc43e8c653469af5d9ab Mon Sep 17 00:00:00 2001 From: Derrors <33656531+Derrors@users.noreply.github.com> Date: Wed, 25 Nov 2026 09:01:40 +0800 Subject: [PATCH 4/4] fix(ddi): update #171 test name and route debug e2e on iOS 17-18 - Sync regression case #171 with the renamed test in ictl-device::ddi so tests/check_regression_cases.py passes. - Check the classic personalized image in debug e2e on iOS 17-18 instead of querying cryptexd. Co-Authored-By: Claude Code --- apps/iphone-control/src/debug.rs | 10 +++++++--- docs/dev/regression-cases.md | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/iphone-control/src/debug.rs b/apps/iphone-control/src/debug.rs index 0b696cb..0f67328 100644 --- a/apps/iphone-control/src/debug.rs +++ b/apps/iphone-control/src/debug.rs @@ -103,13 +103,17 @@ fn check(step: &str, t0: Instant, ok: bool, detail: String) -> anyhow::Result<() } } -async fn e2e(device: &Device, bundle_id: &str, out: &std::path::Path) -> anyhow::Result<()> { +async fn e2e(device: &Device, legacy_ddi: bool, bundle_id: &str, out: &std::path::Path) -> anyhow::Result<()> { let t = Instant::now(); let mut tunnel = device.open_tunnel().await?; check(ictl_l10n::tr!("建隧道", "open tunnel"), t, true, String::new())?; let t = Instant::now(); - let ddi = tunnel.ddi_mounted().await?; + let ddi = if legacy_ddi { + device.legacy_ddi_mounted().await?.then(|| "personalized".to_owned()) + } else { + tunnel.ddi_mounted().await? + }; check( ictl_l10n::tr!("开发者镜像", "developer disk image"), t, @@ -497,7 +501,7 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> { } Check::E2e { bundle_id, out } => { let t0 = Instant::now(); - e2e(&device, &bundle_id, &out).await?; + e2e(&device, ictl_device::ddi::legacy(info.major_version()), &bundle_id, &out).await?; println!( "{}", ictl_l10n::trf!("全部通过,总耗时 {:.1}s", "All passed in {:.1}s", t0.elapsed().as_secs_f64()) diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index 073d611..023a4a4 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -174,4 +174,4 @@ | 168 | 后台启动 WDA 不带环境变量,WDA 不设 `USE_IP` 时在手机的所有网卡上监听:手机连着 Wi-Fi 时,局域网里谁都能经 8100(没有认证)操作手机、经 9100 看画面 | 后台启动和 XCTest 启动都带 `USE_IP=127.0.0.1`;`state.json` 的 `loopback_wdas` 记下这样启动的进程,旧版本启动的(不在里面)不再接上而是重新启动 | 单测 `the_launch_environment_is_a_dictionary_of_strings`、`only_a_loopback_only_background_wda_is_attached_to_again` + 真机(USB 上 WDA 就绪、工具和控制台 MJPEG 画面照常;手机连 Wi-Fi 时从局域网另一台机器 `curl http://<手机IP>:8100/status`、`:9100` 连不上;升级前已在运行的后台 WDA 被重新启动) | | 169 | 事件日志、「上次重签」、重签完成的到期时间按 UTC 显示又不标明,东八区的用户看到的时间差 8 小时 | 显示本地时间并带时区偏移(`2026-11-24 16:08:52 +08:00`);写给旧版本读的 `last_resign` 整句照旧是 UTC | 单测 `local_time_carries_its_offset`、`resign_result_is_shown_in_the_reader_language`(在 UTC、东八区、`America/St_Johns` 下都要过) | | 170 | 更新器、后台服务、自动更新任务的报错写死英文(约 120 条),中文界面下 `iphone-control update` 和控制台更新面板显示英文 | 全部中英成对(`tr!`/`trf!`),按运行时的语言输出;`outcome.json` 的 `status` 字段不变,控制台仍按它显示状态 | 手动:`IPHONE_CONTROL_LANG=zh` 和 `en` 下各运行一次 `iphone-control update apply`(没有脚本安装记录时),报错分别是中文、英文 | -| 171 | iOS 17–18(#185,iPhone XS,iOS 18.7.12):开发者镜像经 cryptexd 挂载卡住,WDA 起不来。这些版本要经典个性化镜像,走 lockdown 的 `mobile_image_mounter` | iOS 17–18 不问 cryptexd:先 `lookup_image("Personalized")`(已挂上就不读文件;锁屏等其他错误照常报出,不当成没挂),没挂才从 `ddi/personalized/` 缓存(上游 `Xcode_iOS_DDI_Personalized`,自动下载)或 `ICTL_DDI_DIR` 取三个文件再挂;iOS 26 及以后、版本读不出(0)照旧走 cryptexd;连续挂载失败只清掉这台手机用的那份缓存 | 单测 `only_ios_17_and_18_take_the_classic_personalized_image`、`the_personalized_image_needs_its_three_files_and_sits_next_to_the_cryptex_one` + 真机(iPhone XS,iOS 18.7.12:补丁前一版挂上并起了 WDA;本版待重测) | +| 171 | iOS 17–18(#185,iPhone XS,iOS 18.7.12):开发者镜像经 cryptexd 挂载卡住,WDA 起不来。这些版本要经典个性化镜像,走 lockdown 的 `mobile_image_mounter` | iOS 17–18 不问 cryptexd:先 `lookup_image("Personalized")`(已挂上就不读文件;锁屏等其他错误照常报出,不当成没挂),没挂才从 `ddi/personalized/` 缓存(上游 `Xcode_iOS_DDI_Personalized`,自动下载)或 `ICTL_DDI_DIR` 取三个文件再挂;iOS 26 及以后、版本读不出(0)照旧走 cryptexd;连续挂载失败只清掉这台手机用的那份缓存 | 单测 `only_ios_17_and_18_take_the_personalized_image_with_its_three_files_next_to_the_cryptex_one` + 真机(iPhone XS,iOS 18.7.12:补丁前一版挂上并起了 WDA;本版待重测) |