The SSH client is the same as iOS's and the GUI's now: native-ssh, on
libssh, loaded as libdmodem_ssh_jni.so (NativeSsh.kt). SshLink polls
it on its own thread; its channels carry the shell, commands, the
port forwards (-L, -R, -D) and the forwarded agent's requests. Keys
stay the app's: SSH's wire form (SshWire.kt), OpenSSH's and PEM keys
read through the engine, PuTTY's .ppk read here, all on BouncyCastle.
The engine: commands can forward the agent, a write tells what's still
kept for the server (forwards hold back a fast sender), libssh built
WITH_SERVER (its callbacks for the agent's channels need it), and its
remote listen on port 0 patched to take the port from its own reply.
The unit tests build the JNI library for the host (buildHostSsh) and
run against it: OpenSSH's sshd, puttygen and Apache MINA's server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
Hdlc, Ip, Ppp and ChatScript move to shared/'s common Kotlin; the NAT
(its sockets) and Android's VPN stay the app's. What they needed of the
JVM, common: an IPv4 address (Inet4: on the JVM java.net.Inet4Address
itself, the app's code as it was), MD5 for CHAP, a timer (coroutines, one
piece at a time, as the scheduled executor), atomicfu's synchronized.
PppLoopbackTest (common: the JVM and native): a client and a server in
memory, the link up, the address and DNS given, IP both ways, the
hang-up; MD5 against RFC 1321's vectors. The app's PPP tests (the ISP,
the chat scripts, the internet line over two modems, the phone as an
ISP) pass on the shared code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
shared/'s io: what the shared code needs of I/O the same on the JVM and
iOS: Source and Sink (the JVM's streams through asSource()/asSink()), a
byte buffer, a queue of bytes read with a timeout (on coroutines'
channels), IOException (java.io's own on the JVM), the monotonic clock,
a sleep, the local time zone's offset.
The transfers move there (TransferIo, X/Y/ZMODEM, Kermit, the CRCs, the
files' Outgoing and Incoming); a folder of received files and a JVM file
to send stay the JVM's (FolderIncoming, Outgoing.of). Kermit's dates by
arithmetic (civil from days and back) in the local zone.
TransferLoopbackTest (common: the JVM and native): each protocol both
ways in memory, the files and their dates as sent. It found Kermit's
dates read wrong when they came as yyyymmdd (the 6-digit form matched
first): the 8-digit form first now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
The terminal's VT/xterm emulator, its screen, Sixel, the character sets,
the keys, the characters' widths and the themes move to shared/'s common
Kotlin (the same package: the app's code as it was), their JVM-only calls
in common Kotlin's ways (code points, ISO 8859-1, copyInto, Base64.Mime).
The Android app has its JVM side; iOS its framework, DModemShared (iOS
devices, simulator); Linux native runs the common tests too.
TerminalEmulatorTest in common Kotlin (kotlin.test): on the JVM and
native; XtermFeaturesTest on the JVM. CI: the shared tests on Linux
(JVM, native) and on an iOS simulator (apple.yml).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- an adapter (FTDI, CP210x, CH34x, PL2303, CDC-ACM; usb-serial-for-
android, from JitPack for that alone) as another bridge: its speed and
format set, its DTR out the modem's carrier (the computer's DCD on a
null modem), the computer's DTR (its DSR) dropped hanging up; the first
adapter found, again when one is plugged in; Android offers the app
when one is (a device filter), its permission asked for
- with root: an ACM function added to the phone's USB gadget in
configfs, so a computer on the phone's cable sees a modem, served on
/dev/ttyGS0; taken out again when off; said plainly when the phone's
kernel can't
- Settings' serial port section has both
Tested: an adapter's port faked (both ways, DCD, DTR's drop hanging up,
unplugged), the gadget on a pty with root faked, its scripts parsed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- A catalog: Alpine (its own release list), Ubuntu 24.04 (its base
image, the newest point release), and from the Linux Containers
images (built daily, SHA-256 sums): Debian 13, Fedora, Arch Linux,
openSUSE Tumbleweed, Kali, Void, Rocky, AlmaLinux, Devuan; those not
built for the phone's processor shown as such (the images' index)
- Or any root file system tarball by its URL (.tar, .tar.gz, .tar.xz;
xz with org.tukaani:xz), its SHA-256 checked when given; one in a
single top folder moved up; anything else refused and removed
- Several systems side by side, each in linux/<id> with system.json;
the first release's Alpine still known
- Set up for proot at each start: resolv.conf a file (not systemd's
link), hosts, /etc/mtab, apt's sandbox user root, pacman without its
sandbox or space check, a prompt named for the distribution; root's
own login shell (bash where it has it), found through usrmerge's links
as the system sees them
- Settings, Linux: the systems installed (open, remove), "Install a
Linux" with the catalog or a URL; the terminal's "New Linux shell…"
asks which when there are several; installs report done as a state
the screens watch
- Tests: the sources' indexes, archives of each kind, the proot set-up,
checksums and refusals (offline); Alpine and a custom URL's .xz
through proot on this host; every catalog distribution's package
manager installing Lua when DMODEM_DISTROS names them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- TerminalLink: one interface for the modem's DTE and network links;
sessions (modem, SSH, Telnet) as tabs, each with its own emulator
- SSH (sshj + BouncyCastle): password, keyboard-interactive and key
login, PTY with window-size changes, keep-alives
- Keys made or imported here (Ed25519, ECDSA P-256, RSA 3072;
OpenSSH, PKCS#8, PEM), sealed with an Android Keystore AES-GCM key;
public keys to copy and share
- known_hosts kept on first use, a changed key put to the user in red
- Passwords optionally remembered per entry, sealed the same way
- Telnet: NVT with NAWS, terminal type, binary and echo options
- Directory entries for SSH and Telnet hosts beside modem numbers;
a Disconnected bar with Reconnect and Close
- Prompts asked from connection threads, answered in dialogs, cancelled
when their connection closes
- Tests against a real SSH server (Apache MINA) in the JVM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- TerminalView filled its background with drawColor(), which fills the
clip it is given: it could paint over the Compose bar above it (the
terminal's status, keyboard, snippets, capture and menu). It fills its
own bounds now.
- The Modem tab's console turned the modem's echoed CR (ATX3\r\r\n) into
a blank line: a lone CR is dropped there now.
- ScreenshotsTest: every tab drawn with Robolectric's native graphics into
app/build/screens/ (Compose UI test).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- TerminalEmulator (pure Kotlin): VT100/VT220 with xterm's extensions:
cursor movement and addressing, erase/insert/delete of characters and
lines, scrolling regions, SGR with 16, 256 and 24-bit colours (; and :
forms), the alternate screen (47/1047/1049), origin, autowrap, insert
and newline modes, application cursor keys and keypad, bracketed paste,
DEC line drawing (G0/G1, SO/SI), tab stops, REP, DSR/CPR, DA1/DA2, ENQ
answerback, OSC titles, DCS/PM/APC skipped, C1 controls, RIS/DECSTR;
ANSI.SYS's CSI s/u and clear-home for BBSes; scrollback; resize that
keeps the cursor's line; text extraction joining wrapped lines.
- Charsets: UTF-8 (streamed across reads), CP437, ISO 8859-1, both ways.
- KeyEncoder: xterm key sequences with modifiers, Ctrl/Alt on characters,
BS or DEL, CR / CR LF / LF.
- TerminalView: cells drawn in runs on whole pixels, bold as bright, iCE
colours, faint, italic, underline, strike, blink, inverse and reverse
video; box drawing and block elements drawn to fill their cells (no
gaps in ANSI art); block/underline/bar cursor with blink; fixed 80/132/40
columns or pinch zoom (kept); scrollback with drag and fling, Shift+PgUp;
long-press selection with copy, paste, select all, share and open link;
a soft keyboard input connection without suggestions, hardware keys;
volume keys as font size or Ctrl/Alt; bell as vibration or flash.
- TerminalSession: the emulator on the DTE hub, sticky Ctrl/Alt, local
echo, (bracketed) paste, capture to a file shared through a
FileProvider, hang up with +++ guard times.
- UI: Terminal tab (status and call time, keyboard, snippets, capture,
hang up, charset, clear, reset, full screen; an extra keys bar with Esc,
Ctrl, Alt, Tab, arrows with repeat, Home/End/PgUp/PgDn, F1-F12), Dial tab
(a directory with each system's init commands, charset and backspace;
dialling starts the modem), snippets with escapes, terminal settings
(11 themes and the rest).
- Tests (JVM, 32 pass): the emulator (17), the session (7), and the view
drawn for real with Robolectric's native graphics (ANSI art in CP437 at
80 columns, its cells' colours checked). Lint: no issues.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
- Gradle 9.8.1, AGP 9.4.1 (its built-in Kotlin, 2.4.21), compileSdk 37,
minSdk 26; the native library built by externalNativeBuild for
arm64-v8a, armeabi-v7a, x86_64 and x86 (only dmodem_jni, NDK r29), 16 KB
page aligned; R8 keeps NativeModem's natives and callbacks.
- ModemService: a foreground service (specialUse) that runs the native
modem with its DTE on DteHub, sends the init commands (ATX3), holds a
wake lock and a low-latency Wi-Fi lock while on, takes the DNS servers
from the active network, and starts the modem again when the default
network changes (after the call in progress); a notification with the
call's state and Stop.
- DteHub: the modem's DTE shared by any number of listeners (console,
terminal, bridges), kept across the modem's restarts.
- ModemState: the run state, the call's status, the log and the
console's text, for the UI and the notification.
- Settings in DataStore: the SIP account (or user:password@host pasted),
incoming calls, T.38, init commands, country, log levels; no backups
(the password).
- UI (Compose, Material 3): Modem (start/stop, status, an AT command line
and the modem's output), Settings, Log.
- Tests: DteHub and the settings (JVM, 5 pass); NativeModemTest
(instrumented: the library loads, binds, answers AT, ATI3, ATX3, stops,
and closing the DTE stops it), compiled here, run by CI on an emulator.
- CI: the APK, unit tests and lint; native-test on the runner; the
instrumented tests on an x86_64 emulator. The private submodule needs
a DMODEM_RE_TOKEN secret.
Lint: no issues.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs