mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 13:40:45 +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 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
165 lines
5.9 KiB
Python
165 lines
5.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""彻底删掉设备诊断的全部代码。
|
|
|
|
用户要求:"安卓端中转设置下面,把那个设备诊断给删了"
|
|
|
|
上次只删了入口(openDiagPanel),面板代码还留着:
|
|
buildDiagPanel() / closeDiagPanel() / runManualDiag()
|
|
以及 diagPanel / diagText / diagStatusLine / diagIpInput / diagRunning
|
|
还有 Diagnostics.manualTest 的调用
|
|
|
|
这次连它们一起删。删完立刻编译,确认没误伤(上次删坏过字段)。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
|
|
MAIN = ROOT / "android" / "src" / "com" / "lanremote" / "watch" / "MainActivity.java"
|
|
TOOLCHAIN = Path(r"C:\Users\shu\Desktop\deepseekagent\starklink\toolchain")
|
|
|
|
|
|
def method_span(lines, start):
|
|
"""从一个方法的签名行开始,按花括号配平找结束行(含)。"""
|
|
depth = 0
|
|
seen = False
|
|
for index in range(start, len(lines)):
|
|
depth += lines[index].count("{")
|
|
if "{" in lines[index]:
|
|
seen = True
|
|
depth -= lines[index].count("}")
|
|
if seen and depth <= 0:
|
|
return index
|
|
return None
|
|
|
|
|
|
def drop_methods_touching(lines, marker: str) -> int:
|
|
"""删掉所有**方法体里**提到 marker 的方法。返回删了几个。"""
|
|
removed = 0
|
|
changed = True
|
|
while changed:
|
|
changed = False
|
|
for index, line in enumerate(lines):
|
|
stripped = line.strip()
|
|
# 只看方法签名行
|
|
if not (stripped.startswith(("private ", "public ", "protected "))
|
|
and "(" in stripped and stripped.endswith("{")):
|
|
continue
|
|
end = method_span(lines, index)
|
|
if end is None:
|
|
continue
|
|
body = "".join(lines[index:end + 1])
|
|
if marker in body:
|
|
# 往前的注释和空行一起删
|
|
start = index
|
|
while start > 0 and (lines[start - 1].strip().startswith("//")
|
|
or lines[start - 1].strip() == ""):
|
|
start -= 1
|
|
del lines[start:end + 1]
|
|
removed += 1
|
|
changed = True
|
|
break
|
|
return removed
|
|
|
|
|
|
def main() -> int:
|
|
text = MAIN.read_text(encoding="utf-8")
|
|
lines = text.splitlines(keepends=True)
|
|
|
|
# ---- 1. 删掉所有碰 diag 的方法 ----
|
|
total = 0
|
|
for marker in ("Diagnostics.manualTest", "buildDiagPanel", "diagPanel",
|
|
"diagText", "diagStatusLine", "diagIpInput", "diagRunning"):
|
|
n = drop_methods_touching(lines, marker)
|
|
if n:
|
|
print(f" 删掉 {n} 个用到 {marker} 的方法")
|
|
total += n
|
|
if not total:
|
|
print(" 没有需要删的方法")
|
|
|
|
text = "".join(lines)
|
|
|
|
# ---- 2. 删掉字段声明 ----
|
|
for field in ("private FrameLayout diagPanel;",
|
|
"private TextView diagText;",
|
|
"private TextView diagStatusLine;",
|
|
"private EditText diagIpInput;",
|
|
"private boolean diagRunning = false;"):
|
|
if field in text:
|
|
# 连同上面紧挨的注释一起删
|
|
text = re.sub(r"[ \t]*//[^\n]*\n(?=[ \t]*"
|
|
+ re.escape(field) + ")", "", text, count=1)
|
|
text = text.replace(field + "\n", "", 1)
|
|
print(f" 删掉字段 {field.split()[-1]}")
|
|
|
|
# ---- 3. onBackPressed 里的诊断分支 ----
|
|
old_back = """ if (diagPanel != null && diagPanel.getVisibility() == View.VISIBLE) {
|
|
closeDiagPanel();
|
|
return;
|
|
}
|
|
"""
|
|
if old_back in text:
|
|
text = text.replace(old_back, "", 1)
|
|
print(" 删掉 onBackPressed 里的诊断分支")
|
|
|
|
# ---- 4. 清掉只剩注释的空注释块 ----
|
|
text = text.replace(""" // ==================================================================
|
|
// 设备诊断(原来是一个单独的「遥控诊断」App,现在合并进来)
|
|
// ==================================================================
|
|
|
|
""", "")
|
|
text = re.sub(r"\n{4,}", "\n\n\n", text)
|
|
|
|
MAIN.write_text(text, encoding="utf-8", newline="\n")
|
|
|
|
# ---- 5. 编译验证 ----
|
|
print()
|
|
print(" 编译验证:")
|
|
out = ROOT / "_build" / "javacheckD"
|
|
if out.exists():
|
|
import shutil
|
|
shutil.rmtree(out, ignore_errors=True)
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
srcs = [str(p) for p in (ROOT / "android" / "src").rglob("*.java")]
|
|
import os
|
|
env = dict(os.environ)
|
|
env["JAVA_TOOL_OPTIONS"] = "-Duser.language=en -Duser.country=US"
|
|
proc = subprocess.run(
|
|
[str(TOOLCHAIN / "jdk17" / "bin" / "javac.exe"), "--release", "8",
|
|
"-encoding", "UTF-8", "-cp",
|
|
str(TOOLCHAIN / "android-sdk" / "platforms" / "android-34"
|
|
/ "android.jar"), "-d", str(out)] + srcs,
|
|
capture_output=True, text=True, encoding="utf-8", errors="replace",
|
|
env=env)
|
|
if proc.returncode == 0:
|
|
print(" ✓ 编译通过")
|
|
else:
|
|
print(" ✗ 编译失败:")
|
|
for line in (proc.stdout + proc.stderr).splitlines():
|
|
if "error" in line or "symbol" in line:
|
|
print(f" {line.strip()[:100]}")
|
|
|
|
# ---- 6. 残余 ----
|
|
print()
|
|
print(" 残余检查:")
|
|
left = MAIN.read_text(encoding="utf-8")
|
|
for name in ("diagPanel", "diagText", "diagStatusLine", "diagIpInput",
|
|
"diagRunning", "buildDiagPanel", "closeDiagPanel",
|
|
"Diagnostics.", "设备诊断"):
|
|
count = left.count(name)
|
|
if count:
|
|
print(f" [{name}] 还有 {count} 处")
|
|
if not any(left.count(n) for n in
|
|
("diagPanel", "diagText", "diagStatusLine", "diagIpInput",
|
|
"diagRunning", "buildDiagPanel", "closeDiagPanel",
|
|
"Diagnostics.")):
|
|
print(" 没有残余 ✓")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|