Files
ykxmz/_tests/test_watch_relayonly.py
T
xmz7891 b62ac865ea ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端
- 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%)
- 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败)
- 每分钟回头找局域网,自动切回快 400 倍的路径
- 画面心跳帧:静止时省流量,客户端仍知道流是活的
- 锁屏时给出可操作的提示

手表端
- 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException
- 连接错误翻译成人话(证书/时间/解析/超时分别提示)
- 经中转连上后用服务器报的地址刷新已配对记录
- 新增局域网连接页面、服务器延迟检测

服务器端
- 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502)
- 网络调优脚本 net-tune.sh(开机自动应用)
- 管理页:批量删除、网络体检、下载区
- 隧道改 HTTP/2 + 双连接

文档
- 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
2026-10-06 19:01:05 +08:00

127 lines
5.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""断言安卓端这次改造到位了。
用户要求:
1. 中转设置下面,删掉「设备诊断」,换成「输入配对码连接」
2. 局域网那套东西(搜索/手动填 IP)都删掉
3. 图标换成作者给的图
这个测试是源码级 + 产物级断言。
配合 verify_all 里的"手表 App 整体编译",
能挡住"删代码删坏了字段"这类事故。
"""
from __future__ import annotations
import re
import sys
import zipfile
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
WATCH = ROOT / "android" / "src" / "com" / "lanremote" / "watch"
MAIN = WATCH / "MainActivity.java"
passed = 0
failed = 0
def check(name, ok, detail=""):
global passed, failed
if ok:
passed += 1
print(" [PASS] " + name)
else:
failed += 1
print(" [FAIL] " + name + " " + str(detail))
def main() -> int:
src = MAIN.read_text(encoding="utf-8")
# 去掉注释再查(注释里会提到这些名字)
code = re.sub(r"//[^\n]*", "", src)
code = re.sub(r"/\*.*?\*/", "", code, flags=re.S)
print("一、设备诊断已移除")
check("没有 openDiagPanel 的定义", "private void openDiagPanel" not in code)
check("没有 openDiagPanel 的调用", "openDiagPanel(" not in code)
check("首页没有「设备诊断」按钮",
'bigButton("连不上?点这里诊断"' not in code)
check("没有「点这里诊断」字样", "点这里诊断" not in code)
print()
print("二、局域网入口按新设计存在(但不再是旧交互)")
# 注意:早期这里断言的是"局域网那套已清掉",
# 那是用户要求删除时的版本。后来用户又要求把局域网连接加回来
# (首页 -> 局域网连接页面 -> 搜索/直连),所以这些断言反过来了。
check("首页有局域网入口",
'bigButton("局域网连接(同一个 WiFi)"' in code)
check("有独立的局域网页面", "private void buildLanPanel()" in code)
check("页面里能广播搜索", "Discovery.search(" in code)
check("用 DiscoveryCore 的结果类型", "DiscoveryCore.Found" in code)
# 局域网页面里**本来就该有**搜索按钮,所以不能断言"全代码没有"。
# (我一开始就是这么写错的。)
check("局域网页面里有搜索按钮",
'bigButton("自动搜索电脑"' in code)
# 旧交互确实不该再有:手动输入地址那一套
check("没有旧的手动输入地址按钮",
'bigButton("手动输入地址"' not in code)
check("没有 toggleManual(旧交互)", "toggleManual" not in code)
check("首页没有裸的 hostInput", "hostInput" not in code)
print()
print("三、换成了「输入配对码连接」")
check("有按钮", 'bigButton("输入配对码连接"' in code)
check("有 promptPairingCode 定义",
"private void promptPairingCode()" in code)
check("有 connectByCode 定义", "private void connectByCode(" in code)
check("点按钮会开输入框", "promptPairingCode();" in code)
check("校验必须是 6 位数字", "\\\\d{6}" in code or "\\d{6}" in code)
check("没填中转地址时会引导去设置",
"请先在「中转设置」里填服务器地址" in code)
print()
print("四、关键字段还在(防删代码时误伤)")
for field in ("busy", "mirrorStreaming", "incoming", "incomingName",
"gridColumns", "cellHeightDp", "cellTextSp", "cellQueue",
"logBuffer", "frameCount", "currentFps", "fpsWindowStart"):
declared = bool(re.search(
r"(private|volatile|final)[^;\n]*\b" + field + r"\b\s*(=|;|,)", code))
check(f"字段 {field} 有声明", declared)
print()
print("五、图标换成了作者给的图")
ico = ROOT / "windows" / "app.ico"
check("windows/app.ico 存在", ico.is_file())
if ico.is_file():
# 旧图标是 12KB 左右(自己画的),新图标带照片会大很多
check("图标是新的(不是原来那个自绘的)",
ico.stat().st_size > 50000, f"{ico.stat().st_size} 字节")
for folder in ("drawable-mdpi", "drawable-hdpi", "drawable-xhdpi",
"drawable-xxhdpi", "drawable-xxxhdpi"):
path = ROOT / "android" / "res" / folder / "ic_launcher.png"
check(f"安卓图标 {folder} 存在", path.is_file())
old_xml = ROOT / "android" / "res" / "drawable" / "ic_launcher.xml"
check("旧的矢量图标已删除", not old_xml.is_file())
print()
print("六、APK 里带上了新图标")
apks = sorted((ROOT / "dist").glob("*watch*.apk"),
key=lambda p: p.stat().st_mtime, reverse=True)
if apks:
with zipfile.ZipFile(apks[0]) as archive:
names = archive.namelist()
icons = [n for n in names if "ic_launcher" in n]
check(f"APK 里有图标资源({len(icons)} 个)", bool(icons),
names[:6])
else:
check("找到 APK", False, "dist 里没有 watch apk")
print()
print("=" * 62)
print(f"通过 {passed} 项,失败 {failed} 项")
return 0 if failed == 0 else 1
if __name__ == "__main__":
raise SystemExit(main())