Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Repository layout

Tetheron is one repository with two products, the Android app and the Linux desktop software, and the protocol schemas they share (ADR-0001). Directories, crates and packages keep the name tether (see Names).

Top level

.
├── proto/               protobuf schemas, the single source for both sides
├── desktop/             Rust workspace: daemon, desktop app, CLI, packaging
├── android/             Gradle build: the Android app and the shell helper
├── docs/                this documentation (mdBook source)
├── .github/             CI workflows, issue and pull request templates
├── book.toml            mdBook configuration, output goes to target/book/
├── README.md            project overview
├── CHANGELOG.md         release notes, Keep a Changelog format
├── CONTRIBUTING.md      pointer to the contributor guide
├── CODE_OF_CONDUCT.md   code of conduct
├── SECURITY.md          how to report a vulnerability, threat model summary
├── NOTICE               copyright notice and third-party credits
├── LICENSE              GPL-3.0
└── logo.svg             the project logo

proto/tether/v1/

The wire protocol, version 1. Rust types are generated by tether-proto, Kotlin types by the Wire Gradle plugin. Behaviour is specified in the wire protocol reference.

FileContents
envelope.protoEnvelope: the frame of the control connection, a oneof over every message below except those of shell.proto
common.protoHello, Ping, Pong, Disconnect, the UDP Beacon, StreamOpen and StreamPurpose for secondary connections, DeviceKind
pairing.protoPairRequest, PairResponse, PairConfirm, PairReject, Unpair
device.protoDeviceInfo, Battery
notifications.protoNotificationPosted, NotificationRemoved, NotificationActionRequest, NotificationDismiss
blobs.protoBlobRequest, Blob: small binary objects addressed by hash (icons, avatars, album art)
messages.protoSMS and MMS: conversations, messages, live events, sending, attachments
contacts.protocontact sync as vCard deltas
media.protomedia sessions and commands, phone volume
misc.protoDo Not Disturb, RingPhone, Connectivity, Clipboard, ShareText
files.protofile offers in both directions, transfer progress and cancellation
photos.protogallery queries, thumbnails, fetch, delete, change notices
calls.protocall state, call commands, call log, Bluetooth identity
enhance.protoenhanced tier, app side: AdbLink, AdbWifiState, AdbWifiRequest, the app list
shell.protothe separate protocol between the daemon and the shell helper (ShellEnvelope): handshake, mirroring, input, clipboard, grants, display power, app start, audio, camera

desktop/

A Cargo workspace (desktop/Cargo.toml) with six crates under desktop/crates/ and the packaging files under desktop/packaging/. Cargo.lock is committed.

Crate dependencies

tether-proto   generated types, no dependency on other crates
     ^
     |-- tether-core   protocol engine (library)
     |        ^
     |        |
     |-- tetherd       the daemon, uses tether-core and tether-proto
     |
     `-- tether-gtk    the desktop app, uses tether-proto only

tether-distro  no dependency on other crates, used by tetherd and tether-gtk
tether-cli     no dependency on other crates

tether-gtk and tether-cli reach the daemon only through D-Bus (ADR-0006). tether-gtk uses tether-proto for the mirror stream, which it reads from the shell helper’s video connection.

tether-proto

PathContents
build.rscompiles the .proto files with protox and prost-build, from an explicit list of files
src/lib.rsmodule v1 (generated), PROTOCOL_VERSION, DEFAULT_PORT, ALPN, MDNS_SERVICE

tether-distro

PathContents
src/lib.rsfamily(): the distribution family (Debian, Fedora, Arch or other) from /etc/os-release. The package names and install commands that hints of the daemon and the app show for each family

tether-core

A library with everything an endpoint needs below the user interface. It has no D-Bus interface.

PathContents
src/lib.rspublic exports, CAPABILITIES
src/identity.rsthe device identity: a self-signed ECDSA P-256 certificate. The device id is the hash of its public key
src/trust.rsthe persistent store of paired devices
src/tls.rsmutual TLS 1.3 with trust on first use
src/framing.rslength-prefixed Envelope framing
src/session.rsone authenticated connection: Hello, send and receive loop, keepalive, the capability each frame requires
src/pairing.rsshort authentication string, QR proof, the tether://pair URI
src/streams.rssecondary connections for bulk data (ADR-0014)
src/blobs.rscache of small blobs, addressed by hash
src/device.rsthe device registry and the Event and PeerRequest types the daemon consumes
src/paths.rsXDG directories
src/error.rsthe crate’s error type
src/discovery/avahi.rs (mDNS through Avahi’s D-Bus API), beacon.rs (UDP beacon), mod.rs (merged events, manual addresses)
src/core/mod.rsCore: owns identity, trust, transport, discovery and the registry; dispatches received frames
src/core/net.rslistening, accepting, dialling
src/core/pair_flow.rsthe pairing state machine
src/core/notif_flow.rsdevice information, battery, notifications, blobs
src/core/feature_flow.rsMilestone 2 frames and their send helpers, intentional disconnect
src/core/call_flow.rscalls, call log, Bluetooth identity
src/core/enhance_flow.rsenhanced tier frames and the app list
src/core/state.rsthe state shared by the core’s tasks
tests/integration tests between two in-process cores: pairing, QR, disconnect and hold, messages and contacts, streams, calls, enhanced tier
examples/fake_phone.rsa fake phone for developing against the real daemon

tetherd

The daemon. Owns the connection to the phone and the D-Bus name org.tether.Daemon on the session bus. Cargo features audio and webcam (both default) pull in GStreamer.

PathContents
src/main.rsstart-up
src/config.rsconfig.toml
src/db.rsthe SQLite cache per device (ADR-0013)
src/dbus/mod.rsthe bridge from core events to D-Bus signals and property changes
src/dbus/daemon.rsinterface org.tether.Daemon1
src/dbus/device.rsinterface org.tether.Device1
src/dbus/dicts.rsbuilders for the a{sv} values of the D-Bus API
src/notify.rsphone notifications as desktop notifications, and the daemon’s own notifications
src/battery.rsthe low-battery alert
src/mpris.rsone MPRIS player per phone with an active media session
src/media_pause.rspauses desktop players during a call
src/ringtone.rsthe desktop ringtone for incoming calls
src/call_tracker.rsthe call state machine
src/bluetooth.rsBlueZ: adapter, guided pairing, hands-free connection
src/pipewire.rsPipeWire graph logic for call audio
src/adb.rsadb: the binary, the private server, a command runner that parses output, device tracking (ADR-0016)
src/shell.rssupervisor of the shell helper (ADR-0017)
src/phone_audio.rsplayback of the phone’s audio through GStreamer
src/webcam.rsthe camera pipeline into the v4l2loopback device (ADR-0019)
src/webcam_setup.rsstate of v4l2loopback on the machine; runs the set-up script through pkexec
src/features/mod.rsFeatures, the per-device state, routing of core events to features
src/features/messages.rs, contacts.rs, vcard.rsmessage sync and sending; contact sync; the vCard parser
src/features/media.rsmedia sessions and phone volume
src/features/misc.rsDo Not Disturb, ring, connectivity, clipboard, share
src/features/files.rs, photos.rsfile transfer; gallery index, thumbnails, originals, deletion
src/features/calls.rs, calllog.rs, bt.rs, audio.rscalls; call log; Bluetooth glue; call audio routing and echo cancellation
src/features/enhance.rsthe enhanced tier: adb servers, Wireless debugging pairing, linking, the state machine per device
src/features/apps.rs, phone_audio.rs, webcam.rsthe app list; the phone audio switch; the webcam switch and the virtual camera

tether-cli

PathContents
src/main.rsthe clap command tree and every command
src/proxies.rszbus proxies for org.tether.Daemon1 and org.tether.Device1

tether-gtk

The desktop app. The crate is tether-gtk, the binary is tether. Cargo features: tray and mirror (default), mock (the in-process fake daemon, tether --mock).

PathContents
src/main.rs, application.rs, window.rsentry point; the application object; the main window
src/backend/mod.rsthe Backend trait and the typed data the interface uses
src/backend/dbus.rsthe Backend implementation over D-Bus
src/backend/mock.rs, mock/, mock_data.rsthe fake daemon and its generated data
src/backend/calls.rs, enhance.rs, apps.rs, webcam.rstyped forms of the Milestone 3 and 4 parts of the D-Bus API
src/models/GObject models the widgets bind to
src/widgets/the pages and rows: overview, notifications, messages, photos, files, calls, apps, webcam group
src/dialogs/pairing QR, add address, preferences, per-app settings, file offer, image viewer, Bluetooth pairing, webcam set-up
src/calls/incoming-call banner and in-call window
src/enhance/enhanced tier status row and set-up wizard
src/mirror/the mirror window: stream framing, decode pipeline, input mapping (ADR-0018)
src/apps/app windows and “pin to desktop”
src/clipboard.rs, tray.rs, config.rs, util.rsclipboard sync; tray icon; gtk.toml and autostart; helpers
data/style sheet, GResource manifest, desktop entry, AppStream metainfo, icons, sample streams for the fake daemon (data/mock/)
build.rscompiles the GResource bundle

desktop/packaging/

Everything that turns the workspace into the single Debian package tether and into the tarball for other distributions (ADR-0008). The package metadata is in [package.metadata.deb] at the end of desktop/crates/tetherd/Cargo.toml.

PathContents
build-deb.shbuilds the release binaries and the .deb
build-tarball.shbuilds the release binaries and tether-<version>-linux-<arch>.tar.gz
tarball/install.shthe install script inside the tarball: dependency check, install, uninstall
tarball/README.mdthe short instructions inside the tarball
debian/postinst, prerm, postrmmaintainer scripts
systemd/tetherd.servicethe systemd user unit
dbus/org.tether.Daemon.servicesession bus activation
ufw/tetherthe ufw application profile Tether (port 7360, TCP and UDP)
webcam/tether-webcam-setuproot helper that creates the v4l2loopback device
webcam/org.tether.webcam-setup.policythe polkit action for that helper
wireplumber/optional WirePlumber drop-ins for call audio, installed as documentation only
README.mdwhat is installed where

android/

A Gradle build (settings.gradle.kts, wrapper included) with two modules. Dependency versions are in gradle/libs.versions.toml.

PathContents
app/the application module: the Android app and the shell helper in one APK
hidden-api/a compile-only Java stub of one hidden framework interface (android.content.IContentProvider), not packaged
tools/helper_test.pydrives the shell helper on an attached phone without the daemon (Python 3, standard library only)

android/app/src/main/java/org/tether/android/

The app. ADR-0005 describes its background model.

PackageContents
(root)AppGraph (manual dependency injection), TetherApp (the Application)
corelogging (TLog), byte helpers, Permissions, SettingsRepository, TrustedDesktopStore
core.identitythe identity key in AndroidKeyStore and its certificate
transportFraming, Connection, Session, TetherEngine, the Feature interface, Protocol (constants and capabilities), HoldSet, StreamManager
transport.tlsthe TLS context and the trust manager
pairingSas, QrPairingUri, PairingManager
discoverymDNS (NsdDiscovery), UDP beacon, the merged repository
serviceTetherService (foreground service), BootReceiver, NetworkMonitor, notification channels
features.battery, features.deviceinfobattery and device information
features.notificationsthe notification listener, the bridge with filtering, the wire mapping
features.blobsblob store and feature
features.messagesSMS and MMS repository, diffing, senders, the MMS PDU encoder
features.contactscontacts repository, vCard writer, delta sync
features.mediamedia sessions and volume
features.miscDo Not Disturb, ring, connectivity, clipboard (with the tile and the send activity)
features.files, features.sharefile transfer; the share target
features.photosMediaStore repository, the photos feature, the delete activity
features.callscall state and commands, the in-call service, call log, caller lookup
features.bluetoothBluetooth identity and connect requests
features.appsthe list of launchable apps
enhancethe app side of the enhanced tier
uiCompose screens: MainActivity, navigation, onboarding, home, settings, qr, components, theme

android/app/src/main/java/org/tether/shell/

The shell helper of the enhanced tier (ADR-0017). It is in the same APK and runs outside the app process: the daemon starts it through adb with app_process, and it speaks shell.proto.

FileContents
Main.ktentry point, ability probes, the control channel
ShellProtocol.kt, Geometry.ktpure protocol and geometry code
FakeContext.kt, Workarounds.kt, Hidden.ktthe system context as the shell package; access to hidden APIs
MirrorSession.kt, CaptureTarget.ktthe H.264 encoder on the main display or a virtual display
InputInjector.kttouch, key, scroll and text input
AudioCapture.kt, OpusConfig.ktphone audio capture to Opus
CameraCapture.kt, CameraSelect.ktcamera capture for the webcam
ClipboardBridge.ktclipboard read, write and watch
Grants.kt, GrantTable.kt, Exec.ktthe fixed grant commands
PanelPower.kt, CleanUp.ktscreen off while mirroring, and its restore if the helper dies
ShellLog.ktlogging to stderr

Other parts of the module: android/app/src/main/AndroidManifest.xml, resources under android/app/src/main/res/, unit tests under android/app/src/test/java/ (same packages), R8 rules in android/app/proguard-rules.pro.

.github/

PathContents
workflows/desktop.ymlfmt, clippy and tests on every change to desktop/ or proto/. Builds the .deb and the tarball on a v* tag
workflows/android.ymlunit tests and debug APK on every change to android/ or proto/. Builds the signed release APK on a v* tag
workflows/docs.ymlchecks links, builds this site, publishes it from main
ISSUE_TEMPLATE/bug_report.yml, feature_request.yml, config.yml
PULL_REQUEST_TEMPLATE.mdthe pull request checklist

docs/

The source of this site.

PathContents
introduction.md, SUMMARY.mdthe landing page and the table of contents. A page that SUMMARY.md does not list is not built
tutorials/, how-to/, reference/, explanation/the user guide, by kind of page
adr/architecture decision records and their template
contributing/this guide. checklists/ holds the device verification checklists per milestone
roadmap.mdplan and status of every milestone
notes/engineering notes: research reports and session records, not updated after they are written
images/screenshots (desktop/, android/)
tools/check_links.py, the link checker CI runs, and screenshots.sh, which takes the desktop screenshots