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

About the architecture

Tetheron is an Android app and a set of Linux programs that share one wire protocol. This page explains why the parts are split the way they are, and follows one notification from the phone to the desktop and back.

  Android phone                                      Linux desktop
 +-------------------------------+                  +------------------------------------------+
 | Tether app (Kotlin/Compose)   |                  |  tetherd  (Rust, systemd user service)   |
 |  TetherService (foreground    |  TLS 1.3 / TCP   |   identity + pinning   pairing (SAS/QR)  |
 |   service, connectedDevice)   |<================>|   discovery (Avahi mDNS + UDP beacon)    |
 |  NotificationListenerService  |  port 7360       |   sessions + features: notifications,    |
 |  SMS/MMS, contacts, calls,    |  protobuf        |   messages, contacts, media, files,      |
 |  media sessions, MediaStore,  |  Envelope        |   photos, clipboard, calls, apps         |
 |  clipboard, app list          |  + secondary     |   SQLite cache per phone, MPRIS player   |
 |  NsdManager + UDP beacon      |  TLS streams     |   adb, phone audio, webcam               |
 |                               |                  |        |                                 |
 |  P-256 key in AndroidKeyStore |                  |        |  D-Bus  org.tether.Daemon       |
 +-------------------------------+                  |        v         (session bus)           |
        ^                                           |  +-------------+  +------------+         |
        | Bluetooth hands-free (call audio)         |  | tether      |  | tether-cli |         |
        +------------------------------------------>|  | GTK4/adw    |  +------------+         |
                                                    |  | tray (SNI)  |                         |
 +-------------------------------+                  |  +-------------+   org.freedesktop.      |
 | Shell helper                  |  adb reverse     |        ^           Notifications         |
 | org.tether.shell.Main         |  tunnel,         |        | mirror connection               |
 | (same APK, runs as `shell`,   |  one-time token  |        | (file descriptor)               |
 |  started by tetherd over adb) |<================>|  tetherd listener on 127.0.0.1           |
 +-------------------------------+  ShellEnvelope   +------------------------------------------+
                                    + media streams

The webcam path ships with 0.5.0. Everything else in the diagram is in 0.4.1.

One repository, one protocol definition

The two sides are useless without each other, and the protocol between them grows with every feature. Both therefore live in one repository, and the protocol is defined once, in protobuf schema files from which the Rust side and the Kotlin side generate their message types at build time. A protocol change is one pull request that touches the schema, the desktop and the phone together. With separate repositories it would be three coordinated ones.

The phone app is Kotlin with Jetpack Compose and requires Android 14, because that is where the foreground service type Tetheron depends on appeared, and older versions would need a second code path for services and permissions. The desktop is Rust with GTK 4 and libadwaita. The daemon has to hold TLS connections, speak D-Bus and decode video in one binary without a runtime, and the target desktops (Cinnamon, GNOME) are GTK-based. ADR-0001 records both choices.

The desktop side

tetherd, the daemon, is the only process that talks to the phone. It owns the device identity, discovery, pairing, the connections, every feature and the caches. The desktop app tether and the command-line tool tether-cli are clients of the daemon’s D-Bus API, org.tether.Daemon on the session bus, which is the only interface between the daemon and any user interface.

The split exists because syncing must keep working when no window is open. Notifications must appear, files must arrive, and the battery level in the tray must update. The daemon posts desktop notifications itself, and the app can be closed, crash or be replaced without dropping the connection to the phone. A documented API also allows more than one front end. The app and the command-line tool are two, and a GNOME Shell extension is planned as a third.

The daemon runs as you, never as root, as a systemd user service tied to the graphical session. It needs your notification service and your files, and a system service running as a dedicated user could reach neither.

Two alternatives were rejected. A single app with the daemon built in would disconnect the phone when you close the window. A GNOME Shell extension as the whole product would exclude Cinnamon, KDE and Xfce. The cost of the chosen design is that every feature needs a D-Bus surface as well as a protocol surface. ADR-0006 has the record.

The phone side

The phone side is one APK with three entry points that Android treats very differently.

  • TetherService is a foreground service of type connectedDevice, the type Android offers to apps that maintain a connection to an external device. It holds the connection to the desktop for hours with the screen off and shows one silent, permanent notification. About discovery and connectivity explains what else the phone needs to keep it alive, and ADR-0005 records the model.
  • The notification listener is bound by Android when you grant notification access. It is kept small and forwards what it sees to the service.
  • The shell helper is a second program inside the same APK and is not part of the app. The daemon starts it through adb, and it runs as Android’s shell user, which may capture the display, inject input, create virtual displays and capture audio. It exists only in the enhanced tier.

Android does not let a normal app do what screen mirroring needs, and the shell user is the one route to those abilities that needs neither root nor a partnership with the phone’s manufacturer. Packing the helper into the app’s APK means there is one file to install and the helper always matches the app’s version. The helper is not the paired peer and has no identity of its own, so it speaks a small protocol of its own to the daemon, gated by a one-time token. About privilege tiers and adb covers this in full.

The wire protocol in outline

The wire protocol reference is the normative description. The design decisions behind it are these.

Both sides listen on TCP port 7360 and either may dial, because the phone may be unreachable while it dozes and the desktop may be asleep when the phone comes home.

Every connection is TLS 1.3 with a certificate on both ends, and there is no plaintext mode. The certificates are self-signed. What counts is the key, which each side pins when you pair; see About the security model. TCP with TLS was chosen over QUIC because no maintainable QUIC implementation existed for Android that did not bring in Google-shipped or native code. The framing does not depend on the transport, so QUIC can be added later.

Messages are protobuf, one per length-prefixed frame. Protobuf has code generators for both Kotlin and Rust and tolerates unknown fields, so the two sides share a schema and can still evolve separately. Adopting KDE Connect’s protocol was considered and rejected for reasons of transport and pairing that ADR-0002 sets out.

On connecting, each side sends a list of capability strings such as notifications, messages or calls. A feature is active only when both sides list what it needs. This is how an old and a new build keep working together. It is also how the phone tells the desktop that a permission is missing: it does not advertise a capability whose permission it does not hold.

Bulk data (files, photos, message attachments) never travels on the first connection, the control connection. The side that has the bytes opens another TLS connection to the same peer for them. Cutting files into control frames was rejected because a large transfer would stall notifications and media controls behind it. The price is one TLS handshake per stream. ADR-0014 has the comparison.

Where the desktop keeps data

Messages, contacts and the photo index must outlive a window, so the cache lives in the daemon. It is one SQLite database per paired phone, with large items (attachments, thumbnails, fetched photos) as files beside it. Configuration and files lists the locations. D-Bus suits paged method calls and change signals and does not suit megabytes of data, so clients ask the daemon for a page of rows, and for bulk data they get a file path in the daemon’s cache.

Media control lives in the daemon for the same reason. For each connected phone that has a media session, the daemon exports an MPRIS player. MPRIS is how Linux desktops connect media keys, panel applets and tools such as playerctl to players, so all of those control the phone with no Tetheron window open.

The clipboard is the exception. On Wayland a program can read the clipboard only while it has focus, so the desktop app watches and sets the clipboard. When the app is not running, the daemon covers for it with wl-copy or xclip, and on X11 it also watches for changes on the desktop.

ADR-0013 records these decisions.

A notification, end to end

  1. A chat app on the phone posts a notification. Android hands it to the notification listener.
  2. The phone app filters it. Its own notifications, group summaries, ongoing foreground-service notifications, media transport notifications and apps on your blocklist are dropped.
  3. The app sends a NotificationPosted message on the control connection. The message carries the SHA-256 hash of the icon in place of the icon.
  4. If the daemon has no icon with that hash, it sends a BlobRequest and the phone answers with the image. The daemon stores the image under its hash, so each icon crosses the network once.
  5. The daemon posts a desktop notification through org.freedesktop.Notifications, with the phone notification’s actions as buttons. It also emits a NotificationPosted signal on D-Bus, and the desktop app, if it is running, adds the notification to its list.
  6. You click Reply. Desktop notification pop-ups have no standard for typing a reply inside them, so the daemon emits ReplyRequested and the desktop app opens its reply box.
  7. You type and send. The app calls the daemon over D-Bus, and the daemon sends a NotificationActionRequest with your text to the phone.
  8. The phone app fills the text into the notification’s reply action and fires it. The chat app sends the message as if you had replied from the phone’s notification shade, and never learns that the reply came from a desktop.
  9. When the chat app removes its notification, the phone sends NotificationRemoved, and the daemon closes the desktop notification.

The daemon does all the work up to step 5, so the notification appears with the app closed. The app is needed only for the reply box.