From 317bd3020d5ebe41e56d0a28d314c98b8e56b00a Mon Sep 17 00:00:00 2001 From: yuming Date: Fri, 18 Sep 2026 21:22:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=B0=B1=E6=BB=9A=E5=8A=A8=E5=AF=BC=E8=87=B4=E6=BC=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:旧逻辑等30秒就超时,重试点击一次后再等30秒就滚动。 大文件30秒下不完,队列满时重试点击无效,导致卡片漏下载。 修复: - max_wait_per_round 从30秒增加到120秒 - 等待逻辑改为三轮:先等120s→再等120s→重试点击→再等120s - 总最长等待6分钟,足够6个小文件全部下载完 - 队列满时不立即重试点击,先让正在下载的完成腾出位置 --- automate.py | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/automate.py b/automate.py index 6bac8be..28178d8 100644 --- a/automate.py +++ b/automate.py @@ -544,7 +544,7 @@ def get_remote_new_file_count(baseline_files): return len(all_files - baseline_files) -def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_round=30): +def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_round=120): """循环:点击固定网格 9 个卡片(点击即下载)→ 轮询确认下载数量稳定 → 滚动 2 行。 新版 UI(7.8.1)自绘,dump 拿不到缩略图 bounds,改用固定网格坐标 THUMB_X x THUMB_Y。 首次点击卡片会弹"使用手机网络下载将消耗流量"确认框,点确定后补点一次该卡片。 @@ -747,29 +747,40 @@ def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_r done = len(tapped_cells) - len(pending) total = get_remote_new_file_count(baseline) if pending: - # 超时未打勾的卡片,先重试点击一次:可能是点击落在卡片间隙/分组标签上 - # 没生效(下载根本没触发),而不是下载慢。之前直接滚动会导致这些卡片 - # 永远漏下载。重试后仍超时才滚动,靠下游 MD5 查重兜底重复。 - print(f" 轮 {r+1}: 等待 {waited}s 超时,{done}/{len(tapped_cells)} 个已打勾," - f"仍有 {len(pending)} 个未完成,重试点击未完成的卡片...") - for (gx, cy) in pending: - adb("shell", "input", "tap", str(gx), str(cy)) - time.sleep(0.5) - # 重试后再等一轮 - retry_waited = 0 - while retry_waited < max_wait_per_round: + # 超时未打勾:先不重试点击(队列满时重试无效),再等一轮让正在下载的完成 + print(f" 轮 {r+1}: 等待 {waited}s 后 {done}/{len(tapped_cells)} 个已打勾," + f"仍有 {len(pending)} 个未完成,继续等待一轮...") + wait2_waited = 0 + while wait2_waited < max_wait_per_round: time.sleep(poll_interval) - retry_waited += poll_interval + wait2_waited += poll_interval ensure_not_anr() - retry_shot = screenshot("/tmp/_retrywait.png") - retry_chk = get_checked_cells_dynamic(retry_shot, row_centers) - still_pending = [c for c in pending if not retry_chk.get(c)] + w2_shot = screenshot("/tmp/_wait2.png") + w2_chk = get_checked_cells_dynamic(w2_shot, row_centers) + still_pending = [c for c in pending if not w2_chk.get(c)] if not still_pending: break if still_pending: - print(f" 轮 {r+1}: 重试后仍有 {len(still_pending)} 个未完成,照常滚动(靠下游去重兜底)") + # 两轮等待后仍未打勾,可能是点击没生效(落在间隙上)或队列满被拒绝 + # 再重试点击一次,然后等最后一轮 + print(f" 轮 {r+1}: 再等 {wait2_waited}s 后仍有 {len(still_pending)} 个未完成,重试点击...") + for (gx, cy) in still_pending: + adb("shell", "input", "tap", str(gx), str(cy)) + time.sleep(0.5) + retry_waited = 0 + while retry_waited < max_wait_per_round: + time.sleep(poll_interval) + retry_waited += poll_interval + ensure_not_anr() + retry_shot = screenshot("/tmp/_retrywait.png") + retry_chk = get_checked_cells_dynamic(retry_shot, row_centers) + still_pending = [c for c in still_pending if not retry_chk.get(c)] + if not still_pending: + break + if still_pending: + print(f" 轮 {r+1}: 三轮等待后仍有 {len(still_pending)} 个未完成,照常滚动(靠下游去重兜底)") else: - print(f" 轮 {r+1}: 重试后全部打勾完成") + print(f" 轮 {r+1}: 全部打勾完成") else: print(f" 轮 {r+1}: {len(tapped_cells)} 个全部打勾完成(等待 {waited}s),累计新下载 {total} 个,开始滚动") else: