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

Tether wire protocol v1

Status: normative for Milestones 1–3. Changes require an ADR and a bump of protocol_version only when incompatible. Milestone 2 additions are purely additive (new Envelope fields 13 and 70–127, new capabilities); a v1 peer that lacks a capability never receives the corresponding frames.

Transport

  • TCP, fixed port 7360 on both desktop and phone. Both sides listen; either may dial.
  • TLS 1.3 only, ALPN tether/1, mutual certificates. Certificates are self-signed ECDSA P-256 (SHA-256 signature). Validity is irrelevant: verifiers never check dates, names or chains, only the public key.
  • Device id = lowercase hex SHA-256 of the DER SubjectPublicKeyInfo of the leaf certificate (64 chars). On Android this is SHA-256(cert.publicKey.encoded).
  • Verification rules (identical on both sides):
    1. Peer presents exactly one certificate. Compute fp.
    2. If any trusted device record has id == fp → session is paired with that device.
    3. Else accept the connection as unpaired (TOFU). Unpaired sessions may only exchange Hello, Ping/Pong, PairRequest, PairResponse, PairConfirm, PairReject, Unpair. Anything else is ignored and answered with one Unpair (see “Stale trust” below).
    4. The Hello.device_id MUST equal fp; otherwise close.
  • If two connections to the same peer exist, the one dialled by the device with the lexicographically smaller device id is kept; the other is closed quietly after its Hello is seen.
  • Framing: u32 big-endian length (≤ 4 MiB) + protobuf tether.v1.Envelope. seq starts at 1 and increases by 1 per sent frame; receivers only log gaps.
  • Keepalive: send Ping every 15 s when idle; drop the connection if nothing (any frame) is received for 45 s. Reconnect with exponential backoff 1 s → 60 s.
  • Secondary connections: for bulk data, the sender opens another TLS connection to the same peer (same verification), sends one frame StreamOpen{purpose, ref_id, index, size} and then raw bytes until size bytes are sent or the stream is closed. The receiver maps ref_id to a pending transfer. (Not used in M1 except for blobs > 256 KiB, which M1 never produces.)

Discovery

  • mDNS/DNS-SD service _tether._tcp.local, port 7360, TXT records id=<device_id>, name=<name>, kind=desktop|phone|tablet, pv=1. Linux publishes/browses via Avahi D-Bus; Android via NsdManager.
  • UDP beacon: protobuf Beacon sent to 255.255.255.255:7360 and to the subnet broadcast every 5 s while discoverable (desktop: always while running; phone: while the app is in the foreground or for 60 s after wake). Receivers treat beacons as hints and dial the sender’s TCP port.
  • Manual: user enters host[:port]; QR carries addresses (below).

Pairing

Pairing runs on an unpaired session. The initiator is whichever side the user tapped first; both flows are symmetric after the first message.

  1. Initiator sends PairRequest{nonce = 32 random bytes, qr_proof?}.
  2. Responder replies at once with PairResponse{nonce = 32 random bytes, qr_accepted}.
  3. Both compute the SAS:
    (fp_lo, nonce_lo), (fp_hi, nonce_hi) = sort the two (device_id, nonce) pairs by device_id (ASCII)
    digest = SHA-256( "tether-sas-v1" || fp_lo || fp_hi || nonce_lo || nonce_hi )
    sas    = (first 4 bytes of digest as u32 big-endian) mod 1_000_000, zero-padded to 6 digits
    
    where fp_* are the 64-char ASCII hex strings and nonce_* the raw 32 bytes.
  4. Each side shows sas and the peer name; the user confirms on both devices. On confirm a side sends PairConfirm; on reject or 60 s timeout, PairReject{reason}.
  5. The devices are paired when a side has both sent and received PairConfirm. It then persists {device_id, name, kind, certificate DER} as trusted.
  6. Unpair from either side removes the record; the receiver removes its record too.

Stale trust

Trust can become asymmetric (one side unpaired while the other was offline). Rules:

  • A side that receives a restricted frame (anything other than Hello, Ping, Pong, Pair*) on an unpaired session MUST reply with Unpair once and MUST ignore further restricted frames on that session. It SHOULD keep the connection open so the user can re-pair over it.
  • A device that removes a pairing while the peer is unreachable MUST send Unpair on the next session with that peer.
  • A device whose session dies right after Hello MUST apply reconnect backoff (1 s → 60 s); discovery hints do not bypass that backoff.

QR fast path

The desktop renders tether://pair?v=1&id=<device_id>&n=<url-encoded name>&a=<ip:port>&a=<ip2:port>&s=<base64url 16-byte secret>. The secret is single-use and valid for 5 minutes. The phone connects to the first reachable address, and sends PairRequest{nonce, qr_proof = HMAC-SHA256(key = secret, msg = ASCII phone device_id)}. If the proof is valid the desktop replies PairResponse{nonce, qr_accepted = true} and immediately PairConfirm; the phone, having scanned the QR, auto-sends PairConfirm when qr_accepted is true. No SAS prompt is shown on either side. Invalid proof → PairReject{reason = "mismatch"}.

Test vectors

fp1    = 5b7ad2d123b4cbc97dddc13b75f67df2f68a9150930c9476d059ea53e9b0c915
fp2    = ad75ecdda3a53bf1323b6f6ab6c3ba3c74acf0effb7fc6402e521ab36868a837
nonce1 = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f   (belongs to fp1)
nonce2 = 202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f   (belongs to fp2)
SAS    = 754516

fp_a   = 00 * 32 (hex "000…0"), fp_b = ff * 32 (hex "fff…f"), both nonces = 32 zero bytes
SAS    = 246492

qr_secret (16 bytes) = 000102030405060708090a0b0c0d0e0f
qr_proof for requester fp2 = 9c62474aca6bd1420e62c94879ee5cb6a2c8fd7ac73d6c451d0c30f5b7596565

Session flow after pairing

  1. Hello both ways (capabilities exchanged).
  2. Phone sends DeviceInfo and Battery immediately, then Battery on change (level change or charging state change).
  3. Phone sends NotificationPosted for every currently active notification (filtered, see below) and then live updates; NotificationRemoved on removal.
  4. Desktop requests icons by BlobRequest{hash}; phone answers Blob. Desktop caches by hash.
  5. Desktop sends NotificationActionRequest / NotificationDismiss; phone acts and the resulting removal flows back as NotificationRemoved.

Notification filtering on the phone

Skip: the phone app’s own notifications, group summaries, FLAG_ONGOING_EVENT foreground-service notifications unless the user opted in, media transport notifications (CATEGORY_TRANSPORT, handled by the media feature later), notifications from packages in the user’s blocklist. Everything else is sent, including silent ones (flagged silent).

Capabilities

A feature is active only when both sides list the required capability.

CapabilitySinceFrames it enables
batteryM1Battery
deviceinfoM1DeviceInfo
notificationsM1NotificationPosted/Removed, NotificationActionRequest, NotificationDismiss
notifications.replyM1remote-input actions
blobsM1BlobRequest/Blob (icons, album art)
disconnectM2Disconnect (hold semantics, see below)
streamsM2secondary stream connections (StreamOpen), TransferProgress, TransferCancel
messagesM2conversations/messages sync, SendMessage (SMS)
messages.mmsM2attachments in Message, AttachmentRequest, MMS send
contactsM2ContactsRequest/Delta/Changed
mediaM2MediaSessions, MediaCommand
volumeM2PhoneVolume, SetPhoneVolume
dndM2DndState, SetDnd
ringM2RingPhone
connectivityM2Connectivity
clipboardM2Clipboard, ShareText
filesM2FileOffer, FileAccept (requires streams)
photosM2MediaQuery/Items, ThumbnailRequest/Thumbnail, MediaFetch, MediaDelete, MediaChanged
callsM3CallState, CallCommand (answer/reject/hang up/mute/route/silence), CallCommandResult
calls.dialM3CallCommand{DIAL}
calllogM3CallLogRequest, CallLog, CallLogChanged
bluetoothM3BtIdentity, BtRequest
enhanceM4AdbLink, AdbWifiState, AdbWifiRequest (see “Enhanced tier”)
appsM4.2AppListRequest, AppList, AppListChanged (icons need blobs)

The phone advertises a capability only when it holds the permission the feature needs (e.g. messages requires READ_SMS); it re-sends nothing when a permission is granted later — the next connection carries the new list, and the desktop treats Hello.capabilities as the source of truth per session.

Intentional disconnect and hold (M2, ADR-0012)

A user-initiated “Disconnect” on either side sends Disconnect{hold_seconds, reason} on the control connection and then closes it. Rules:

  • The sender stops auto-reconnecting to that peer (holds) for hold_seconds; 0 means until the local user presses Connect, pairs again, or the peer dials in. The sender still accepts inbound connections from the peer.
  • The receiver, on Disconnect, also holds for the same duration: it MUST NOT dial the peer (reconnect loop and discovery hints both pause) until the hold expires, the local user acts, or the peer dials in. A held device remains paired; nothing is persisted — a process restart clears the hold.
  • Disconnect is a restricted frame (paired sessions only). A peer that does not announce disconnect is simply closed; the other side then applies the pre-M2 behaviour (60 s backoff).
  • reason = "shutdown" is sent by a daemon or app that is exiting; receivers SHOULD treat it as hold_seconds = 0 but resume dialling as soon as discovery sees the peer again (shutdown is not a user intent to stay apart).

Secondary streams (M2, ADR-0014)

Bulk bytes never travel on the control connection. The side that has the bytes dials a new TLS connection to the peer (same certificates, same verification; the peer MUST be paired, otherwise the connection is closed at once) and sends exactly one framed Envelope{StreamOpen{purpose, ref_id, index, size, name, mime}} — no Hello. Then it writes exactly size raw bytes and half-closes (shutdown(SHUT_WR)). The receiver reads size bytes, closes, and reports completion on the control connection where the feature defines it.

  • ref_id ties the stream to a control-connection request: a transfer_id (FileOffer), or a request_id (SendMessage, AttachmentRequest, MediaFetch). Ids are random strings (UUID v4 recommended) chosen by the side that created the request. The receiver maps (peer, ref_id, index) to a pending transfer.
  • Ordering: the control frame and the stream travel on different TCP connections and may arrive in either order. A receiver MUST hold a stream whose ref_id is unknown for up to 10 s waiting for the control frame, then close it. Receivers MUST reject a stream whose size exceeds the size announced in the control frame.
  • At most 4 concurrent streams per peer; senders queue beyond that.
  • Flow control and completion are TCP’s; TransferProgress{ref_id, index, bytes} is sent by the receiver at most every 500 ms per stream for UI only.
  • Cancellation: either side closes the stream connection and SHOULD send TransferCancel{ref_id, index, reason} on the control connection; index = 0xFFFFFFFF cancels the whole transfer. A side that cannot provide a requested stream (file vanished, permission missing) sends TransferCancel with reason = "not_found" or "error:<text>" instead of opening a stream.
  • Received files are written to a temporary name in the destination directory and renamed on completion; partial files are deleted on cancel. Names from the wire are sanitised to a base name (no path separators, no leading dot, no control characters) and made unique (name (2).ext).
  • The stream dialler uses the peer’s control-connection address; the desktop listens on 7360, the phone listens on 7360 while its service runs.

Purposes: FILE (file transfer), ATTACHMENT (MMS part), MEDIA (gallery item), BLOB (reserved for > 256 KiB blobs, unused), VIDEO/AUDIO (M4).

Feature flows (M2)

All requests below are desktop → phone unless stated. Pushes are phone → desktop and happen on connect (snapshot) and on change.

Messages (messages, messages.mms)

  1. On connect the desktop sends ConversationsRequest{since_ms} with the newest date_ms in its cache (0 on first sync). The phone answers one ConversationList{threads, complete}.
  2. The desktop pages threads it does not have with MessagesRequest{request_id, thread_id, before_ms, limit ≤ 200} → Messages{request_id, thread_id, messages (newest first), more}. To catch up after being offline it sends MessagesRequest{thread_id = "", since_ms}.
  3. The phone pushes MessageEvent{message, deleted} on every provider change (new inbox/sent message, status change, deletion). Pushes are best-effort; the desktop reconciles with step 1 on the next connect.
  4. Sending: SendMessage{request_id, addresses, body, sub_id, attachments}. Without attachments and with one address the phone sends a (multipart) SMS; otherwise an MMS. For each attachment the desktop opens StreamOpen{ATTACHMENT, ref_id = request_id, index = n, size}. The phone answers SendMessageResult{request_id, ok, error, message_id} once the platform reported the result (sent PendingIntent), or ok = false with a reason on failure or 60 s timeout.
  5. AttachmentRequest{request_id, part_id} → the phone opens StreamOpen{ATTACHMENT, ref_id = request_id, index = 0, size, name, mime} or sends TransferCancel{reason = "not_found"}.
  6. Read state and deletion are desktop-local (ADR-0011).

Contacts (contacts)

ContactsRequest{known[{uid, version}]} → one or more ContactsDelta{upserts[{uid, version, vcard}], deleted[], complete} frames (≤ 2 MiB each; deleted and complete = true on the last). The phone pushes ContactsChanged{} (throttled to one per 5 s) when the provider changes; the desktop re-requests. vCard 3.0 with FN, N, TEL;TYPE=…, EMAIL, PHOTO;ENCODING=b;TYPE=JPEG (≤ 256 px), X-TETHER-STARRED:1 for favourites.

Media sessions and volume (media, volume)

Phone pushes MediaSessions{sessions} (first = active) on connect and on change, throttled to 2/s; position is position_ms at phone time position_ts_ms and the desktop extrapolates with playback_speed. Album art is fetched by BlobRequest{art_hash} (JPEG or PNG, Blob.mime says which). MediaCommand{session_id, action, position_ms}; SEEK uses position_ms. PhoneVolume{streams} pushed on connect/change; SetPhoneVolume{stream, level}.

DND, ring, connectivity (dnd, ring, connectivity)

DndState{filter, can_change} pushed on connect/change; SetDnd{filter} is ignored (and the phone re-pushes the current state) while can_change is false. RingPhone{start}: the phone rings at maximum alarm volume with vibration and shows a full-screen activity with a Stop button regardless of silent mode or DND; the phone stops after 60 s or on RingPhone{start = false}. Connectivity{sims, wifi_ssid, wifi_level, airplane_mode} pushed on connect and on change (throttled to one per 10 s).

Clipboard and share (clipboard)

Clipboard{text, ts_ms} in either direction; the receiver replaces its clipboard and MUST NOT echo it back. Text is capped at 1 MiB. ShareText{text, url, open} phone → desktop from the Android share sheet.

Files (files)

FileOffer{transfer_id, files} → FileAccept{transfer_id, accepted, reason}. Receivers auto-accept offers from paired devices unless the user disabled it (then the UI asks). After acceptance the sender opens one FILE stream per file, index = position in files. The receiver stores into its downloads directory (~/Downloads/Tether/ on Linux, Downloads/Tether/ via MediaStore on Android) and the sender’s UI tracks TransferProgress. An offer that is not answered within 60 s is cancelled by the sender.

Photos (photos)

MediaQuery{request_id, kind, limit ≤ 500, before_ms, album} → MediaItems{request_id, items (newest first), more}. before_ms is inclusive (date_ms <= before_ms) so items that share the boundary timestamp are never skipped between pages; the desktop de-duplicates items by id. ThumbnailRequest{id, max_px} → Thumbnail{id, max_px, mime, data ≤ 256 KiB}; the desktop caches thumbnails per device and id. MediaFetch{request_id, id} → StreamOpen{MEDIA, ref_id = request_id, size, name, mime} or TransferCancel. MediaDelete{request_id, ids} → MediaDeleteResult{request_id, deleted, failed, needs_confirmation}; when Android requires on-phone confirmation the phone sends a first result with needs_confirmation = true and a final one when the user answered. MediaChanged{} pushed (throttled to one per 5 s) when MediaStore changes.

Calls (M3, ADR-0015)

Call control uses the Tether connection; call audio uses Bluetooth HFP with the desktop as hands-free unit and the phone as audio gateway. The two are independent: without a Bluetooth link the desktop can still see, answer, reject, hang up, mute and dial, and audio stays on the phone.

Capabilities: the phone advertises calls when READ_PHONE_STATE and ANSWER_PHONE_CALLS are granted (numbers additionally need READ_CALL_LOG), calls.dial with CALL_PHONE, calllog with READ_CALL_LOG, bluetooth with BLUETOOTH_CONNECT. The desktop advertises all four; it advertises bluetooth only when BlueZ is present.

Call state

The phone pushes CallState{calls, can_control, can_dial} on connect when any call exists, and on every change (new call, status, mute, route), at most every 200 ms. It is always the full list. A call that ends is sent once with status ENDED and omitted afterwards. Call.id is stable for the call’s lifetime. photo_hash refers to a contact photo fetchable with BlobRequest.

The phone pushes the state within 500 ms of RINGING so the desktop banner appears in about a second. An incoming call on a session with no calls capability on the desktop still produces the normal notification mirror.

Commands

CallCommand{request_id, call_id, action, number, sub_id, on, route} → CallCommandResult{request_id, ok, error} once the platform call returned, then the resulting CallState.

ActionFieldsPhone implementation
ANSWERcall_idTelecomManager.acceptRingingCall()
REJECTcall_idTelecomManager.endCall() on a ringing call
HANGUPcall_idTelecomManager.endCall()
DIALnumber, sub_idTelecomManager.placeCall(tel:…) with the SIM’s PhoneAccountHandle
MUTEcall_id, onAudioManager.setMicrophoneMute(on)
ROUTEcall_id, routeAudioManager.setCommunicationDevice (BLUETOOTH = the device whose address matches the desktop’s BtIdentity.mac; PHONE = earpiece; SPEAKER = speaker)
SILENCEcall_idTelecomManager.silenceRinger()

In-call DTMF is not available to non-dialer apps and is not part of the protocol (documented gap, ADR-0015).

Android implementation (deviations from the table above, M3):

  • When Telecom binds the phone’s InCallService (it does once the app-op MANAGE_ONGOING_CALLS is allowed: adb shell appops set org.tether.android MANAGE_ONGOING_CALLS allow, a one-time grant that survives reboots; verified on Android 16 / One UI 8.5, where telecom add-or-remove-call-companion-app has no effect), ANSWER/REJECT/HANGUP act on the addressed Call (answer, reject, disconnect), MUTE uses InCallService.setMuted and ROUTE uses InCallService.requestCallEndpointChange (BLUETOOTH prefers the endpoint named like the desktop’s BtIdentity.name).
  • Without the companion service, ROUTE answers ok = false, error = "route_unsupported" (setCommunicationDevice only routes the app’s own audio, ADR-0015); MUTE uses AudioManager.setMicrophoneMute; HANGUP ends the foreground call whatever call_id says (TelecomManager.endCall).
  • SILENCE: silenceRinger() needs MODIFY_PHONE_STATE or the dialer role; on SecurityException the phone mutes the ring stream if it has DND access (restored when ringing stops), else error = "silence_unsupported".
  • Fallback call state (no companion service) comes from the aggregate IDLE/RINGING/OFFHOOK telephony state per SIM: an outgoing call is ACTIVE with connected_ms = off-hook time (the far end answering is not visible), and a waiting call leaving RINGING is assumed answered.
  • Error strings used in CallCommandResult.error: calls_disabled, dial_disabled, permission_denied, unknown_call, no_call, not_ringing, invalid_number, route_unsupported, route_unavailable, route_timeout, route_failed: …, mute_failed, end_call_failed, silence_unsupported, unsupported_action, error: ….
  • ACTION_REQUEST_DISCOVERABLE for BtRequest{PAIR} additionally needs BLUETOOTH_ADVERTISE; without it the guidance opens Bluetooth settings (One UI is discoverable while that screen is open).

Call log

CallLogRequest{request_id, since_ms, before_ms, limit ≤ 500} → CallLog{request_id, entries (newest first), more}. before_ms is inclusive; the desktop de-duplicates by id. On connect the desktop requests since_ms = newest cached date (0 on first sync) and pages older entries in the background. The phone pushes CallLogChanged{added} when entries appear (throttled to one per 2 s); missed calls have type = MISSED, new = true.

Bluetooth identity and pairing

Both sides send BtIdentity{mac, name, enabled, bonded_to_peer, hfp_connected} on connect (when bluetooth is shared) and whenever any field changes. The phone’s mac comes from BluetoothAdapter.getAddress() where allowed; Android returns 02:00:00:00:00:00 to apps, so the phone instead reports the empty string and the desktop matches the phone by name among BlueZ devices and, once bonded, by bonded_to_peer (the phone checks its bonded devices for the desktop’s mac, which it can see). The desktop drives pairing: it sends BtRequest{PAIR} (the phone shows “Pair with <PC> over Bluetooth” guidance and makes itself discoverable via ACTION_REQUEST_DISCOVERABLE if needed), then discovers and pairs through BlueZ with numeric comparison shown on both sides. After bonding the desktop sends BtRequest{CONNECT} or connects HFP itself.

Enhanced tier (M4, ADR-0016, ADR-0017)

Two parties on the phone take part: the app (the paired peer, normal Tether connection) and the shell helper (uid 2000, started by the desktop through adb, its own sockets and protocol in shell.proto).

App side (enhance)

  • AdbWifiState (phone → desktop on connect and on change): developer options, USB debugging, Wireless debugging, and whether the app can switch Wireless debugging itself (WRITE_SECURE_SETTINGS).
  • AdbWifiRequest{enable} (desktop → phone): the app writes Settings.Global adb_wifi_enabled and answers with AdbWifiState.
  • AdbLink{token} (phone → desktop): sent when the app’s shell-only receiver org.tether.android/.enhance.AdbLinkReceiver (permission android.permission.DUMP) receives am broadcast -n … --es token <token>. The desktop matches the token to the adb device it sent the broadcast through and stores serial ↔ device id.

Helper lifecycle

  1. The desktop has an authorised adb device linked to a paired phone.
  2. adb reverse localabstract:tether_<nonce> tcp:<port> to the daemon’s listener on 127.0.0.1.
  3. adb shell CLASSPATH=<pm path of org.tether.android> app_process / org.tether.shell.Main tether_<nonce>; the daemon writes the one-time token and a newline to the helper’s stdin and keeps stdin open. The helper exits when stdin or the control connection closes.
  4. The helper connects to localabstract:tether_<nonce> and sends ShellEnvelope{connect{token, CONTROL}}, then ShellEnvelope{hello}. A wrong token closes the connection.
  5. Requests carry a request_id and are answered with ShellResult (or the specific result message). Unknown messages are ignored.

Mirroring

MirrorStart → the helper opens a second connection, sends connect{token, MIRROR, ref_id = mirror_id}, then ShellResult. From then on that connection uses u8 kind, u32 length, payload records: MirrorMeta (kind 1), video packets (kind 2: u64 PTS in µs, u8 flags, Annex-B access unit) and, towards the phone, InputEvent (kind 3). A rotation or resize restarts the encoder and sends a new MirrorMeta followed by codec config and a key frame. Input coordinates are in pixels of the frame size the sender last saw; the helper scales them and drops events with a stale frame size. Closing the connection from either side ends the mirror; MirrorEnded is sent on the control channel when the phone side ends it.

screen_off turns the panel off for the mirror’s lifetime and is restored when the last mirror that asked for it ends or the helper exits (a detached cleanup process covers a killed helper). stay_awake keeps the device from sleeping while mirroring.

Clipboard, grants, display power

  • ClipboardWatch{on} makes the helper send ShellClipboard on every primary-clip change; the daemon treats it like Clipboard from the app. ShellClipboard towards the helper sets the phone clipboard.
  • GrantRequest{items, apply} → GrantResult with the state of each item read back after the attempt. Item names are fixed (see shell.proto).
  • DisplayPower{on} switches the panel outside a mirror.

App streaming and phone audio (M4.2)

  • App list (apps, normal app): AppListRequest → AppList with every launchable app (package, label, icon blob hash). AppListChanged tells the desktop to ask again. Needs no adb; starting an app in its own window does.
  • App window: MirrorStart{new_display{w, h, dpi}, start_package} creates a virtual display, launches the app on it and mirrors it; input on that MIRROR connection goes to that display. MirrorConfigure{resize} changes the display size (new MirrorMeta). The display and its content are destroyed when the mirror ends; when the last task on it goes away the helper ends the mirror with app_closed. Several mirrors run at once. Needs abilities display.new and mirror.input.
  • StartApp{package, display_id} launches an app on an existing display.
  • Phone audio: AudioStart{audio_id, source} → the helper opens an AUDIO connection (AudioMeta, then Opus packets, record framing as for mirrors) and answers ShellResult. The daemon decodes and plays it. AudioStop, or closing the connection, ends it; AudioEnded reports the phone side. One capture at a time. Sources and their abilities: OUTPUT (audio.output), PLAYBACK (audio.playback), PLAYBACK_DUP (audio.playback_dup).

Phone as webcam (M4.3, ADR-0019)

  • Ability camera: the helper could read the camera list at start.
  • CameraListRequest → CameraList: per camera its Camera2 id, facing, sensor orientation, the sizes it delivers straight to a video encoder, its fixed frame rates, whether it has a torch, and its maximum zoom.
  • CameraStart{camera_id, device_camera | facing, width, height, fps, bitrate, torch, zoom} → the helper opens the camera, opens a CAMERA connection (connect{token, CAMERA, ref_id = camera_id}), sends CameraMeta (kind 1) and then video packets (kind 2, as on a MIRROR connection: codec config first, then access units starting with a key frame), and answers ShellResult. The helper takes the listed size and rate closest to the request; CameraMeta says what is in use. Frames are as the sensor delivers them; the desktop rotates and flips.
  • CameraConfigure{bitrate, torch, zoom, request_keyframe} changes a running capture. A different camera or size is a CameraStop and a new CameraStart.
  • CameraStop, or closing the connection, ends it. CameraEnded{reason} is sent for every started capture: stopped, camera_disconnected (another app took the camera), camera_disabled (privacy switch or device policy), camera_error, encoder_error, socket_closed.
  • One capture at a time (busy). Nothing travels desktop → helper on the CAMERA connection.

Helper behaviour for M4.3 (verified on a Galaxy A55, Android 17):

  • A failed CameraStart answers only ShellResult (no CameraEnded), with bad_request, unsupported, busy, not_found: camera, camera_disabled, camera_disconnected (camera in use), camera_error or encoder_error.
  • CameraEnded is sent once the camera is released, about 0.3 s after CameraStop. A CameraStart that arrives while a stopped capture is still closing waits up to 3 s. On a switch the old capture’s CameraEnded arrives before the new ShellResult; match by camera_id.
  • Size choice: the same aspect ratio is preferred when that size has at least half the pixels of the largest fitting one. Portrait requests are not swapped; ask in landscape. CameraMeta.fps is 0 when the camera has no fixed rates.
  • H.264 High profile, key frame every 2 s, PTS is the sensor timestamp. Start to first key frame 0.84 to 1.47 s.
  • Shell has a low camera priority: any app that opens the camera takes it (camera_disconnected).
  • Test tools may pass only=<group,…> after the socket name to limit the start-up probes (mirror, clipboard, grants, display, apps, audio, panel, camera).

Helper behaviour for M4.2 (verified on a Galaxy A55, Android 16):

  • An app display is created without system decorations and with IME policy HIDE: the phone’s soft keyboard does not show for a focused field there; the PC keyboard types. The window must supply Back.
  • The display size equals the encoded size (rounded to the encoder’s alignment). dpi = 0 at start derives from the main display; dpi = 0 in a resize keeps the density, so a larger window shows more.
  • app_closed means “no visible task on the display for about 1.5 s”; it also fires when the phone user swipes the app out of Recents. Apps opened on a virtual display are listed in the phone’s Recents.
  • Key events, InputText and the paste fallback into app displays were reliable on the A55 (15/15, 15/15, 6/6); no UHID path exists.
  • PLAYBACK and PLAYBACK_DUP take media, game, navigation, sonification, accessibility and assistant audio. Ringtones, alarms, notification sounds and voice calls stay on the phone. OUTPUT takes everything.
  • AudioEnded is sent for every started capture, also after AudioStop. Packets are 20 ms Opus at 48 kHz stereo; the config packet is OpusHead.
  • Limits: eight mirrors, display sides 64 to 4096, one audio capture.
  • screen_off, stay_awake and show_touches are counted per mirror and restored when the last mirror that asked for them ends.

Helper behaviour worth knowing (M4.1, verified on a Galaxy A55, Android 16):

  • Start to ShellHello takes 1–2 s. The helper dials the MIRROR connection before it answers MirrorStart. It exits with 0 when stdin or the control connection closes (1 crash, 2 usage or no token, 3 cannot connect); stderr lines are tether-helper: <I|W|E> text.
  • MirrorEnded is sent for every started mirror, also after MirrorStop (stopped) and when the desktop closes the connection (socket_closed).
  • Video PTS is the encoder’s monotonic clock, not zero-based; config packets carry PTS 0. One mirror at a time (busy); H.265 and AV1 answer unsupported: codec; StartApp answers unsupported until M4.2.
  • InputTouch with mouse: buttons is the mask after the event, a move with no button is a hover, pressure 0 on down/move means 1.0. InputText falls back to a paste for unmapped characters and restores the previous clip; InputPaste does not restore.
  • ClipboardWatch reports changes only, not the current clip.
  • AdbLink goes to every paired session that announced enhance; with none connected the token is kept for 60 s. AdbWifiState.can_change is not refreshed by itself when the permission is granted later.

Error codes in ShellResult.error: unsupported (ability missing), bad_request, busy, not_found, encoder_error, denied, internal, optionally followed by : detail.

Test vectors (M2)

StreamOpen frame for a 5-byte FILE stream, ref_id "t1", index 0, name "a.txt":
  envelope seq=1 → protobuf bytes:
  08 01 e2 03 0f 08 01 12 02 74 31 20 05 2a 05 61 2e 74 78 74
  framed: 00 00 00 14 followed by the 20 bytes above, then the 5 raw bytes.