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

155 lines
5.9 KiB
Python

# -*- coding: utf-8 -*-
"""手表端接上两个新功能:
* 「音色」 —— 拉取电脑上的 TTS 音色列表,选一个作为默认
* 「电脑音乐」—— 拉取电脑音乐目录里的音频文件,选一个直接播放
"""
from __future__ import annotations
import sys
from pathlib import Path
MAIN = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\android\src"
r"\com\lanremote\watch\MainActivity.java")
OLD_ROW = ''' addRow(grid,
action("语音播报", new Runnable() {
public void run() { promptSay(); }
}),
action("弹通知", new Runnable() {
public void run() { promptNotify(); }
}));
'''
NEW_ROW = ''' addRow(grid,
action("语音播报", new Runnable() {
public void run() { promptSay(); }
}),
action("音色", new Runnable() {
public void run() { pickVoice(); }
}));
addRow(grid,
action("电脑音乐", new Runnable() {
public void run() { pickLocalAudio(); }
}),
action("弹通知", new Runnable() {
public void run() { promptNotify(); }
}));
'''
ANCHOR = ''' private void promptSay() {'''
NEW_METHODS = ''' /** 选择电脑上的 TTS 音色。 */
private void pickVoice() {
statusView.setText ? statusView.setText("正在获取电脑音色…") : null;
appendLog("获取电脑音色列表");
io.execute(new Runnable() {
@Override
public void run() {
final Map<String, Object> reply = call({"cmd": "voice_list"});
final List<String> voices = strList(reply, "voices");
runOnUiThread(new Runnable() {
@Override
public void run() {
if (voices.isEmpty()) {
toast("电脑上没读到音色(或没连接)");
return;
}
List<String> labels = new ArrayList<String>();
labels.add("系统默认");
labels.addAll(voices);
showChooser("选择播报音色", labels, new Chooser() {
@Override
public void onPick(int index) {
String chosen = index == 0 ? "" : voices.get(index - 1);
Map<String, Object> request = new HashMap<String, Object>();
request.put("cmd", "set_voice");
request.put("voice", chosen);
send(request, "设置音色");
}
});
}
});
}
});
}
/** 播放电脑音乐目录里的某个文件。 */
private void pickLocalAudio() {
statusView.setText ? statusView.setText("正在获取电脑音乐…") : null;
appendLog("获取电脑音乐列表");
io.execute(new Runnable() {
@Override
public void run() {
final Map<String, Object> reply = call({"cmd": "audio_list"});
final List<String> names = strList(reply, "names");
final List<String> paths = strList(reply, "paths");
runOnUiThread(new Runnable() {
@Override
public void run() {
if (names.isEmpty()) {
toast("电脑音乐目录里没有音频文件");
return;
}
showChooser("选择要播放的音乐", names, new Chooser() {
@Override
public void onPick(int index) {
Map<String, Object> request = new HashMap<String, Object>();
request.put("cmd", "play_local");
request.put("path", paths.get(index));
send(request, "播放 " + names.get(index));
}
});
}
});
}
});
}
private void promptSay() {'''
DIALOG_ANCHOR = ''' private Button bigButton(String text, int color, float sizeSp) {'''
DIALOG = ''' /** 简单的列表选择框。 */
private interface Chooser {
void onPick(int index);
}
private void showChooser(String title, List<String> items, final Chooser chooser) {
final String[] array = items.toArray(new String[0]);
new android.app.AlertDialog.Builder(this)
.setTitle(title)
.setItems(array, new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(android.content.DialogInterface dialog, int which) {
chooser.onPick(which);
}
})
.setNegativeButton("取消", null)
.show();
}
private Button bigButton(String text, int color, float sizeSp) {'''
def main() -> int:
text = MAIN.read_text(encoding="utf-8")
ok = True
for old, new, tag in ((OLD_ROW, NEW_ROW, "按钮"),
(ANCHOR, NEW_METHODS, "处理方法"),
(DIALOG_ANCHOR, DIALOG, "选择框")):
if old not in text:
print(f" [失败] {tag} 锚点未匹配")
ok = False
else:
text = text.replace(old, new, 1)
print(f" {tag}: OK")
if ok:
MAIN.write_text(text, encoding="utf-8")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())