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
SubjectPublicKeyInfoof the leaf certificate (64 chars). On Android this isSHA-256(cert.publicKey.encoded). - Verification rules (identical on both sides):
- Peer presents exactly one certificate. Compute
fp. - If any trusted device record has
id == fp→ session is paired with that device. - 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 oneUnpair(see “Stale trust” below). - The
Hello.device_idMUST equalfp; otherwise close.
- Peer presents exactly one certificate. Compute
- 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
Hellois seen. - Framing:
u32big-endian length (≤ 4 MiB) + protobuftether.v1.Envelope.seqstarts at 1 and increases by 1 per sent frame; receivers only log gaps. - Keepalive: send
Pingevery 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 untilsizebytes are sent or the stream is closed. The receiver mapsref_idto 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 recordsid=<device_id>,name=<name>,kind=desktop|phone|tablet,pv=1. Linux publishes/browses via Avahi D-Bus; Android viaNsdManager. - UDP beacon: protobuf
Beaconsent to255.255.255.255:7360and 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.
- Initiator sends
PairRequest{nonce = 32 random bytes, qr_proof?}. - Responder replies at once with
PairResponse{nonce = 32 random bytes, qr_accepted}. - Both compute the SAS:
where(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 digitsfp_*are the 64-char ASCII hex strings andnonce_*the raw 32 bytes. - Each side shows
sasand the peer name; the user confirms on both devices. On confirm a side sendsPairConfirm; on reject or 60 s timeout,PairReject{reason}. - The devices are paired when a side has both sent and received
PairConfirm. It then persists{device_id, name, kind, certificate DER}as trusted. Unpairfrom 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 withUnpaironce 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
Unpairon the next session with that peer. - A device whose session dies right after
HelloMUST 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
Helloboth ways (capabilities exchanged).- Phone sends
DeviceInfoandBatteryimmediately, thenBatteryon change (level change or charging state change). - Phone sends
NotificationPostedfor every currently active notification (filtered, see below) and then live updates;NotificationRemovedon removal. - Desktop requests icons by
BlobRequest{hash}; phone answersBlob. Desktop caches by hash. - Desktop sends
NotificationActionRequest/NotificationDismiss; phone acts and the resulting removal flows back asNotificationRemoved.
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.
| Capability | Since | Frames it enables |
|---|---|---|
battery | M1 | Battery |
deviceinfo | M1 | DeviceInfo |
notifications | M1 | NotificationPosted/Removed, NotificationActionRequest, NotificationDismiss |
notifications.reply | M1 | remote-input actions |
blobs | M1 | BlobRequest/Blob (icons, album art) |
disconnect | M2 | Disconnect (hold semantics, see below) |
streams | M2 | secondary stream connections (StreamOpen), TransferProgress, TransferCancel |
messages | M2 | conversations/messages sync, SendMessage (SMS) |
messages.mms | M2 | attachments in Message, AttachmentRequest, MMS send |
contacts | M2 | ContactsRequest/Delta/Changed |
media | M2 | MediaSessions, MediaCommand |
volume | M2 | PhoneVolume, SetPhoneVolume |
dnd | M2 | DndState, SetDnd |
ring | M2 | RingPhone |
connectivity | M2 | Connectivity |
clipboard | M2 | Clipboard, ShareText |
files | M2 | FileOffer, FileAccept (requires streams) |
photos | M2 | MediaQuery/Items, ThumbnailRequest/Thumbnail, MediaFetch, MediaDelete, MediaChanged |
calls | M3 | CallState, CallCommand (answer/reject/hang up/mute/route/silence), CallCommandResult |
calls.dial | M3 | CallCommand{DIAL} |
calllog | M3 | CallLogRequest, CallLog, CallLogChanged |
bluetooth | M3 | BtIdentity, BtRequest |
enhance | M4 | AdbLink, AdbWifiState, AdbWifiRequest (see “Enhanced tier”) |
apps | M4.2 | AppListRequest, 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;0means 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. Disconnectis a restricted frame (paired sessions only). A peer that does not announcedisconnectis 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 ashold_seconds = 0but 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_idties the stream to a control-connection request: atransfer_id(FileOffer), or arequest_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_idis unknown for up to 10 s waiting for the control frame, then close it. Receivers MUST reject a stream whosesizeexceeds 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 = 0xFFFFFFFFcancels the whole transfer. A side that cannot provide a requested stream (file vanished, permission missing) sendsTransferCancelwithreason = "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)
- On connect the desktop sends
ConversationsRequest{since_ms}with the newestdate_msin its cache (0 on first sync). The phone answers oneConversationList{threads, complete}. - 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 sendsMessagesRequest{thread_id = "", since_ms}. - 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. - 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 opensStreamOpen{ATTACHMENT, ref_id = request_id, index = n, size}. The phone answersSendMessageResult{request_id, ok, error, message_id}once the platform reported the result (sent PendingIntent), orok = falsewith a reason on failure or 60 s timeout. AttachmentRequest{request_id, part_id}→ the phone opensStreamOpen{ATTACHMENT, ref_id = request_id, index = 0, size, name, mime}or sendsTransferCancel{reason = "not_found"}.- 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.
| Action | Fields | Phone implementation |
|---|---|---|
ANSWER | call_id | TelecomManager.acceptRingingCall() |
REJECT | call_id | TelecomManager.endCall() on a ringing call |
HANGUP | call_id | TelecomManager.endCall() |
DIAL | number, sub_id | TelecomManager.placeCall(tel:…) with the SIM’s PhoneAccountHandle |
MUTE | call_id, on | AudioManager.setMicrophoneMute(on) |
ROUTE | call_id, route | AudioManager.setCommunicationDevice (BLUETOOTH = the device whose address matches the desktop’s BtIdentity.mac; PHONE = earpiece; SPEAKER = speaker) |
SILENCE | call_id | TelecomManager.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-opMANAGE_ONGOING_CALLSis 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, wheretelecom add-or-remove-call-companion-apphas no effect), ANSWER/REJECT/HANGUP act on the addressedCall(answer,reject,disconnect), MUTE usesInCallService.setMutedand ROUTE usesInCallService.requestCallEndpointChange(BLUETOOTH prefers the endpoint named like the desktop’sBtIdentity.name). - Without the companion service, ROUTE answers
ok = false, error = "route_unsupported"(setCommunicationDeviceonly routes the app’s own audio, ADR-0015); MUTE usesAudioManager.setMicrophoneMute; HANGUP ends the foreground call whatevercall_idsays (TelecomManager.endCall). - SILENCE:
silenceRinger()needsMODIFY_PHONE_STATEor the dialer role; onSecurityExceptionthe phone mutes the ring stream if it has DND access (restored when ringing stops), elseerror = "silence_unsupported". - Fallback call state (no companion service) comes from the aggregate
IDLE/RINGING/OFFHOOK telephony state per SIM: an outgoing call is
ACTIVEwithconnected_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_DISCOVERABLEforBtRequest{PAIR}additionally needsBLUETOOTH_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 writesSettings.Global adb_wifi_enabledand answers withAdbWifiState.AdbLink{token}(phone → desktop): sent when the app’s shell-only receiverorg.tether.android/.enhance.AdbLinkReceiver(permissionandroid.permission.DUMP) receivesam 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
- The desktop has an authorised adb device linked to a paired phone.
adb reverse localabstract:tether_<nonce> tcp:<port>to the daemon’s listener on 127.0.0.1.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.- The helper connects to
localabstract:tether_<nonce>and sendsShellEnvelope{connect{token, CONTROL}}, thenShellEnvelope{hello}. A wrong token closes the connection. - Requests carry a
request_idand are answered withShellResult(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 sendShellClipboardon every primary-clip change; the daemon treats it likeClipboardfrom the app.ShellClipboardtowards the helper sets the phone clipboard.GrantRequest{items, apply}→GrantResultwith the state of each item read back after the attempt. Item names are fixed (seeshell.proto).DisplayPower{on}switches the panel outside a mirror.
App streaming and phone audio (M4.2)
- App list (
apps, normal app):AppListRequest→AppListwith every launchable app (package, label, icon blob hash).AppListChangedtells 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 (newMirrorMeta). The display and its content are destroyed when the mirror ends; when the last task on it goes away the helper ends the mirror withapp_closed. Several mirrors run at once. Needs abilitiesdisplay.newandmirror.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 answersShellResult. The daemon decodes and plays it.AudioStop, or closing the connection, ends it;AudioEndedreports 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}), sendsCameraMeta(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 answersShellResult. The helper takes the listed size and rate closest to the request;CameraMetasays 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 aCameraStopand a newCameraStart.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
CameraStartanswers onlyShellResult(noCameraEnded), withbad_request,unsupported,busy,not_found: camera,camera_disabled,camera_disconnected(camera in use),camera_errororencoder_error. CameraEndedis sent once the camera is released, about 0.3 s afterCameraStop. ACameraStartthat arrives while a stopped capture is still closing waits up to 3 s. On a switch the old capture’sCameraEndedarrives before the newShellResult; match bycamera_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.fpsis 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 = 0at start derives from the main display;dpi = 0in a resize keeps the density, so a larger window shows more. app_closedmeans “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,
InputTextand the paste fallback into app displays were reliable on the A55 (15/15, 15/15, 6/6); no UHID path exists. PLAYBACKandPLAYBACK_DUPtake media, game, navigation, sonification, accessibility and assistant audio. Ringtones, alarms, notification sounds and voice calls stay on the phone.OUTPUTtakes everything.AudioEndedis sent for every started capture, also afterAudioStop. Packets are 20 ms Opus at 48 kHz stereo; the config packet isOpusHead.- Limits: eight mirrors, display sides 64 to 4096, one audio capture.
screen_off,stay_awakeandshow_touchesare 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
ShellHellotakes 1–2 s. The helper dials the MIRROR connection before it answersMirrorStart. It exits with 0 when stdin or the control connection closes (1 crash, 2 usage or no token, 3 cannot connect); stderr lines aretether-helper: <I|W|E> text. MirrorEndedis sent for every started mirror, also afterMirrorStop(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 answerunsupported: codec;StartAppanswersunsupporteduntil M4.2. InputTouchwithmouse:buttonsis the mask after the event, a move with no button is a hover, pressure 0 on down/move means 1.0.InputTextfalls back to a paste for unmapped characters and restores the previous clip;InputPastedoes not restore.ClipboardWatchreports changes only, not the current clip.AdbLinkgoes to every paired session that announcedenhance; with none connected the token is kept for 60 s.AdbWifiState.can_changeis 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.