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

Debug Tetheron

This page shows where each part logs, how to watch what the daemon does, and how to investigate call audio, the enhanced tier and the mirror window.

Logs can contain names, phone numbers and notification texts. Remove them before you attach a log to an issue.

Read the daemon’s log

The daemon writes its log to standard error. For the installed daemon (a systemd user service), read the journal:

journalctl --user -u tetherd -f

A daemon started from the build tree logs to its terminal.

RUST_LOG chooses what is logged. It takes a default level and levels per module, separated by commas. Without it the level is info.

RUST_LOG=info,tetherd=debug ./target/debug/tetherd
ValueShows
infoStart-up, connections, pairing, state changes of each feature
info,tetherd=debugAlso each request of the daemon’s features and the output of the shell helper on the phone
tether_core=trace,tetherd=debugAlso the transport library (tether-core) in full detail

Message contents, keys, nonces and pairing codes are never logged above the level trace. Keep to that in new code (see Code style).

The lines to look for at start-up are listening on TCP port, the state of adb (adb <version> at <path> or enhanced tier unavailable), the state of the virtual camera (webcam:) and D-Bus: owning org.tether.Daemon. If the daemon exits with owning org.tether.Daemon (is another tetherd running?), another daemon has the name.

Watch the daemon’s events

tether-cli watch prints every D-Bus signal of the daemon until you press Ctrl+C: devices that appear and disappear, property changes, notifications, pairing, calls.

tether-cli watch

Run it in one terminal while you reproduce the problem in another. To watch a daemon with a private bus name, set TETHER_BUS_NAME for the command.

Inspect the daemon over D-Bus

The daemon owns org.tether.Daemon on the session bus. The object /org/tether/Daemon has the interface org.tether.Daemon1. Each device is an object /org/tether/Devices/<device-id> with the interface org.tether.Device1. The D-Bus API reference describes every member.

busctl --user tree org.tether.Daemon 2>/dev/null
busctl --user introspect org.tether.Daemon /org/tether/Daemon 2>/dev/null
busctl --user introspect org.tether.Daemon /org/tether/Devices/<device-id> 2>/dev/null
busctl --user get-property org.tether.Daemon /org/tether/Devices/<device-id> \
  org.tether.Device1 PairState Connected
busctl --user monitor org.tether.Daemon

Replace <device-id> with the full id from the output of tree.

busctl prints Unexpected signal <arg> direction value 'in'. many times for the daemon’s objects. The warning is harmless, and 2>/dev/null hides it.

introspect shows the current value of every property of a device. Be careful with busctl --user call: methods act on the real phone.

Read the phone app’s log

The Android app logs to logcat with tags that start with Tether..

adb logcat -v time | grep -E "Tether\."

To follow a few tags only:

adb logcat -s Tether.Calls Tether.CallLog Tether.Bt
AreaTags (each prefixed with Tether.)
Connection and pairingEngine, Session, Conn, Pairing, Trust, Identity, Streams, Network
DiscoveryNsd, Beacon
Service life cycleService, Boot
NotificationsNotifListener, NotifBridge, NotifFeature, NotifMap
Messages and contactsMessages, SmsRepo, SmsSend, MmsSend, Contacts, ContactsRepo
Media and phone controlsMedia, Volume, Dnd, Ring, Connectivity, Battery, DeviceInfo
Clipboard, files, photosClipboard, Files, Share, Photos, PhotosRepo, Blobs
CallsCalls, CallLog, Bt
Enhanced tierEnhance, Apps
User interfaceOnboarding, UiFlow, Qr, Cdm

Only a debug build of the app writes debug-level lines. A release build logs from info upwards.

The shell helper of the enhanced tier runs outside the app process and does not log to these tags. It writes lines of the form tether-helper: <I|W|E> text to its standard error, and the daemon logs them at debug level (RUST_LOG=info,tetherd=debug).

The app has no log export of its own. Save the log with adb. -d prints what is in the log buffer and exits:

adb logcat -d -v time | grep -E "Tether\." > tether-phone.log

Read the file before you share it, and remove anything personal.

Debug call audio

Call control travels over the connection between the phone and the daemon. Call audio uses Bluetooth hands-free through PipeWire, and most problems are there. Calls and call audio explains the design, and the call audio spike notes record how the current behaviour was found.

With a phone as the audio gateway, PipeWire creates the call’s nodes only while the phone holds the audio link (SCO) open. Only the phone can open that link.

  1. Read what the daemon decided:

    journalctl --user -u tetherd | grep -E 'CallAudio|call audio|echo'
    
  2. During a call, look at the PipeWire graph:

    pw-dump | grep -c headset-audio-gateway
    pw-link -l | grep -A2 bluez_
    
    You seeMeaning
    A count of 0The phone has not opened the audio link. The audio is on the phone. Look at the phone side (step 4).
    Nodes bluez_input.<MAC>.<n> and bluez_output.<MAC>.<n>The link is open. bluez_input has the class Stream/Output/Audio (the caller’s voice), bluez_output has Stream/Input/Audio (your microphone). Both are streams.
    The nodes exist but pw-link -l shows no links for themWirePlumber did not link them to the default sink and source. The daemon adds missing links about 2.5 seconds after the nodes appear.

    pw-top -b -n 2 shows whether the nodes are running. pw-dump can print a second JSON array when the graph changes while it runs. If you parse its output, parse the first value only.

  3. Read the session manager and the kernel:

    journalctl --user -u wireplumber -u pipewire
    sudo dmesg | grep -i sco
    
  4. Look at the phone:

    adb logcat | grep -E 'Tether\.Calls|InCallController'
    adb shell appops get org.tether.android MANAGE_ONGOING_CALLS
    adb shell dumpsys telecom | grep -i tether
    adb shell dumpsys bluetooth_manager
    

    The app-op must be allow. Without it Android does not bind the app’s in-call service, and the desktop cannot switch the audio route. In the dumpsys bluetooth_manager output, the section HeadsetService shows when the audio link opened and closed.

  5. If the far end hears an echo or loses your voice, check the echo canceller. The daemon runs it while a call uses the PC’s speakers and microphone. The setting is call_echo_cancel in config.toml.

Start capturing before the call starts. A snapshot of the graph every two seconds during a test call shows more than the logs do afterwards.

Debug adb and the enhanced tier

Start with the state the daemon reports:

tether-cli enhance <id> status

Then run the daemon with RUST_LOG=info,tetherd=debug to see the results of the adb commands and the helper’s output.

SymptomCause and what to do
enhanced tier unavailable: no adb on PATH in the daemon’s logInstall adb, or set adb_path in config.toml. The daemon needs adb 34.0.0 or newer.
The phone is unauthorizedUSB debugging authorisation can be lost after the cable is replugged or debugging is toggled. Accept the prompt on the phone again, with Always allow from this computer.
adb devices in your terminal does not show the phone that the daemon uses over Wi-FiExpected. By default the daemon runs its own adb server on port 5038 with its own key. A phone on a USB cable is reached through your normal adb server.
Mirroring over Wi-Fi stops working after Wireless debugging was toggledWireless debugging changes its port on every toggle. The daemon resolves it again before it connects. tether-cli enhance <id> rearm asks the phone to switch Wireless debugging back on.
Wireless debugging switches itself off again on a Samsung phoneOne UI does that when the current Wi-Fi network was not allowed for Wireless debugging. Turn Wireless debugging on by hand on the phone and choose Always allow on this network when asked. The daemon tries the automatic switch-on once per session.
The helper exits or does not starttether-cli enhance <id> restart, and read the tether-helper: lines in the daemon’s log. The helper’s exit codes are 0 (its input or the control connection closed), 1 (crash), 2 (wrong usage or no token) and 3 (cannot connect).
A script that calls adb pair or adb connect reports success although it failedBoth commands exit with 0 on failure. Parse their output.

android/tools/helper_test.py tests the helper without the daemon (see Test your changes). Platform findings lists the behaviour of adb and of vendor builds that the code works around.

Warning

Debugging tools that capture the phone’s screen or dump its user interface can expose private content. Read “Test against a real phone” in Test your changes first.

Debug the mirror window’s video

The phone-screen window and the app windows decode H.264 with GStreamer inside the GTK app (feature mirror). The pipeline is appsrc, h264parse, a decoder, a queue and a GTK 4 sink that is compiled into the app. Screen mirroring, app windows and webcam explains the design.

  1. Reproduce the problem without a phone first. The mock plays two embedded test clips through the same pipeline:

    RUST_LOG=tether=debug cargo run -p tether-gtk --features mock -- --mock --mirror 5b7a
    

    If the mock’s picture is fine, the problem is on the phone’s or the daemon’s side.

  2. Find out which decoder is used. The app logs video decoder selected. It tries vah264dec, nvh264dec and v4l2slh264dec (hardware), then avdec_h264 and openh264dec (software), and moves on to the next one when a decoder fails while running.

  3. Force a decoder to rule the others out. TETHER_VIDEO_DECODER names an element that is tried before all others:

    TETHER_VIDEO_DECODER=avdec_h264 ./target/debug/tether
    

    The “software decoding” preference of the app leaves the hardware decoders out.

  4. Check that the elements exist on the computer:

    gst-inspect-1.0 h264parse
    gst-inspect-1.0 avdec_h264
    

    h264parse is in gstreamer1.0-plugins-bad, avdec_h264 in gstreamer1.0-libav.

SymptomCause
“No video in this build”The app was built without the feature mirror.
The window stays on “connecting” for some seconds at the first startThe first start of a pipeline with nvh264dec can take 2 to 9 seconds under load. Later starts are fast.
The picture jumps forwardIntended. When more than 30 encoded frames wait in front of the decoder for over 1.5 seconds, the app drops them and asks the phone for a key frame.

GStreamer’s own debug output is controlled by its GST_DEBUG environment variable, described in the GStreamer documentation.

The daemon uses GStreamer too, for phone audio and for the webcam. tether-cli phone-audio <id> and tether-cli webcam <id> status show their state, and their errors are in the daemon’s log.

Common pitfalls

  • Stop programs with pkill -x, never pkill -f. pkill -x tetherd matches the exact program name. pkill -f matches whole command lines, including that of the calling shell.
  • The GTK app is tether, the daemon is tetherd. pkill -x tether stops only the app.
  • Two daemons cannot share a bus name or a port. If a debug daemon will not start, the installed one is probably running. Stop it, or run the debug daemon beside it.
  • tether-cli talks to the installed daemon unless TETHER_BUS_NAME is set. Check the variable before you run a command that acts on a phone.
  • A stopped daemon can come back. The installed package registers org.tether.Daemon for D-Bus activation, and the GTK app’s Start service button starts the installed service.
  • The GTK app keeps running in the tray. Closing the window hides it while the tray icon is active. A second tether only brings the first one’s window to the front, so stop the old app before you start a new build.
  • adb install -r keeps the pairing only between builds signed with the same key. Switching between a debug and a release APK means uninstalling and pairing again.