A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.
Enable terminal mouse support for TUI apps
ExTv9be1fb5b583a
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.ktindex c1aa142..602c812 100644--- a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt+++ b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt@@ -35,8 +35,6 @@ import androidx.lifecycle.viewModelScopeimport com.excp.podroid.data.repository.SettingsRepositoryimport com.excp.podroid.engine.PodroidQemuimport com.excp.podroid.engine.VmState-import com.termux.terminal.TerminalEmulator-import com.termux.terminal.TerminalOutputimport com.termux.terminal.TerminalSessionimport com.termux.terminal.TerminalSessionClientimport com.termux.view.TerminalView@@ -251,33 +249,6 @@ class TerminalViewModel @Inject constructor(// starts and the PTY file descriptor is allocated.sess.updateSize(80, 24)- // Busybox ash sends \033[6n (cursor position query) on every prompt.- // The Termux TerminalEmulator responds with \033[row;colR via TerminalOutput- // → bridge stdin → serial → VM ttyAMA0. Due to bridge round-trip latency,- // the response arrives after ash's readline has timed out waiting for it,- // so ash treats it as keyboard input and displays "^[[16;5R" garbage.- //- // Fix: replace the session's emulator with one whose TerminalOutput is a- // no-op — all emulator responses are dropped. Keyboard input is unaffected- // because it flows through session.write() → PTY master (separate path).- try {- val noOpOutput = object : TerminalOutput() {- override fun write(data: ByteArray, offset: Int, count: Int) {}- override fun titleChanged(oldTitle: String?, newTitle: String?) {}- override fun onCopyTextToClipboard(text: String?) {}- override fun onPasteTextFromClipboard() {}- override fun onBell() {}- override fun onColorsChanged() {}- }- val displayEmulator = TerminalEmulator(noOpOutput, 80, 24, 2000, sessionClient)- val field = TerminalSession::class.java.getDeclaredField("mEmulator")- field.isAccessible = true- field.set(sess, displayEmulator)- Log.d(TAG, "Emulator output replaced — CPR responses will be dropped")- } catch (e: Exception) {- Log.w(TAG, "Could not replace emulator output: ${e.message}")- }-session = sessLog.d(TAG, "Bridge session created — PTY connected to ${qemu.serialSockPath}")}diff --git a/app/src/main/jniLibs/arm64-v8a/libpodroid-bridge.so b/app/src/main/jniLibs/arm64-v8a/libpodroid-bridge.soindex 72659f7..feb4223 100755Binary files a/app/src/main/jniLibs/arm64-v8a/libpodroid-bridge.so and b/app/src/main/jniLibs/arm64-v8a/libpodroid-bridge.so differdiff --git a/podroid-bridge.c b/podroid-bridge.cindex 0741611..7533f5b 100644--- a/podroid-bridge.c+++ b/podroid-bridge.c@@ -74,6 +74,42 @@ static int write_all(int fd, const char *buf, int n) {return 0;}+/*+ * filter_csi6n — strip CSI 6n responses from VM data.+ *+ * CSI 6n is the emulator's response to the shell's DA1 query (\033[6n).+ * The response format is \033[<row>;<col>R, e.g. \033[16;5R.+ *+ * When this response reaches ash via the PTY, ash reads it as keyboard input+ * and prints "^[[16;5R" garbage. Filtering it here prevents that.+ *+ * CSI 6n is the ONLY response we filter — all other CSI sequences pass+ * through normally (mouse tracking, title changes, etc.).+ */+static int filter_csi6n(char *buf, int n) {+ char *src = buf;+ char *dst = buf;+ int i = 0;+ while (i < n) {+ if (i < n - 2 && buf[i] == '\033' && buf[i + 1] == '[') {+ /* Check for CSI 6n: ESC [ <digits> ; <digits> R */+ int j = i + 2;+ while (j < n && buf[j] >= '0' && buf[j] <= '9') j++;+ if (j < n && buf[j] == ';') {+ int k = j + 1;+ while (k < n && buf[k] >= '0' && buf[k] <= '9') k++;+ if (k < n && buf[k] == 'R') {+ /* Matched CSI 6n — skip it */+ i = k + 1;+ continue;+ }+ }+ }+ *dst++ = buf[i++];+ }+ return dst - buf;+}+int main(int argc, char *argv[]) {if (argc < 3) {fprintf(stderr, "Usage: %s <serial.sock> <ctrl.sock>\n", argv[0]);@@ -145,11 +181,12 @@ int main(int argc, char *argv[]) {if (write_all(serial_fd, buf, n) < 0) break;}- /* Serial → screen */+ /* Serial → screen (filter CSI 6n garbage before forwarding to PTY) */if (FD_ISSET(serial_fd, &rfds)) {int n = read(serial_fd, buf, sizeof(buf));if (n <= 0) break;- if (write_all(STDOUT_FILENO, buf, n) < 0) break;+ int filtered = filter_csi6n(buf, n);+ if (write_all(STDOUT_FILENO, buf, filtered) < 0) break;}}