// the find
twilio/audioswitch
An Android audio management library for real-time communication apps.
A Kotlin library that handles the Android side of voice and video calls: audio focus with VOICE_COMMUNICATION usage, enumerating earpiece, speakerphone, wired and Bluetooth outputs, and choosing between them. It came out of Twilio's own video and voice sample apps, so it's aimed at developers building VoIP or conferencing features who would otherwise write this routing glue themselves.
- The default selection order (BluetoothHeadset, WiredHeadset, Earpiece, Speakerphone) is written down in the README, and selectDevice() overrides it. The policy is visible rather than buried in the library.
- A failed Bluetooth SCO connection reverts the selected device, and BluetoothHeadsetConnectionListener reports state changes and failures. The failure path is the part hand-rolled routing code tends to skip, and it's where calls end up on the wrong output.
- The androidTest suite covers automatic selection and multiple headsets using fake Bluetooth intents and fake devices, and a Firebase Test Lab config sits in ftl/. Device-facing audio code gets exercised beyond unit tests, which is rarer than it should be.
- Java 8 consumption is a stated goal, backed by Java-specific unit tests. That's a real commitment for a library that Java apps still depend on.
- Only the active Bluetooth headset is tracked. Switching between paired headsets means going to system settings, so an in-call headset picker means the app has to track the others itself.
- The README says Bluetooth is disabled without BLUETOOTH_CONNECT on Android 12+, but it doesn't describe any error or callback that tells the app why. Expect support questions about devices that just never show a headset.
- Logging is off by default, and the snapshot instructions point at oss.sonatype.org, a host Sonatype has been moving away from. Confirm the snapshot repository still resolves before depending on it, and turn logging on before filing a routing bug.
- Changes that need integration testing get closed and re-raised internally, so an outside contribution can take a while to land and the public PR history is a thin record of how the project actually moves.