Files
ShortX_ToolHub/code/th_10_shell.js
root 9b07a888a5 chore: bump version for shell refactor (1.0.0 -> 1.0.1)
- th_01_base.js: 1.0.1 (Base64 decode comment cleanup)
- th_10_shell.js: 1.0.1 (remove Action-first path, keep only broadcast bridge)
- th_11_action.js: 1.0.1 (toast msg update)
- ToolHub.js: MODULE_MANIFEST synced
2026-04-20 12:32:55 +08:00

29 lines
1.1 KiB
JavaScript
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.
// @version 1.0.1
// =======================【Shell广播桥执行】======================
// 仅通过广播桥发送 shell 命令,由外部接收器实际执行。
// 注意system_server 进程本身不直接执行 shell。
FloatBallAppWM.prototype.execShellSmart = function(cmdB64, needRoot) {
var ret = { ok: false, via: "", err: "" };
try {
var action = String(this.config.SHELL_BRIDGE_ACTION || CONST_SHELL_BRIDGE_ACTION || "shortx.toolhub.SHELL");
var it = new android.content.Intent(action);
// 广播协议cmd_b64 + root + from
it.putExtra(CONST_SHELL_BRIDGE_EXTRA_CMD, String(cmdB64));
it.putExtra(CONST_SHELL_BRIDGE_EXTRA_ROOT, !!needRoot);
it.putExtra(CONST_SHELL_BRIDGE_EXTRA_FROM, "ToolHub");
context.sendBroadcast(it);
ret.ok = true;
ret.via = "BroadcastBridge";
safeLog(this.L, 'i', "shell via broadcast ok action=" + action + " root=" + String(!!needRoot));
} catch (eB) {
ret.err = "Broadcast err=" + String(eB);
safeLog(this.L, 'e', "shell via broadcast fail err=" + String(eB));
}
return ret;
};