Files
ykxmz/_build/rename_apk.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

105 lines
3.7 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 -*-
"""把 APK 名字统一成 ykxmz-watch,并修掉测试里的硬编码旧名。
用户要求:"名字不要带中文,就 ykxmz"
APK 现在叫 LanRemote-Watch-1.4.0.apk —— 是新名之前留下的,
和 ykxmz 不一致。改成 ykxmz-watch-1.4.0.apk。
顺带:
* test_apk_contents.py 里硬编码了 1.3.0,改成跟着版本走
* 两个测试都改成"扫 dist 目录找最新 apk",别再写死版本号
(写死的老是升级一次就坏一次,已经踩过好几回了)
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
BUILD = ROOT / "android" / "build_apk.ps1"
PKG = ROOT / "_build" / "package_remote.py"
APK_TEST = ROOT / "_tests" / "test_apk_contents.py"
NEW_NAME = "ykxmz-watch-1.4.0.apk"
def main() -> int:
ok = True
# ---------- 1. build_apk.ps1(保持 BOM)----------
raw = BUILD.read_bytes()
had_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
old = '$apkName = "LanRemote-Watch-1.4.0.apk"'
new = '$apkName = "ykxmz-watch-1.4.0.apk"'
if old in text:
text = text.replace(old, new, 1)
BUILD.write_bytes((b"\xef\xbb\xbf" if had_bom else b"")
+ text.replace("\r\n", "\n").encode("utf-8"))
print(f" build_apk.ps1: APK 改名(BOM {'保留' if had_bom else '无'})")
elif new in text:
print(" build_apk.ps1: 已经是新名")
else:
print(" [失败] build_apk.ps1 找不到 apkName")
ok = False
# ---------- 2. package_remote.py ----------
text = PKG.read_text(encoding="utf-8")
old = 'APK_SRC = ROOT / "dist" / f"LanRemote-Watch-{VERSION}.apk"'
new = 'APK_SRC = ROOT / "dist" / f"ykxmz-watch-{VERSION}.apk"'
if old in text:
text = text.replace(old, new, 1)
PKG.write_text(text, encoding="utf-8", newline="\n")
print(" package_remote.py: APK 路径已更新")
elif new in text:
print(" package_remote.py: 已经是新名")
else:
print(" [警告] package_remote.py 里没找到 APK_SRC")
# ---------- 3. test_apk_contents.py ----------
text = APK_TEST.read_text(encoding="utf-8")
old = 'APK = ROOT / "dist" / "LanRemote-Watch-1.3.0.apk"'
new = '''# 别写死版本号 —— 一升级就坏(这坑踩过好几回了)。
# 直接扫 dist 里最新的手表 APK。
def _latest_apk() -> Path:
candidates = sorted(
(ROOT / "dist").glob("*watch*.apk"),
key=lambda p: p.stat().st_mtime, reverse=True)
return candidates[0] if candidates else \\
ROOT / "dist" / "ykxmz-watch-1.4.0.apk"
APK = _latest_apk()'''
if old in text:
text = text.replace(old, new, 1)
APK_TEST.write_text(text, encoding="utf-8", newline="\n")
print(" test_apk_contents.py: 改成动态找最新 APK")
else:
print(" [警告] test_apk_contents.py 锚点没找到")
# ---------- 4. 语法 ----------
import ast
for label, path in (("package_remote.py", PKG),
("test_apk_contents.py", APK_TEST)):
try:
ast.parse(path.read_text(encoding="utf-8"))
print(f" {label} 语法 OK")
except SyntaxError as exc:
print(f" {label} 语法错误: {exc}")
ok = False
# ---------- 5. 删掉旧的 1.4.0 apk ----------
for stale in ("LanRemote-Watch-1.4.0.apk",
"LanRemote-Watch-1.4.0.apk.idsig"):
path = ROOT / "dist" / stale
if path.exists():
path.unlink()
print(f" 删掉旧文件 {stale}")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())