mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 23:00:44 +00:00
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞 - 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀? 鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException - 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴? 鏈嶅姟鍣ㄧ - 鏀寔 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())
|