diff --git a/app/src/main/java/com/haorui/app/crossplatform/source/douyin/DouyinDevicePort.kt b/app/src/main/java/com/haorui/app/crossplatform/source/douyin/DouyinDevicePort.kt index 1f41720..c320d90 100644 --- a/app/src/main/java/com/haorui/app/crossplatform/source/douyin/DouyinDevicePort.kt +++ b/app/src/main/java/com/haorui/app/crossplatform/source/douyin/DouyinDevicePort.kt @@ -601,11 +601,32 @@ internal class DouyinDevicePort( } /** - * 分享面板功能行翻页(e2e 第四轮实锤:手势横滑页码不动——微博 e35 同款坑, - * 手势易被面板误判为拖拽关闭)。首选无障碍原生滚动(面板内 y>1400 的 - * isScrollable 容器 ACTION_SCROLL_FORWARD),失败退化横滑手势。 + * 分享面板功能行翻页(R5/R6 实锤链): + * - 手势横滑(adb input swipe 同参)真机验证可行,GestureRunner 派发待验证; + * - 原生滚动 ACTION_SCROLL_FORWARD 返回 true 但滚错容器(好友列表),**不可信**; + * - 第二页按钮不在第一页树里(R6 取证证伪离屏预渲染)。 + * 策略:手势横滑 → **翻页验证闭环**(树 text 集出现新按钮=成功);未翻页重试一次; + * 全部失败才退原生滚动(知道它不可信,仅兜底记录)。 */ private fun swipePanelRowForward(): Boolean { + fun panelTexts(): Set = + tree()?.selfAndDescendants()?.mapNotNull { it.text.takeIf { t -> t.isNotBlank() } }?.toSet() ?: emptySet() + + val before = panelTexts() + for (attempt in 1..2) { + val swiped = runCatching { + kotlinx.coroutines.runBlocking { service.gestures.swipe(0.833f, 0.868f, 0.185f, 0.868f) } + }.getOrDefault(false) + Thread.sleep(1_200) + val after = panelTexts() + val changed = before.isNotEmpty() && after.isNotEmpty() && (after - before).isNotEmpty() + if (swiped && changed) { + log("面板功能行:手势翻页成功(第 $attempt 次,新增按钮=${(after - before).take(3)})") + return true + } + log("面板功能行:手势第 $attempt 次 派发=$swiped 页面变化=$changed") + } + // 兜底:原生滚动(R5 实锤滚错容器,返回值不可信,仅当最后的尝试) val root = service.root() if (root != null) { var visited = 0 @@ -628,17 +649,16 @@ internal class DouyinDevicePort( } finally { runCatching { target.recycle() } } - if (ok) { - log("面板功能行:原生滚动成功") + Thread.sleep(1_200) + val after = panelTexts() + if ((after - before).isNotEmpty()) { + log("面板功能行:原生滚动翻页成功") return true } + log("面板功能行:原生滚动 performAction=$ok 但页面未变(滚错容器实锤)") } } - val swiped = runCatching { - kotlinx.coroutines.runBlocking { service.gestures.swipe(0.833f, 0.868f, 0.185f, 0.868f) } - }.getOrDefault(false) - log("面板功能行:原生滚动不可用,手势横滑=$swiped") - return swiped + return false } override fun saveLocalFromSharePanel(): DouyinHotListCollector.SaveLocalOutcome {