Feature: Support the remote terminal on Android hosts
The terminal tools were Windows/Linux only because the Android client had no COMMAND_SHELL handler: the server opened a shell sub-connection and the command was silently dropped, leaving exec_command to time out. This adds the PTY path on the client and the matching server gating. Client: COMMAND_SHELL on the main connection spawns a terminal thread that opens an authenticated sub-connection, sends TOKEN_TERMINAL_START and keeps the PTY alive until the server closes it. common/PTYHandler.h is reused, with a minSdk-21 openpty built from posix_openpt/grantpt and /system/bin/sh (mksh) as the shell. A new CLIENT_CAP_TERMINAL bit lets the server reject old APKs up front with -32005. Server: the tool masks, instructions and docs matrix accept APK. While verifying, exec_command left a second echoed copy of the command line in stdout: mksh forks with ECHO still on, so input written before its line editor takes over is echoed by the line discipline in addition to the shell's own redraw. The server now waits for the shell's first output (the prompt) before sending the command and sentinel, which restores the single-echo assumption the cleaning step relies on. terminal_exec on a ready session is unaffected. Verified on the Android 15 emulator: exec_command returns clean stdout and real exit codes for id/uname/df/ls (including a failing command), and terminal_open keeps cwd across commands, pipes work and close is clean. The committed ghost.apk is stale and must be rebuilt before release; a rebuilt APK was used for this testing. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
915c587964
commit
445bd8bbb9
9 files changed
+205
-32
No files matched your search
@@ -132,6 +132,7 @@
|
||||
| 电源操作 | `TOKEN_MACHINE_MANAGE` | ✅ `power_action` | — |
|
||||
| 卸载主机(被控程序) | `TOKEN_UNINSTALL` | ✅ `uninstall_host`(win + apk) | Android 新版拉起系统卸载确认框,需人工确认 |
|
||||
| 远程交谈 | `COMMAND_CHAT` | ✅ `chat_*`(win + apk) | Android 新版弹应用内聊天窗口(能力位 `CLIENT_CAP_REMOTE_CHAT`),老 APK 返回 `-32005` |
|
||||
| 远程终端 | `COMMAND_SHELL` | ✅ `exec_command` / `terminal_*`(win + lnx + apk) | Android 新版复用 `common/PTYHandler.h`(`/system/bin/sh`,能力位 `CLIENT_CAP_TERMINAL`),老 APK 返回 `-32005` |
|
||||
| **客户端升级** | `COMMAND_UPDATE` | ❌ | 零客户端改动,需独立评审(见 §4.4) |
|
||||
| **上传执行 / 下载执行** | `COMMAND_UPLOAD_EXEC` / `COMMAND_DOWN_EXEC` | ❌ | 零客户端改动,需独立评审(见 §4.4) |
|
||||
| **代理映射** | `COMMAND_PROXY` | ❌ | 需独立设计(见 §4.3) |
|
||||
|
||||
Reference in new issue
Block a user