mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 21:50:44 +00:00
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
121 lines
4.2 KiB
Python
121 lines
4.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Activity 骨架必须完整(防"白屏"这类事故)。
|
|
|
|
为什么要单独一个测试:
|
|
我删诊断代码时,脚本是"方法体里出现标记就删掉整个方法"。
|
|
onCreate 里调了 buildDiagPanel(),于是**整个 onCreate 被删了**。
|
|
|
|
它照样编译通过(Activity.onCreate 不是抽象方法),
|
|
回归也全绿,但 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 body_of(src: str, signature: str) -> str:
|
|
"""取出某个方法的完整方法体(花括号配平)。"""
|
|
index = src.find(signature)
|
|
if index < 0:
|
|
return ""
|
|
start = src.find("{", index)
|
|
if start < 0:
|
|
return ""
|
|
depth = 0
|
|
for pos in range(start, len(src)):
|
|
if src[pos] == "{":
|
|
depth += 1
|
|
elif src[pos] == "}":
|
|
depth -= 1
|
|
if depth == 0:
|
|
return src[start:pos + 1]
|
|
return ""
|
|
|
|
|
|
def main() -> int:
|
|
src = MAIN.read_text(encoding="utf-8")
|
|
|
|
print("一、Activity 生命周期骨架")
|
|
check("有 onCreate", "protected void onCreate(Bundle" in src)
|
|
check("有 onDestroy", "protected void onDestroy()" in src)
|
|
|
|
create = body_of(src, "protected void onCreate(Bundle")
|
|
check("onCreate 有方法体", bool(create), len(create))
|
|
if create:
|
|
check("调了 super.onCreate", "super.onCreate(" in create)
|
|
check("**调了 setContentView**(不调就是白屏)",
|
|
"setContentView(" in create, "白屏的直接原因")
|
|
check("建了 root 容器", "root = new FrameLayout" in create)
|
|
check("建了连接页", "buildConnectPanel()" in create)
|
|
check("建了控制页", "buildControlPanel()" in create)
|
|
check("建了镜像页", "buildMirrorPanel()" in create)
|
|
check("初始化了 store", "new DeviceStore(" in create)
|
|
check("初始化了 ui 线程 Handler", "new Handler(" in create)
|
|
check("初始化了 client", "new RemoteClient(" in create)
|
|
check("装了崩溃兜底", "installCrashGuard()" in create)
|
|
check("装了崩溃兜底在 ui 之后(否则 NPE)",
|
|
create.find("new Handler(") < create.find("installCrashGuard()"),
|
|
"顺序")
|
|
|
|
print()
|
|
print("二、三个面板都有创建方法")
|
|
for name in ("private void buildConnectPanel()",
|
|
"private void buildControlPanel()",
|
|
"private void buildMirrorPanel()"):
|
|
check(f"{name[13:-3]} 存在", name in src)
|
|
|
|
print()
|
|
print("三、关键字段都有赋值(不只是声明)")
|
|
for field, pattern in (
|
|
("store", r"\bstore\s*=\s*new DeviceStore"),
|
|
("ui", r"\bui\s*=\s*new Handler"),
|
|
("client", r"\bclient\s*=\s*new RemoteClient"),
|
|
("root", r"\broot\s*=\s*new FrameLayout")):
|
|
check(f"{field} 被赋值", bool(re.search(pattern, src)))
|
|
|
|
print()
|
|
print("四、打包后的 APK 里 Activity 类在")
|
|
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()
|
|
check("classes.dex 在", "classes.dex" in names)
|
|
check("AndroidManifest.xml 在", "AndroidManifest.xml" in names)
|
|
check("dex 不是空的",
|
|
archive.getinfo("classes.dex").file_size > 100000,
|
|
archive.getinfo("classes.dex").file_size)
|
|
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())
|