diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f69fbe..752cdfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ What changed in each release, one line per change. Versions follow [Semantic Ver ### Fixes - With native control (iOS 27), reading the screen no longer keeps failing until the phone is replugged when the phone's accessibility service stops answering; it is restarted on its own (#152). +- With native control (iOS 27), automatic unlocking no longer fails with "couldn't bring up the passcode keypad" while the keypad is on screen: the keys it tapped were sometimes not taken by the phone. ## [0.2.8] - 2026-11-18 diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e52c0fa..daeed3f 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -9,6 +9,7 @@ ### 修复 - 原生控制(iOS 27)下,手机上的无障碍服务不再应答时,读界面不会再一直失败到重新插线为止;会自动把它重启(#152)。 +- 原生控制(iOS 27)下,自动解锁不会再在密码键盘已经出来时报「调不出锁屏密码键盘」:点下去的数字键有时没被手机认。 ## [0.2.8] - 2026-11-18 diff --git a/crates/ictl-daemon/src/tools/native.rs b/crates/ictl-daemon/src/tools/native.rs index 2f60b13..4c54c1c 100644 --- a/crates/ictl-daemon/src/tools/native.rs +++ b/crates/ictl-daemon/src/tools/native.rs @@ -791,9 +791,13 @@ struct NativeScreen<'a> { /// Reads the lock screen: with the HID session's screen stream open, the phone hides the lock screen and its /// passcode keypad from accessibility (one element, the app's, for every session; iPhone 15 Pro Max, iOS 27.2.1), so -/// the session is closed first, and the elements come back a moment after. The next tap opens it again (about 0.5 s) +/// the session is closed first, and the elements come back a moment after. The next tap opens it again (about 0.5 s). +/// Not before the last touch has landed ([`TOUCH_LANDS`]) async fn read_lock_screen(d: &Daemon, g: &mut Inner) -> crate::error::Result<(String, ScreenSize, i64)> { let was_open = g.tunnel.as_ref().is_some_and(ictl_device::Tunnel::hid_open); + if was_open && let Some(left) = touch_lands_in(g.hid_used.map(|t| t.elapsed())) { + tokio::time::sleep(left).await; + } crate::core::close_hid(g).await; let t0 = Instant::now(); loop { @@ -810,6 +814,19 @@ async fn read_lock_screen(d: &Daemon, g: &mut Inner) -> crate::error::Result<(St } } +/// A touch sent over HID doesn't count when its session closes right after it: the passcode keypad came up, but no +/// key went down and the field stayed at 0 digits, so unlocking failed with "couldn't bring up the keypad" (or +/// stopped at the 2nd or 3rd digit). Not every time: the same phone unlocked with no wait for hours, then lost +/// every key. Unlocks while it lost them, by how long the session stayed open after the touch (iPhone19,7, +/// iOS 27.2.1, one daemon, the waits taken in turn): 0 ms 0 of 9, 50 ms 0 of 3, 100 ms 0 of 3, 150 ms 1 of 3, +/// 200 ms 3 of 4, 250 ms 5 of 5, 350 ms 3 of 3. An unlock takes about 1.5 s longer for it (8.3 s without) +const TOUCH_LANDS: Duration = Duration::from_millis(350); + +/// How much longer the HID session has to stay open for the last touch sent over it to count, `since` it was sent +fn touch_lands_in(since: Option) -> Option { + TOUCH_LANDS.checked_sub(since?).filter(|d| !d.is_zero()) +} + /// How long after the HID session closes the lock screen's elements may take to come back const LOCK_SCREEN_BACK: Duration = Duration::from_secs(3); @@ -887,6 +904,18 @@ impl Screen for NativeScreen<'_> { mod tests { use super::*; + /// The HID session isn't closed right after a touch (the phone takes the touch back): the rest of + /// `TOUCH_LANDS` is waited out first, and nothing when no touch was sent or it was long enough ago + #[test] + fn the_hid_session_stays_open_until_the_last_touch_has_landed() { + let ms = Duration::from_millis; + assert_eq!(touch_lands_in(Some(ms(0))), Some(TOUCH_LANDS)); + assert_eq!(touch_lands_in(Some(ms(100))), Some(TOUCH_LANDS - ms(100))); + assert_eq!(touch_lands_in(Some(TOUCH_LANDS)), None); + assert_eq!(touch_lands_in(Some(ms(5000))), None); + assert_eq!(touch_lands_in(None), None); + } + fn info(version: &str) -> DeviceInfo { DeviceInfo { udid: "u".into(), diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index 0b4e857..cd73c2f 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -159,3 +159,4 @@ | 153 | 第一次启动系统 App(备忘录、提醒事项)时,系统先在另一个进程(`com.apple.PDUIApp`)里显示隐私说明页盖在上面;`/wda/apps/launch` 要等 XCTest 看到 App 到前台,一直等到 60 秒超时,接着 WDA 被判卡死重启,`iphone_launch_app` 报超时(65 秒) | 先用 `/wda/apps/launchUnattached`(不经 XCTest,发出就返回),再照旧轮询前台:前台是隐私说明页就马上报「被挡住」,结果和权限弹窗一样提示先点它的按钮;它回「failed to launch」时说明页已经出来,照样往下查;旧版 WDA 没有这个接口时退回 `/wda/apps/launch` | 单测 `a_first_launch_privacy_notice_is_reported_at_once`、`an_older_wda_without_unattached_launch_launches_as_before`、`other_launch_errors_are_errors` + 真机(iPhone 12 mini,iOS 26.4.1:没打开过的「备忘录」0.7 秒返回、WDA 不重启,0.2.7 是 65 秒并重启 WDA;冷启动「时钟」后马上点标签页照常点中)| | 154 | `iphone_tap_element` 没找到(或序号超出、整个被盖住)时什么都没点,带 `then` 却先等界面稳定 0.7~0.8 秒,再拿它点之前读的树比较,说「界面和操作前一样:操作可能没生效(点在了空白处…),不要原样再做一遍」,好像点过了 | 没点就清掉「操作前的界面」,不做比较;MCP 端看到没点到东西时不等稳定,直接用按名字点击刚读的树列元素或截图 | 真机(iPhone 12 mini,iOS 26.4.1:设置里按不存在的文字点,带 `then=elements` 和 `then=screenshot`,0.2.7 是 1.3~1.45 秒带那句提示,本分支 0.6~0.9 秒不带;只换守护进程(旧 MCP)时仍等稳定但也不带;按存在的文字点照常等稳定、说界面变了)| | 155 | 原生控制(iOS 27):手机上的 axauditd(remoteAXService 背后的进程)卡住后,每次读界面都超时(先 `remoteAXService: request`,之后每次握手 `deviceAPIVersion`),守护进程一直「准备手机失败,稍后重试」,重连、重建隧道、重启守护进程都没用,只有重新插线才恢复。iPhone 15 Pro Max(iOS 27.2.1)上见过三次:两次在部署重启守护进程后,一次在自动解锁后。2026-11-18 排查:只在锁屏键按下后马上读界面时出现(完整场景回归里约 35 次锁屏碰上 2 次),卡住前 axauditd 不报错、日志停住 8 秒,像在等一个不回的应答;没能复现的有:客户端请求中途断开或不发 clientNeedsAccessibility: false(10 次)、40 个半开连接加 48 次切换 App、锁屏状态下重启守护进程(5 次)、锁屏前后每 0.1 秒读一次(20 轮,带或不带 SpringBoard 的元素)。根因在 axauditd 内部,要抓它卡住时的调用栈(sysdiagnose)才看得到 | 无障碍服务不应答单独成一种错误(`DeviceError::AxUnanswered`,文字同超时);读界面、读前台 App 碰到它时经 CoreDevice 结束 axauditd(下次连接系统自动拉起),再读一次;同一台设备一分钟内最多一次,事件日志记「已重启手机上的 axauditd」 | 单测 `an_unanswered_accessibility_service_is_told_apart_and_reads_as_a_timeout`、`only_axauditd_is_the_accessibility_daemon` + 真机(经 AppService 给 axauditd 发 SIGSTOP 冻住:main 上一直报超时,修复后下一次读界面直接成功、axauditd 换了进程号) | +| 156 | 原生控制(iOS 27):自动解锁时密码键盘出来了,却一位都输不进去,三轮后报「调不出锁屏密码键盘」(偶尔停在第 2、3 位)。每点一个数字键就要读密码栏,读之前得先关 HID 会话(开着时手机不让无障碍服务看锁屏);点完马上关,手机不认这次触摸。时有时无:同一台手机(iPhone19,7,iOS 27.2.1)不等也能解锁了几个小时,之后每一下都丢 | 关 HID 会话前,等上一次 HID 操作发出满 `TOUCH_LANDS`(0.35 秒)。丢键期间同一个守护进程里轮流量的解锁成功数:0 毫秒 0/9,50 毫秒 0/3,100 毫秒 0/3,150 毫秒 1/3,200 毫秒 3/4,250 毫秒 5/5,350 毫秒 3/3 | 单测 `the_hid_session_stays_open_until_the_last_touch_has_landed` + 真机脚本 `scenarios.py lock` |