mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 14:50:45 +00:00
== 用户要求 ==
"安卓那个逻辑也要改一下,就是你输入配对码后,进入一个页面,
页面有两个按钮,第一个按钮是远控,第二个按钮是静默更新被控端"
== 做成什么样 ==
新增 choicePanel,连接成功后先进这一页:
已连接「电脑名」
电脑端 2.1.5 → 可更新到 2.2.0
[ 远控 ] <- 第一个按钮
[ 静默更新被控端 ] <- 第二个按钮
按钮顺序按用户说的来(远控在前)。
页面顶上显示电脑名和**电脑端当前版本** —— 用户之前要求
"手表端连接那个电脑端也可以查看电脑端目前所处的版本",
这里是最自然的展示位置(不弹框,只显示一行)。
为什么不让它直接进控制页:老版本的被控端可能缺功能或有 bug,
"先更新再远控"是更合理的顺序 —— 但不强制,给用户自己选。
== 一个刻意不改的地方 ==
自动切到中转服务器**恢复**时的 `showControlPanel()` **没动** ——
用户本来就在远控页,中途弹一层选择页会打断他。
测试里专门断言了这一点,免得以后有人"顺手统一一下"改坏。
== 顺手修的几个问题 ==
1. **忘了定义 lastDeviceName** —— 写选择页时凭直觉用了这个变量,
编译报"找不到符号"。补上字段并在连接回调里赋值。
(教训:写代码时要用的变量,先确认它存在。)
2. **泄漏闸门拦下我自己** —— 这两天写的一批服务器诊断/配置脚本里
硬编码了服务器 IP(26 处,5 个文件)。规则是 IP 不能进任何
被跟踪的文件。已全部改成占位符,真实值仍从
_build/.lightsail_host(已 gitignore)读。
3. **verify_all.ps1 删掉「锁屏时记 SKIP」的逻辑** ——
用户明确要求删。那个好意带来一个更糟的后果:锁屏时几关根本不跑,
回归"全绿"了但关键测试其实一跳而过。
**"因为环境不满足所以不测"比"测了发现失败"更危险。**
删掉之后果然暴露出 3 个 FAIL —— 屏幕解锁后重跑全部通过,
确认是环境问题而不是代码问题。
== 服务器这边(不在这份提交里,但同一天做的)==
* nginx 按用户要求重排:
IP(80) 任何路径 -> 404(没东西)
域名 / -> 官网;/zhongzhuanzhan -> 中转站设置
9100 -> 同样的内容(等 AWS 开防火墙)
* 删掉早年 Cloudflare Tunnel 的 systemd 残留
* **补上 ACME 挑战例外** —— 这是最要紧的一条:
80 端口原来把所有请求都 301 到 https,包括
/.well-known/acme-challenge/,**续期时会失败**。
而且它是延迟爆发的(最长 90 天后证书到期才暴露)。
* 清理 1Panel 安装包残留(223MB)
== 验证 ==
全量回归 21 关全部 PASS(零 FAIL,桌面可用状态)
Java 编译通过(android-34, --release 8)
623+ Python 文件语法通过
泄漏闸门通过
全部产物重建,Win7 兼容校验通过
148 lines
5.3 KiB
Python
148 lines
5.3 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""检查手表 APK 是否真的把「遥控诊断」合并进去了。
|
||
|
||
合并前是两个 APK(手表端 + 独立的遥控诊断 App)。
|
||
合并后只需要一个:主程序里有「设备诊断」按钮。
|
||
|
||
这里从 APK 的 dex 和清单里核实,而不是只信源码。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
import subprocess
|
||
import sys
|
||
import tempfile
|
||
import zipfile
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parent.parent
|
||
# 别写死版本号 —— 一升级就坏(这坑踩过好几回了)。
|
||
# 直接扫 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-2.2.0.apk"
|
||
|
||
|
||
APK = _latest_apk()
|
||
DIAG_APK = ROOT / "dist" / "LanRemote-Diag-1.1.0.apk"
|
||
AAPT = (Path(r"C:\Users\shu\Desktop\deepseekagent\starklink\toolchain")
|
||
/ "android-sdk" / "build-tools" / "34.0.0" / "aapt.exe")
|
||
|
||
PASSED = 0
|
||
FAILED = 0
|
||
|
||
|
||
def check(name: str, ok: bool, detail: str = "") -> None:
|
||
global PASSED, FAILED
|
||
if ok:
|
||
PASSED += 1
|
||
print(f" [PASS] {name}")
|
||
else:
|
||
FAILED += 1
|
||
print(f" [FAIL] {name} {detail}")
|
||
|
||
|
||
def main() -> int:
|
||
print("=" * 68)
|
||
print("一、手表 APK 里有没有内置诊断")
|
||
print("=" * 68)
|
||
|
||
if not APK.is_file():
|
||
print(f" 找不到 {APK}")
|
||
print(" 请先运行 android\\build_apk.ps1")
|
||
return 1
|
||
|
||
with zipfile.ZipFile(APK) as archive:
|
||
dex = archive.read("classes.dex")
|
||
|
||
names = {item.decode() for item in
|
||
re.findall(rb"Lcom/lanremote/[A-Za-z0-9_/]+;", dex)}
|
||
print(f" dex 中的类: {len(names)} 个")
|
||
|
||
check("APK 里有 Diagnostics 类(诊断逻辑已内置)",
|
||
"Lcom/lanremote/watch/Diagnostics;" in names,
|
||
str(sorted(names)))
|
||
check("APK 里有 DiscoveryCore(诊断与主程序共用同一份发现实现)",
|
||
"Lcom/lanremote/watch/DiscoveryCore;" in names)
|
||
check("APK 里有 MainActivity", "Lcom/lanremote/watch/MainActivity;" in names)
|
||
# 注意:不能用 "diag" 做子串判断 —— Diagnostics 里也含 diag。
|
||
# 要查的是旧的独立包名 com/lanremote/diag/。
|
||
legacy = [n for n in names if n.startswith("Lcom/lanremote/diag/")]
|
||
check("不含旧的独立诊断包 com.lanremote.diag",
|
||
not legacy, str(legacy))
|
||
|
||
print()
|
||
print("=" * 68)
|
||
print("二、清单权限(诊断读 WiFi 名称需要定位权限)")
|
||
print("=" * 68)
|
||
|
||
# aapt 不认中文路径,先拷到纯 ASCII 路径
|
||
with tempfile.TemporaryDirectory() as tmp:
|
||
simple = Path(tmp) / "watch.apk"
|
||
simple.write_bytes(APK.read_bytes())
|
||
try:
|
||
proc = subprocess.run(
|
||
[str(AAPT), "dump", "badging", str(simple)],
|
||
capture_output=True, timeout=60)
|
||
badging = proc.stdout.decode("utf-8", errors="replace")
|
||
except Exception as exc: # noqa: BLE001
|
||
badging = ""
|
||
print(f" aapt 调用失败: {exc}")
|
||
|
||
if badging:
|
||
for permission, why in (
|
||
("android.permission.ACCESS_FINE_LOCATION", "读 WiFi 名称"),
|
||
("android.permission.INTERNET", "网络通信"),
|
||
("android.permission.CHANGE_WIFI_MULTICAST_STATE", "UDP 广播"),
|
||
):
|
||
check(f"声明了 {permission.split('.')[-1]}({why})",
|
||
permission in badging)
|
||
check("没有申请定位以外的敏感权限",
|
||
"READ_CONTACTS" not in badging
|
||
and "READ_SMS" not in badging
|
||
and "CAMERA" not in badging
|
||
and "RECORD_AUDIO" not in badging)
|
||
else:
|
||
check("能读取 APK 清单", False, "aapt 没有输出")
|
||
|
||
print()
|
||
print("=" * 68)
|
||
print("三、构建脚本不再依赖独立诊断 APK")
|
||
print("=" * 68)
|
||
|
||
package = (ROOT / "_build" / "package.py").read_text(encoding="utf-8")
|
||
check("package.py 不再要求 Diag APK",
|
||
"DIAG_APK" not in package, "仍引用 DIAG_APK")
|
||
check("package.py 说明里写明诊断已合并",
|
||
"合并" in package)
|
||
|
||
src = (ROOT / "android" / "src" / "com" / "lanremote" / "watch"
|
||
/ "MainActivity.java").read_text(encoding="utf-8")
|
||
# 用户要求:"安卓端中转设置下面,把那个设备诊断给删了,
|
||
# 换成输入配对码,输入对应配对码就可以连接对应电脑"
|
||
# 所以这里反过来断言:不该再有设备诊断入口,而是配对码输入。
|
||
import re as _re
|
||
code = _re.sub(r"//[^\n]*", "", src)
|
||
check("主界面不再有「设备诊断」入口", "设备诊断" not in code)
|
||
check("主界面不再调用 Diagnostics.build",
|
||
"Diagnostics.build(" not in code)
|
||
check("主界面不再调用 Diagnostics.manualTest",
|
||
"Diagnostics.manualTest(" not in code)
|
||
check("换成了「输入配对码连接」入口",
|
||
'bigButton("输入配对码连接"' in code)
|
||
check("配对码连接走中转(connectByCode)",
|
||
"private void connectByCode(" in code)
|
||
|
||
print()
|
||
print("=" * 68)
|
||
print(f"通过 {PASSED} 项,失败 {FAILED} 项")
|
||
print("=" * 68)
|
||
return 1 if FAILED else 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|