In modern Android media architecture, applications playing audio and video streams do not directly interface with physical speaker hardware or network casting protocols. Instead, stream destination selection, volume arbitration, and dynamic route handoffs are coordinated centrally by MediaRouterService. Whether transferring playback from internal smartphone speakers to Bluetooth LE Audio earbuds, switching to USB-C DAC outputs, or casting multi-room video to a Google Cast (Chromecast) or Android TV display, the media routing framework arbitrates all active endpoints. For mobile developers, QA engineers, and audio specialists, Android Debug Bridge (ADB) exposes complete real-time routing state tables via the dumpsys media.router command.
Architecture of the Android Media Router Service
The media.router system service (implemented in com.android.server.media.MediaRouterService) coordinates with AudioService, Bluetooth audio managers, and the MediaRouter2 client library:
- System Routes: Represents local hardware outputs (device speaker, wired 3.5mm headset, USB audio class devices, and Bluetooth A2DP / LE Audio streams).
- Remote / Cast Routes: Discovered dynamically over local Wi-Fi via Google Cast protocols or third-party MediaRouteProvider implementations.
- Routing Sessions (MediaRouter2): In Android 11 and later, applications establish isolated routing sessions that allow seamless transfer, volume scaling, and seamless group volume controls without interrupting playback buffers.
- Package Routing Permissions: Validates whether client applications possess the necessary foreground privileges and network discovery entitlements (e.g.,
MEDIA_CONTENT_CONTROL).
Querying the Media Router Subsystem via ADB
Connect your Android device with USB debugging authorized and execute the diagnostic command in your terminal:
adb shell dumpsys media.router
The command dumps active routing records across all user profiles, detailing registered router providers, client applications, active route descriptors, and volume levels.
Analysing Key Diagnostic Output Sections
1. Inspecting User State and Registered Providers
The output groups state tables by Android User ID (User 0 represents the primary user profile):
User 0:
Router Providers:
SystemMediaRouteProvider (System)
com.google.android.gms/.cast.media.CastMediaRouteProvider (Remote)
Selected Route:
Name: Pixel Buds Pro
ID: BLUETOOTH_A2DP_DEVICE_00:11:22:33:44:55
Type: BLUETOOTH_A2DP
Volume: 12 / 25
Connection State: CONNECTED
Key attributes provide immediate diagnostic confirmation:
- Router Providers: Confirms whether the system provider and remote cast discovery daemons (such as Google Play Services Cast provider) are active and running.
- Selected Route: Details the exact audio sink currently receiving decoded audio frames, including hardware MAC identifiers and volume levels.
- Type: Differentiates between
BUILTIN_SPEAKER,WIRED_HEADSET,BLUETOOTH_A2DP,HEARING_AID, andREMOTE_DISPLAY.
2. Active Client Applications and Routing Sessions
Inspect the list of applications currently holding open MediaRouter2 client instances:
Active Client Records:
Client [com.spotify.music] (pid 4182, uid 10192):
Package: com.spotify.music
Route Discovery Preference:
Preferred Features: [LIVE_AUDIO, REMOTE_PLAYBACK]
Active Scan: false
Active Sessions:
Session ID: 10482
Route: Living Room TV (ID: cast:device_a1b2c3d4)
Volume Handling: REMOTE_CONTROL (Volume: 45%)
This reveals whether an application is actively scanning for local Cast endpoints (which consumes battery) or listening passively, and confirms the active routing session ID attached to the app.
Debugging Media Routing and Bluetooth Audio Handoffs
When investigating audio cutouts, volume synchronization anomalies, or failed Cast handoffs, filter the dump to track specific events:
# Check current active route sink
adb shell dumpsys media.router | grep -A 5 -i "Selected Route"
# Identify apps performing active Wi-Fi route scans
adb shell dumpsys media.router | grep -B 2 -A 3 -i "Active Scan: true"
# Check volume handling modes
adb shell dumpsys media.router | grep -i "Volume Handling"
Simulating Route Invalidation and Service Reset
If an external Cast receiver or Bluetooth endpoint remains phantom-cached in the system output picker after disconnection, force a refresh of the routing subsystem without restarting the device:
# Restart the client media application
adb shell am force-stop com.spotify.music
# Verify the media router has reclaimed the default system speaker
adb shell dumpsys media.router | grep -i "Selected Route"
By leveraging dumpsys media.router, Android audio engineers and app developers gain precise, real-time insight into the media routing stack, ensuring seamless, low-latency audio handoffs across local and wireless casting environments.