Bluetooth End-to-End
How Android discovers, pairs, and then actually moves bytes over Classic, BLE and LE Audio — from app APIs through the Bluetooth process and Fluoride to the controller. This is the hop-by-hop walk that Trace a Path Through the Android Stack only maps; do not mix it with Wi-Fi.
- Control plane is pairing, ACL/LE link setup, SMP and GATT procedures. Data plane is ACL media/ATT payloads, SCO/eSCO voice, and ISO (LE Audio). Mixing the two is the usual interview fail.
- Classic (BR/EDR) and BLE share a radio and often a combo chip with Wi-Fi, but they are different MACs and procedures. Never answer a Bluetooth question with Wi-Fi association.
- Apps talk
BluetoothAdapter/BluetoothManager/ profile proxies /BluetoothGatt.BluetoothManagerServiceinsystem_serverowns the adapter lifecycle; the stack lives in thecom.android.bluetoothprocess. - The current AOSP stack is Fluoride (Mainline Bluetooth module). BlueDroid is the historical name. HCI is UART, USB or shared memory into controller firmware.
- Music is A2DP over ACL (AVDTP + SBC/AAC/LDAC). Call audio is HFP over SCO/eSCO (CVSD/mSBC). They are not the same path. Mixer detail: Multimedia.
- LE Audio (LC3, CIS/CIG, BIS/BIG, Auracast) is the long-term replacement for A2DP + HFP, not a codec toggle on Classic.
- A mis-set BLE connection interval or an always-on scan is how a watch dies. Debug with
dumpsys bluetooth_manager, HCI snoop,btmonand logcat — not with Wi-Fi dumps.
Two planes: Classic vs BLE, control vs data
Bluetooth is two radios in one brand name, and each radio has a control conversation and a data conversation. Interviewers use this as a filter. If you start an "A2DP stutter" answer with SMP pairing, or a "GATT notify never arrives" answer with SCO, you have mixed the planes. Classic (BR/EDR) and BLE can run on one dual-mode controller; they still do not share inquiry, advertising, or media paths.
Control plane (lease the link)
- Classic: inquiry, page, SDP, pairing (SSP), bonding keys, profile state machines (A2DP/HFP connect).
- BLE: advertising, scanning,
CONNECT_IND, SMP pairing / LE Secure Connections, bonding (LTK/IRK/CSRK), GATT discovery and CCCD writes. - Android: adapter on/off, permissions,
CompanionDeviceManagerassociation, profile proxy connect,BluetoothGatt.connect(). - Result: an ACL or LE link (and later a SCO/ISO pipe if a profile asks). Keys sit in the bond store.
Data plane (drive on the link)
- ACL — reliable-ish packets: A2DP media, AVRCP, RFCOMM (HFP AT, PBAP, SPP), ATT/GATT values.
- SCO / eSCO — reserved slots for HFP/HSP call audio (CVSD or mSBC). Not A2DP.
- ISO — LE Audio isochronous: CIS (unicast) and BIS (broadcast / Auracast).
- Codec bytes are payload on one of those pipes. Pairing never carries the song.
| Classic (BR/EDR) | BLE (LE) | |
|---|---|---|
| How you find a peer | Inquiry (GIAC) + page to a BD_ADDR | Advertising + scan; connect on an advertiser |
| Typical jobs on a phone | A2DP music, HFP calls, Classic HID, PBAP/MAP | Sensors, wear pairing, HOGP, beacons, LE Audio |
| Control after the link is up | SDP, profile RFCOMM/AVDTP signalling | SMP, ATT procedures, connection-param update |
| Media / data pipes | ACL + SCO/eSCO | LE ACL (ATT) + ISO (LE Audio) |
| Power story | Sniff, park (legacy); still hungrier than BLE idle | Duty-cycled adv/scan; connection interval + latency |
Classic is a reserved conference-room booking: you hunt the directory (inquiry), knock on the door (page), show badges (pairing), then hold the room (ACL) and maybe a private phone line (SCO). BLE is a lighthouse: the peer blinks a notice (advertising), you look on a schedule (scan window), you dock (LE connection), then you either exchange filing-cabinet notes (GATT over ACL) or stream a timed concert (ISO). The booking paperwork is control; the conversation in the room is data. The layer-cake map is on Trace a Path Through the Android Stack; this page is the walk. Watch pairing lives on Wear OS.
CONTROL (once per link / procedure) DATA (every media or ATT byte)
App: enable, scan, pair, connect profile App: AudioTrack / BluetoothGatt.notify
| |
BluetoothManagerService + profile Java AudioFlinger or GattService
| |
Fluoride: HCI create/accept, SMP, SDP, Fluoride: ACL / SCO / ISO payload
AVDTP/HFP/GATT signalling |
| |
Controller firmware: page/adv/LL setup Controller: BR/EDR or LE LL packets
v v
"bonded + profile connected" bytes on the air
Layer cake: app to controller firmware
Every Bluetooth journey on modern Android crosses the same vertical stack. Learn it once. BlueDroid is the historical AOSP userspace name; the current stack is Fluoride, shipped as the Bluetooth Mainline module and run in a process separate from system_server.
┌──────────────────────────────────────────────────────────────┐ │ APP BluetoothManager / Adapter / profile proxies │ CompanionDeviceManager, BluetoothGatt │ ↕ Binder (IBluetooth*, app permissions) │ ├──────────────────────────────────────────────────────────────┤ │ FRAMEWORK BluetoothManagerService in system_server │ Adapter on/off, bind to stack process │ ↕ Binder / AIDL │ ├──────────────────────────────────────────────────────────────┤ │ BLUETOOTH com.android.bluetooth (Java profiles + JNI) │ A2dpService, HeadsetService, GattService │ PROCESS ↕ JNI │ ├──────────────────────────────────────────────────────────────┤ │ FLUORIDE HCI · L2CAP · RFCOMM · SDP · AVDTP · AVCTP │ ATT/GATT · SMP · ISO host · profiles │ STACK ↕ AIDL IBluetoothHci (+ Bluetooth Audio HAL) │ ├──────────────────────────────────────────────────────────────┤ │ HAL / XPORT HCI UART / USB / shared memory │ AIDL IBluetoothAudioProvider (offload) │ ↕ ioctl / char dev / vendor IPC │ ├──────────────────────────────────────────────────────────────┤ │ KERNEL hci_uart / btusb / vendor BT driver │ HCI core; not BlueZ userspace │ ↕ IRQ / DMA / shared mem │ See linux-kernel-bsp.html ├──────────────────────────────────────────────────────────────┤ │ CONTROLLER BT firmware on the radio (often combo chip) │ Classic LL + LE LL + ISO └──────────────────────────────────────────────────────────────┘
The app is a customer at the front desk (BluetoothManager in the app process). Building security (BluetoothManagerService) decides whether the radio department is even open. The radio department is a separate office (the bluetooth process) staffed by profile clerks (Java) and a protocol workshop (Fluoride). They send sealed envelopes (HCI commands/events/ACL) down the mail chute (UART/USB/shared mem) to the basement machines (controller firmware). Internal mail between the front desk and the radio office is Binder — same idea as Binder & AIDL.
App and framework APIs
Prefer BluetoothManager.getAdapter() over the deprecated BluetoothAdapter.getDefaultAdapter(). Apps then take a profile proxy (getProfileProxy for A2DP, Headset, HID, Hearing Aid, LE Audio, …) or a BluetoothGatt / BluetoothGattServer. CompanionDeviceManager is the modern pairing association path: the system shows a chooser, the user picks a device, and the association can grant BLUETOOTH_CONNECT without a scan UI in the app. Runtime permissions since Android 12 are BLUETOOTH_SCAN, BLUETOOTH_CONNECT and BLUETOOTH_ADVERTISE (use neverForLocation on scan when you are not using BLE for location).
system_server versus the bluetooth process
BluetoothManagerService lives in system_server. It turns the adapter on, starts com.android.bluetooth, and holds IBluetoothManager. Profile work, GATT, and Fluoride run in the bluetooth process so a stack crash does not take the whole framework with it. Apps bind through the manager to IBluetooth and profile AIDL in that process. Details of service registration sit with Android frameworks.
Fluoride (not BlueDroid)
Fluoride is the C/C++ host stack: HCI layer, L2CAP, RFCOMM, SDP, AVDTP, AVCTP, BNEP, ATT/GATT, SMP, and the ISO host pieces for LE Audio. Java profile services call into it over JNI. BlueDroid is the name you will still see in paths (bt_config.conf under a bluedroid-ish directory) and old slides — say "historical name; current AOSP is Fluoride / the Bluetooth module." It is not BlueZ userspace. The kernel still has HCI core; Android does not run bluetoothd.
HCI HAL and the kernel hop
On AOSP 13–15 the packet HAL is AIDL android.hardware.bluetooth.IBluetoothHci (HIDL IBluetoothHci 1.0/1.1 on older devices). Fluoride sends command packets and ACL/ISO data; the HAL implementation writes the controller transport and posts events/ACL back. Transport is UART (H4), USB, or vendor shared memory (Qualcomm and MediaTek combo chips are the usual industry examples). The kernel driver owns the tty/USB/smem node; firmware runs the Classic and LE link layers. Kernel driver patterns: Linux Kernel & BSP.
Bluetooth Audio HAL (offload)
A2DP, HFP and LE Audio can encode in software on the AP or offload through AIDL android.hardware.bluetooth.audio.IBluetoothAudioProvider (HIDL Bluetooth Audio on older releases). Offload is a data-plane shortcut: AudioFlinger hands encoded or PCM frames to a vendor DSP/path so Fluoride is not memcpy-ing every SBC frame. Control (AVDTP start, SCO setup, CIS setup) still goes through Fluoride and HCI.
IBluetoothHci
AIDL packet pipe: HCI commands, events, ACL, SCO, ISO. This is how Fluoride talks to firmware, not how an app talks to a headset.
IBluetoothAudioProvider
AIDL audio session for offload (A2DP/HFP/LE Audio). If this fails, software fallback may still play — at a power and jitter cost.
bt_config / bond store
Bonded keys and device metadata persist across bluetooth-process restarts. Adapter "ON" is not the same as "keys still there."
Classic connect: inquiry, page, pairing, bonding, ACL
Classic connection is a control-plane story until ACL exists. Music and AT commands do not start until that ACL (and then a profile channel) is up. Keep inquiry/page separate from pairing, and pairing separate from bonding.
- Inquiry The scanner broadcasts ID packets; discoverable peers in inquiry-scan reply with FHS/EIR (address, class of device, name fragments). Android's discovery API is this, plus BLE scan if you asked for both.
- Page The initiator pages a known BD_ADDR. The peer in page-scan answers. This is "connect to that MAC," not "look around again."
- ACL A logical ACL-U link exists. L2CAP can open channels. Nothing is trusted yet if the devices are unpaired.
- Pairing (SSP) Secure Simple Pairing agrees a link key. Association models: Just Works, Numeric Comparison, Passkey Entry, Out-of-Band.
- Bonding Both sides store the key (and typically the name/UUIDs). Next time is page + authentication, not a full SSP UX.
- SDP + profile Browse services, then open AVDTP / RFCOMM / HID channels on that ACL.
Initiator Peer (discoverable + page-scan) |-- Inquiry --> (inquiry-scan) |<-- FHS / EIR (BD_ADDR, CoD, name) -- |-- Page (that BD_ADDR) --> (page-scan) |<-- page response / ACL up -- |-- L2CAP signalling --> |-- SSP (IO caps, public key, auth) --> Just Works / Numeric / Passkey / OOB |-- bond: store link key -- |-- SDP search (A2DP sink, HFP HF, …) --> |-- AVDTP or RFCOMM open --> profile connected v ACL data plane now legal for that profile
SSP association models
| Model | User sees | MITM protection | When Android uses it |
|---|---|---|---|
| Just Works | Often just "Pair" | No. Passive eavesdrop is hard; active MITM is not. | Headsets and speakers with no display/keypad. |
| Numeric Comparison | Six-digit number on both sides; user confirms match | Yes, if the user actually compares. | Phone-to-phone, some cars, devices with displays. |
| Passkey Entry | One side types a 6-digit value shown on the other | Yes, if the passkey is not leaked. | Keyboard / some carkits. |
| Out-of-Band | NFC tap or another side channel carries the commitment | As strong as the OOB channel. | NFC pairing, some accessory setup. |
IO capability exchange picks the model. A display-only phone plus a no-IO headset becomes Just Works. Do not call Just Works "insecure so we skip pairing" — it still creates a link key; it just does not prove there is no person-in-the-middle.
Inquiry is walking the conference hall reading badges. Page is walking up to a specific badge number. Pairing is agreeing a secret handshake: Just Works is a nod; Numeric Comparison is both reading the same code off a screen; Passkey is typing the code; OOB is bumping NFC badges. Bonding is writing the handshake in your address book so tomorrow you skip the ceremony and just knock (page + authenticate).
BLE connect: advertise, scan, link, pair, bond, timing
BLE has no inquiry/page. The peripheral (or broadcaster) advertises; the central scans; a connectable advertiser plus a central's CONNECT_IND creates an LE ACL. Pairing is SMP, preferably LE Secure Connections (ECDH P-256, Bluetooth 4.2+). Bonding stores LTK (encryption), IRK (privacy / RPA resolution) and optionally CSRK (signing).
- Advertise ADV_IND / ADV_EXT_IND (connectable), ADV_NONCONN_IND (beacon), ADV_SCAN_IND (scannable). Legacy primary ads sit on 3 channels; Bluetooth 5 extended advertising moves the payload to secondary channels.
- Scan Passive listens; active sends SCAN_REQ to get SCAN_RSP. Duty cycle is scan window / scan interval. Android batches and offloads filters to the controller when it can.
- Connect Central sends
CONNECT_INDon an advertising channel. Link-layer connection: interval, peripheral latency, supervision timeout, hop increment. - Optional encrypt / pair SMP pairing method from IO caps (Just Works, Numeric Comparison, Passkey, OOB) under legacy pairing or LE Secure Connections.
- Bond Distribute LTK/IRK/CSRK. Next connection can encrypt immediately, including to an RPA that resolves with the IRK.
Peripheral (advertiser) Central (phone / watch host)
ADV_IND / EXT ADV (interval T_adv) scanWindow / scanInterval
\ /
+-- CONNECT_IND (central) --+
LE ACL up
LL: interval I, latency L, timeout T
ATT: MTU exchange, GATT discover
SMP: LE SC pairing --> bond LTK + IRK
data: ATT notify / write on CID 0x0004
(LE Audio would add CIS/ISO here — see le-audio)
Connection interval, latency, supervision timeout
| Parameter | What it costs / buys |
|---|---|
| Connection interval I | Short I: low latency, high average current. Long I: cheap standby, sluggish GATT. |
| Peripheral latency L | Slave may skip I events and still keep the link. Saves slave power; central must still listen. |
| Supervision timeout T | How long silence means "dead link." Too small: drops in busy RF. Too large: zombie links. |
| Scan window / interval | Discovery probability ≈ window/interval (plus 3-channel luck). 100% duty scan cooks the battery. |
The peripheral is a lighthouse on a timer. The central is a night watch that only looks during a scan window. Docking agrees a ferry schedule (connection interval). The small boat (watch) is allowed to skip sailings (slave latency) but if nobody shows for the supervision timeout, the harbour assumes shipwreck and tears the link down. Pairing is exchanging harbour codes; bonding is writing them in the logbook so tomorrow's ferry does not redo the ceremony.
GATT path: app to ATT PDUs
GATT is a control-ish data plane on an already connected LE ACL (or, rarely, on Classic ATT). Discovery and CCCD writes are procedures. Notifications are data. Do not start this answer with advertising unless the link is not up yet.
App BluetoothGatt.connect() / discoverServices() / setCharacteristicNotification()
--> Binder --> GattService (com.android.bluetooth)
--> Fluoride GATT client (or server)
--> ATT PDUs on L2CAP CID 0x0004 (EATT uses extra dynamic CIDs when both support it)
Exchange MTU
Read By Group Type (primary services)
Find Information / Read By Type (characteristics, 0x2902 CCCD)
Write CMD/REQ (CCCD = 0x0001 notify or 0x0002 indicate)
Handle Value Ntf/Ind (server → client data)
--> HCI ACL --> IBluetoothHci --> kernel transport --> controller LL
--> peer ATT
Service
A UUID-named grouping (Battery, Heart Rate, a vendor 128-bit service). Primary vs secondary. The app walks BluetoothGattService after discovery.
Characteristic
A value plus properties: read, write, write-no-response, notify, indicate. Handle + UUID. This is the folder in the cabinet.
CCCD (0x2902)
Client Characteristic Configuration Descriptor. Writing 0x0001 enables notifications; 0x0002 indications; 0x0000 off. If you "enable notify" in the API but never see a CCCD write in HCI snoop, the peer will stay silent.
Notify versus indicate, and ATT MTU
Notification is unacknowledged at ATT (still over a CRC'd LE link). Indication requires an ATT Handle Value Confirmation — slower, used when the server must know the client got it. Default ATT_MTU is 23 bytes (20 of value after the 3-byte ATT header). requestMtu() / Exchange MTU raises it (commonly up to 517 on Android, limited by both peers and the controller). Large firmware updates that skip MTU exchange crawl.
GATT is a filing cabinet on the far desk. Services are drawers, characteristics are folders, descriptors are sticky notes on a folder. CCCD is the sticky that says "text me when this folder changes." ATT is the inter-office memo format; L2CAP is the envelope service; HCI ACL is the mail cart to the basement radio. The app's BluetoothGatt is just a receptionist filling out memos — the memos still have to be written (CCCD) before anyone texts you.
| API / PDU | Role |
|---|---|
BluetoothGatt.discoverServices() | ATT discovery walk; fills the cache the app then reads. |
readCharacteristic / writeCharacteristic | ATT Read / Write Request or Write Command. |
setCharacteristicNotification + CCCD write | Local registration and the peer enable. Both are required. |
BluetoothGattServer | Phone or watch acting as ATT server (often the wearable sensor side). |
| EATT (optional) | Multiple ATT bearers so a long Read Blob does not stall notifies. |
setCharacteristicNotification(true) and assuming the CCCD was written. On many stacks you must also write descriptor 0x2902 yourself. Another miss: treating a 20-byte notify as a protocol bug when you never exchanged MTU.A2DP path: music to a headset
A2DP is one-way music over ACL, not SCO. The phone is the source; the headset is the sink. Codec negotiation and AVDTP signalling are control; SBC/AAC/LDAC frames are data. Mixer, focus and offload policy are owned by audio — this page only takes the stream from the device pick to the air. Full mixer walk: Multimedia End-to-End.
App MediaPlayer / ExoPlayer / AudioTrack (media usage)
--> AudioFlinger (+ AudioPolicyService picks A2DP device)
--> Bluetooth A2DP source (profile Java in com.android.bluetooth)
AVDTP: discover / get capabilities / set configuration / open / start
codec: SBC (mandatory) · AAC · LDAC · vendor (aptX family, …)
--> encoded frames on L2CAP (AVDTP media channel) = ACL data
software path: AP encodes, Fluoride writes HCI ACL
offload path: IBluetoothAudioProvider + DSP; HCI still starts the session
--> controller Classic LL --> headset sink decode --> speaker
What A2DP is
- Unidirectional media, ACL, AVDTP.
- High bit-rate relative to voice; designed for music.
- Often paired with AVRCP for play/pause/skip and absolute volume.
- Policy must route the media stream to the A2DP device.
What A2DP is not
- Not call audio (that is HFP SCO/eSCO).
- Not GATT. Not BLE (unless you meant LE Audio, a different section).
- Not "Bluetooth is connected so music must play" — ACL + AVDTP start + audio route.
A2DP is a one-way music truck on the ACL highway. AudioPolicy is the dispatcher that decides the truck leaves for the Bluetooth dock instead of the house speakers. AVDTP is the loading dock paperwork (which codec, start/stop). SBC/AAC/LDAC are how the records are packed. SCO is a different, reserved walkie-talkie lane — do not load the symphony onto the walkie-talkie. How the mixing desk itself works is multimedia.
AVDTP SetConfiguration picks the codec from the intersection of source and sink capabilities. SBC always exists as the fallback. If a "hi-res" codec fails handshake, a good stack falls back to SBC rather than playing silence. Absolute volume (AVRCP) can make the UI volume slider drive the headset; if AVRCP volume and A2DP both move, you get double-volume bugs — still not an HCI transport bug.
HFP path: call audio on SCO/eSCO
HFP (Hands-Free Profile) is call control plus a bidirectional voice pipe. The phone is the Audio Gateway (AG); the headset is the Hands-Free unit (HF). AT commands ride RFCOMM on ACL (control). Voice rides SCO or eSCO (data), typically CVSD (narrowband) or mSBC (wideband, "HD voice" over BT). Telecom owns the call; audio policy must route the voice stream to SCO, not to A2DP.
InCallUi / Telecom (placeCall / in-call audio route)
--> Telephony / IMS or CS (the call itself — not this page)
--> AudioPolicy: strategy VOICE, device BLUETOOTH_SCO
--> HeadsetService (HFP AG) in com.android.bluetooth
RFCOMM AT: RING / +CIEV / ATA / AT+BRSF / AT+BAC
codec negotiate: CVSD or mSBC (eSCO)
--> HCI Setup Synchronous Connection (SCO/eSCO)
--> voice frames AG ↔ HF
--> Audio HAL / Bluetooth Audio HAL (in/out voice)
Contrast A2DP: no AT, no SCO, ACL media only
| A2DP | HFP | |
|---|---|---|
| Direction | Mostly source → sink | Bidirectional voice |
| Pipe | ACL (AVDTP media) | SCO/eSCO (+ RFCOMM AT on ACL) |
| Codec | SBC/AAC/LDAC/… | CVSD or mSBC (and later LC3 on LE Audio) |
| Who routes it | Media usage → A2DP device | Voice usage → SCO device |
| If it fails | Music on speaker, or silence / stutter | Call stays on earpiece/speaker; headset buttons may still work (AT only) |
HFP is a walkie-talkie reservation: you keep a signalling clipboard (AT over RFCOMM) and a dedicated voice lane (SCO) so a song truck (A2DP) cannot fill the slots. Telecom is the switchboard that decided there is a call; audio policy is who points the handset at the walkie-talkie. If the clipboard works but the lane never opens, you can tap the headset to answer and still hear the call on the phone speaker.
LE Audio: LC3, CIS/CIG, BIS/BIG, Auracast
LE Audio is not "A2DP over BLE." It is a new host and controller data path: the ISO logical transport, the LC3 codec, and profiles on top (BAP, PACS, ASCS, TMAP, HAP, …). Unicast uses Connected Isochronous Streams; broadcast uses Broadcast Isochronous Streams. This is why it can replace both A2DP (music) and HFP (voice) long term — one LE stack, one codec family, true stereo sync, hearing-aid first-class support.
LC3
Low Complexity Communication Codec. Mandatory for LE Audio. Better quality at lower bit-rate than SBC, and usable for voice and music. Do not say "LC3 is just better SBC on ACL."
CIS / CIG
A CIS is one isochronous stream to one peer. A CIG groups CIS (left + right earbuds, or mic + speaker). The controller schedules ISO events so both buds play the same sample time.
BIS / BIG
A BIS is a broadcast stream; a BIG groups them. No per-listener ACL required. One source, many sinks.
Auracast
The product name for LE Audio broadcast: airport gate, gym TV, hearing-aid assistive listen. Phones scan for broadcast names and sync a BIG. Not a Wi-Fi hotspot.
Unicast (replaces A2DP / HFP long term) App / Telecom / AudioPolicy --> LE Audio profile (BAP) --> ASCS setup --> CIG with CIS to each bud --> LC3 frames on ISO --> IBluetoothHci ISO --> controller Control still uses LE ACL + GATT (PACS capabilities, ASE control) Broadcast / Auracast Source: configure BIG + BIS, advertise Broadcast Audio Announcement Sink: scan, sync BIG, decode LC3 (no pairing required for public broadcasts)
Classic audio is two different postal systems (music trucks on ACL, walkie-talkie on SCO) that you glue together with profile clerks. LE Audio is one timetable: the station (CIG/BIG) publishes numbered carriages (CIS/BIS) that leave at sample time. LC3 is the packing format. Auracast is a station loudspeaker — anyone on the platform can tune in without buying a ticket (pairing). GATT is still the ticket office for unicast capabilities.
Android 13–15 expose LE Audio through profile proxies and the Bluetooth Audio HAL. Hearing aids and true-wireless sets may connect CIS while still advertising. Until the peer is LE Audio capable, the phone still falls back to A2DP/HFP on the same dual-mode controller. Do not tell an interviewer that A2DP is deprecated in AOSP 15 — it is not; LE Audio is the direction of travel.
HID, AVRCP, PBAP/MAP, BLE HID, advertising extensions
Not every Bluetooth question is audio. These profiles still split control vs data, and they still must not be answered with Wi-Fi or USB HID unless the device actually fell back.
| Profile | Pipe | What it does | Interview trap |
|---|---|---|---|
| HID (Classic) | L2CAP HID control + interrupt | Keyboards, mice, gamepads, some remotes. | Interrupt channel is the data plane (reports); control is not the keycode. |
| HOGP (BLE HID) | GATT HID service | Same reports over ATT notify/write. Common for low-power keyboards and wear input. | It is GATT + HID UUIDs, not Classic HID channels. |
| AVRCP | AVCTP on ACL | Play/pause/skip, metadata, absolute volume with A2DP. | AVRCP connected ≠ audio routed. Buttons without A2DP start is a policy bug. |
| PBAP | RFCOMM / GOEP | Car downloads the phone book. | Control is the PBAP session; contacts are the payload. Permissions / accounts matter. |
| MAP | RFCOMM / GOEP | Car or watch reads/sends SMS/MMS notifications. | Not the Wear Data Layer. See Wear OS for DataClient. |
| SPP | RFCOMM | Vendor serial pipes. | Still ACL. Not a Linux tty unless someone made one. |
Advertising extensions (brief)
Bluetooth 5 extended advertising: small header on primary channels, large payload (up to 255 bytes per PDU, chained) on secondary channels, plus periodic advertising. Android's advertising APIs expose sets, legacy vs extended, and periodic where the controller supports it. Use this for richer beacons and LE Audio announcements — not to "make Classic inquiry faster."
HID is a thin remote-control wire: small reports, tight latency. AVRCP is the TV remote for a music session that A2DP is already playing. PBAP/MAP are "please copy my address book / inbox into the car." Extended advertising is a bigger sandwich board on a side street so the main street (three primary channels) stays uncluttered.
Power: sniff, BLE duty cycle, scan windows, watches
Bluetooth power is radio-on time, not "the BT icon is showing." Classic and BLE waste energy in different ways. The AP also wakes for HCI events; a chatty notify or a reconnect loop looks like an Android drain even when the UI is idle. Broader suspend and Doze: Power & thermal. Watch companion policy: Wear OS.
- Classic sniff — after ACL is idle, the link agrees a sniff interval and the radio sleeps between sniff anchors. A2DP streaming cannot sniff; HFP SCO keeps reserved slots. A reconnect loop (page every few seconds) is worse than sniff.
- BLE connection — average current scales with 1 / (I × (1 + L)) plus listen slop. A 15 ms interval with L = 0 on a watch is a heater. After file transfer or pairing UX, update to hundreds of ms.
- Scan / advertise duty — probability of meeting ≈ window/interval (and advertising interval). Continuous low-latency scan is a lab setting, not a ship setting. Controller-side filters (whitelists, IRK, service-UUID) keep the AP asleep.
- LE Audio ISO — scheduled ISO events. Better than dual A2DP+SCO, still not free; unused CIS should be released.
A well-set BLE link is a lighthouse that blinks every few hundred milliseconds. A mis-set 15 ms connection interval is leaving the floodlight on so you never miss a postcard. Sniff is the Classic building switching to motion-sensor lighting. The night watch (AP) should not wake for every blink — that is what controller filtering is for. A watch that pages the phone in a tight loop is someone ringing the doorbell every five seconds; suspend never happens.
Debug: dumpsys, HCI snoop, btmon, pairing and audio misses
Bisect adapter → bond → profile → pipe → audio route. Pairing failures die on the left. "Connected but silence" dies on the right. Do not start with Wi-Fi dumps. Kernel oops on the BT tty is a kernel/BSP hop.
# Adapter, bonds, profile connections (AOSP name)
adb shell dumpsys bluetooth_manager
# Audio route (A2DP vs SCO vs speaker) — see also multimedia.html
adb shell dumpsys media.audio_policy
adb shell dumpsys media.audio_flinger
# HCI snoop: Developer options → Enable Bluetooth HCI snoop log
# or properties (names have moved; confirm on the build)
adb shell settings get secure bluetooth_hci_log
adb shell getprop persist.bluetooth.btsnooplogmode
adb shell getprop persist.bluetooth.btsnooppath
# Typical host path after toggle BT; also inside a bugreport
# /data/misc/bluetooth/logs/btsnoop_hci.log
adb bugreport bugreport.zip
# unzip and search for btsnoop_hci.log — open in Wireshark (btsnoop)
# logcat tags that actually move (exact set varies by release)
adb logcat -s BluetoothManagerService:V BluetoothAdapter:V \
bt_btif:V bt_hci:V bt_btm:V bt_sdp:V bt_l2cap:V bt_rfcomm:V \
bt_av:V bt_hf:V bt_gatt:V bt_smp:V
# Engineering images may ship btmon (BlueZ monitor against the HCI node)
adb shell btmon
# Adapter toggle without Settings UI (does not fix a dead firmware)
adb shell svc bluetooth disable
adb shell svc bluetooth enable
# Stack-only crash/restart (system_server stays up)
adb shell am crash com.android.bluetooth
Pairing failures
- Permissions / CDM Android 12+
BLUETOOTH_CONNECT/SCAN. User cancelled CompanionDeviceManager. This never reaches HCI. - Discovery Not discoverable, wrong transport (you Classic-page a BLE-only bud), or scan duty too low. Confirm ads or inquiry responses in snoop.
- SSP / SMP IO-cap mismatch, numeric compare reject, passkey miss, LE legacy vs LE SC downgrade. Snoop: SMP Pairing Failed reason, HCI Authentication Failure.
- Bond store Keys lost after reboot or after a stack wipe; peer still thinks it is bonded (one-side bond). Clear bond on both ends.
Audio route misses
Profile connected ≠ policy routed. For music: A2DP AVDTP started, codec configured, AudioPolicy device is A2DP, Flinger has a track. For calls: HFP SLCed, SCO/eSCO up in snoop (Setup Synchronous Connection complete), policy device is BLUETOOTH_SCO. If AT answers the call but SCO never completes, you hear the phone speaker. If A2DP is started but policy still points at the speaker, HCI looks fine and the user still hears the tinny speaker. Mixer-level dumps: multimedia.
HCI snoop is the flight recorder on the mail chute: every command, event and ACL/SCO/ISO header. logcat is the office gossip — useful, incomplete. dumpsys bluetooth_manager is the whiteboard of who is bonded and which profile clerk thinks they are on a call. btmon is watching the chute live. Audio dumps are a different building; visit them when the recorder already shows the plane landed.
dumpsys media.audio_policy. A pairing-fail reason in SMP plus a Java "bond none" is a closed case. A successful AVDTP Start plus speaker route is an audio-policy case, not a "Bluetooth firmware" case.Quick revision
- Control = pairing, link setup, SDP/SMP/GATT procedures; data = ACL, SCO/eSCO, ISO payloads.
- Classic uses inquiry/page; BLE uses advertise/scan/CONNECT_IND. Do not mix.
- Never answer Bluetooth with Wi-Fi association; combo chip ≠ shared protocol. See wifi.html.
- BluetoothManagerService is in system_server; Fluoride and profiles run in com.android.bluetooth.
- BlueDroid is historical; current AOSP host stack is Fluoride (Bluetooth Mainline module).
- Apps use BluetoothManager/Adapter, profile proxies, BluetoothGatt, CompanionDeviceManager.
- Android 12+ permissions: BLUETOOTH_SCAN, CONNECT, ADVERTISE; neverForLocation when scan is not location.
- HCI HAL is AIDL IBluetoothHci; audio offload is AIDL IBluetoothAudioProvider.
- Transport is UART, USB or vendor shared memory into controller firmware.
- SSP models: Just Works, Numeric Comparison, Passkey, Out-of-Band. Just Works is not MITM-safe.
- Pairing creates keys; bonding stores them; profiles still connect after that.
- LE Secure Connections uses ECDH P-256; bond LTK, IRK (RPA), optional CSRK.
- BLE timing: interval I, latency L, supervision T with T > (1+L)×I×2.
- GATT: services → characteristics → CCCD 0x2902; ATT on L2CAP CID 0x0004.
- Notify is unacked ATT; indicate needs confirmation. Default ATT_MTU is 23.
- A2DP = music, ACL, AVDTP, SBC/AAC/LDAC. Not SCO. Mixer details on multimedia.html.
- HFP = AT on RFCOMM + voice on SCO/eSCO (CVSD or mSBC). Telecom + voice policy route it.
- LE Audio: LC3 + ISO; CIS/CIG unicast; BIS/BIG broadcast; Auracast is the broadcast product name.
- LE Audio is the long-term A2DP/HFP replacement; Classic profiles remain for old accessories.
- AVRCP is remote control/volume, not the media pipe. HID Classic ≠ HOGP (GATT).
- Sniff is Classic idle; BLE power is duty cycle of adv/scan/connection. SCO cannot sniff.
- A 15 ms watch connection interval with L=0 drains; lengthen I after the interactive phase.
- Debug: dumpsys bluetooth_manager, HCI snoop / btsnoop in Wireshark, btmon, logcat BT tags.
- Profile connected ≠ audio routed. Check AVDTP/SCO in snoop and audio_policy device.
- One-side bond after a key wipe looks like "pairs then immediately fails." Clear both ends.
- Wear pairing and Data Layer: wear-os.html. Kernel HCI driver: linux-kernel-bsp.html.
Glossary
- ACL
- Asynchronous Connection-oriented Link. The workhorse packet pipe for Classic (and the LE data channel). A2DP, RFCOMM, ATT all ride ACL.
- ADV_IND
- Connectable undirected legacy advertisement. Central may send CONNECT_IND.
- A2DP
- Advanced Audio Distribution Profile. Unidirectional music over AVDTP/ACL. Phone is usually the source.
- ASCS
- Audio Stream Control Service. GATT service that sets up LE Audio unicast streams (ASEs).
- ATT
- Attribute Protocol. PDU layer under GATT (reads, writes, notifies) on L2CAP CID 0x0004.
- Auracast
- Brand name for LE Audio broadcast using BIG/BIS so many sinks can hear one source.
- AVDTP
- Audio/Video Distribution Transport Protocol. Signalling and media channels for A2DP.
- AVRCP
- Audio/Video Remote Control Profile. Play/pause/metadata/absolute volume, typically beside A2DP.
- BAP
- Basic Audio Profile. LE Audio profile that uses PACS/ASCS and ISO streams.
- BD_ADDR
- 48-bit Bluetooth device address. May be public or a random/RPA on LE.
- BIG / BIS
- Broadcast Isochronous Group / Stream. LE Audio broadcast transport.
- BlueDroid
- Historical name of the AOSP userspace Bluetooth stack. Current name is Fluoride.
- BluetoothManager
- System service API apps use to get BluetoothAdapter and profile objects.
- BluetoothManagerService
- system_server owner of adapter lifecycle and binding to the bluetooth process.
- Bonding
- Storing pairing keys so later connections authenticate without repeating the UX.
- CCCD
- Client Characteristic Configuration Descriptor (UUID 0x2902). Enables notify/indicate.
- CIG / CIS
- Connected Isochronous Group / Stream. LE Audio unicast, e.g. a stereo pair.
- CompanionDeviceManager
- Framework association API for pairing/choosing a companion without a raw scan UI.
- CSRK
- Connection Signature Resolving Key. Optional LE key for signed writes without encryption.
- CVSD
- Continuously Variable Slope Delta. Narrowband HFP voice codec on SCO/eSCO.
- EATT
- Enhanced ATT. Additional L2CAP CIDs so ATT transactions do not head-of-line block.
- eSCO
- Extended SCO. Retransmitting synchronous voice; required for mSBC wideband HFP.
- Fluoride
- Current AOSP Bluetooth host stack (HCI through profiles), in the Bluetooth Mainline module.
- GATT
- Generic Attribute Profile. Services, characteristics and descriptors on top of ATT.
- HCI
- Host Controller Interface. Commands, events, ACL/SCO/ISO between host and controller.
- HFP
- Hands-Free Profile. AG on the phone, HF on the headset; AT + SCO/eSCO voice.
- HOGP
- HID over GATT Profile. BLE HID reports via GATT instead of Classic HID channels.
- IBluetoothHci
- AIDL HAL that carries HCI packets between Fluoride and the vendor transport.
- Inquiry / page
- Classic discovery (inquiry) versus connecting to a known BD_ADDR (page).
- IRK
- Identity Resolving Key. Lets a bonded peer resolve a Resolvable Private Address.
- ISO
- Isochronous transport for LE Audio (CIS/BIS), separate from ACL and SCO.
- L2CAP
- Logical link multiplexer over ACL. Channels for RFCOMM, AVDTP, ATT, HID, SMP, …
- LC3
- Mandatory LE Audio codec for voice and music.
- LE Secure Connections
- LE pairing with ECDH P-256 (BT 4.2+). Preferred over LE legacy pairing.
- LTK
- Long Term Key. LE encryption key stored when bonding.
- MAP
- Message Access Profile. Cars/watches browse or send messages over RFCOMM/GOEP.
- mSBC
- Modified SBC used as HFP wideband voice on eSCO.
- PACS
- Published Audio Capabilities Service. GATT service advertising LE Audio codec capabilities.
- Pairing
- The procedure that creates keys (SSP or SMP). Not the same as a profile connect.
- PBAP
- Phone Book Access Profile. Typically a car downloading contacts.
- RFCOMM
- Serial-port emulation over L2CAP. HFP AT, SPP, PBAP/MAP session bearer.
- RPA
- Resolvable Private Address. Rotating LE address that a peer with the IRK can still recognise.
- SCO
- Synchronous Connection-Oriented link. Reserved Classic slots for voice; no sniff while up.
- SDP
- Service Discovery Protocol. Classic browse for profile UUIDs before opening channels.
- SMP
- Security Manager Protocol. LE pairing and key distribution.
- Sniff
- Classic low-power ACL mode with periodic anchors. Not available during A2DP/SCO streaming.
- SSP
- Secure Simple Pairing for Classic: Just Works, Numeric Comparison, Passkey, OOB.
- Supervision timeout
- LE (and Classic) timer after which silence kills the link.
Interview questions
Fundamentals
What are the two planes of Bluetooth, and why do interviewers fail mixed answers?
The control plane leases the link: inquiry/page or advertise/scan, pairing (SSP/SMP), bonding, SDP, AVDTP/HFP/GATT procedures. The data plane is what rides afterwards: ACL (A2DP, RFCOMM payloads, ATT values), SCO/eSCO (HFP voice), ISO (LE Audio). Bugs and owners differ — an SMP reject is not an AudioPolicy miss. Name both planes, then stay on the one the question asked. The map is data-flow; this page is the walk.
How does Classic Bluetooth differ from BLE?
Classic (BR/EDR) discovers with inquiry, connects with page, then uses ACL plus optional SCO/eSCO. Typical phone jobs: A2DP, HFP, Classic HID, PBAP/MAP. BLE discovers with advertising, connects with CONNECT_IND, then uses LE ACL for ATT/GATT and ISO for LE Audio. Power and timing models differ (sniff vs connection interval). A dual-mode controller can do both; the procedures still do not mix. Do not drag in Wi-Fi.
What is ACL versus SCO/eSCO versus ISO?
ACL is the packet data link: A2DP media, AVRCP, RFCOMM, ATT. SCO is reserved Classic slots for voice; eSCO adds retransmissions (needed for mSBC). ISO is the LE Audio isochronous transport (CIS/BIS). Music on SCO or voice on A2DP is the junior mix-up.
What is pairing versus bonding?
Pairing is the ceremony that creates keys (Classic SSP or LE SMP). Bonding is writing those keys down (link key, or LTK/IRK/CSRK) so the next page or LE connect can encrypt without the UI. You can pair without bonding (keys vanish). You can be bonded and still not have A2DP started.
What is Fluoride, and what was BlueDroid?
Fluoride is the current AOSP host stack (HCI, L2CAP, RFCOMM, AVDTP, ATT/GATT, SMP, ISO host) in the Bluetooth Mainline module, run from com.android.bluetooth. BlueDroid is the historical name; you will still see it in directory names and old diagrams. It is not BlueZ userspace. Android uses kernel HCI + a vendor transport, not bluetoothd.
Where does Bluetooth run on Android — is it in system_server?
No. BluetoothManagerService in system_server turns the adapter on and binds to the stack. Profiles, GATT and Fluoride live in the com.android.bluetooth process so a stack abort does not kill the framework. Apps talk Binder to both. See frameworks and Binder & AIDL.
BluetoothAdapter versus BluetoothManager — what should you call in AOSP 13–15?
Get the adapter from BluetoothManager.getAdapter() (Context.BLUETOOTH_SERVICE). BluetoothAdapter.getDefaultAdapter() is the legacy static and is deprecated. Profile proxies still come from the adapter (getProfileProxy / getProfile APIs as of that SDK). GATT is device.connectGatt(...).
What is CompanionDeviceManager for?
The system association API: the app declares a filter, the OS shows a chooser, the user picks a device. That association is the modern pairing entry (watches, headphones, sensors) and can grant BLUETOOTH_CONNECT without the app running its own discovery UI. It is not a replacement for GATT once associated. Wear product flow: Wear OS.
Which Bluetooth runtime permissions exist since Android 12?
BLUETOOTH_SCAN, BLUETOOTH_CONNECT, BLUETOOTH_ADVERTISE. Scan no longer implies location if you set neverForLocation and you are not using BLE for location. Missing CONNECT is why a bonded device list or connectGatt fails with a SecurityException before HCI moves. Pre-12 used BLUETOOTH / BLUETOOTH_ADMIN plus location for scan.
What is HCI?
Host Controller Interface: the packet API between the host (Fluoride) and the controller firmware. Commands (reset, inquiry, LE set adv, create connection), events (connection complete, authentication), and data (ACL, SCO, ISO). On Android it crosses AIDL IBluetoothHci then UART/USB/shared memory. Wireshark reads a btsnoop of this pipe.
What is L2CAP?
The multiplexer on top of ACL. Fixed CIDs include signalling, SMP, and ATT (0x0004). Dynamic CIDs carry RFCOMM, AVDTP, HID, EATT. Interview sentence: "HCI ACL is the truck; L2CAP is the labelled crates inside."
GATT versus ATT — which word do you use when?
ATT is the PDU protocol (Read Request, Handle Value Notification, error codes, MTU). GATT is the data model and procedures on top: services, characteristics, descriptors, discovery. Apps see GATT APIs; snoop shows ATT. Saying "we sent a GATT packet" is sloppy; say ATT PDU for a service.
What is a GATT characteristic and what is a CCCD?
A characteristic is a value with a UUID, a handle and properties (read/write/notify/indicate). A CCCD (descriptor 0x2902) is how the client enables notifications (0x0001) or indications (0x0002). Enabling notify in Java without a CCCD write leaves the server silent.
What is A2DP in one hop list?
App audio → AudioFlinger / policy picks A2DP device → A2DP source in the bluetooth process → AVDTP configure/start → SBC/AAC/LDAC frames → L2CAP → ACL → controller → sink decode. Not SCO. Mixer internals: multimedia.
What is HFP in one hop list?
Telecom call + AudioPolicy voice route → HeadsetService (AG) → RFCOMM AT for call control → HCI Setup SCO/eSCO → CVSD or mSBC frames both ways. Headset is HF. Buttons can work (AT) while voice stays on the speaker (no SCO).
What is Secure Simple Pairing, and name the four association models?
Classic pairing that agrees a link key using public-key crypto. Models: Just Works (no MITM), Numeric Comparison (both confirm a 6-digit number), Passkey Entry, Out-of-Band (NFC or similar). IO capabilities pick the model. Headsets usually Just Works.
What is BLE advertising versus scanning?
Advertising is the peripheral (or broadcaster) sending PDUs on advertising channels on an interval. Scanning is the central listening during a scan window every scan interval; active scan also sends SCAN_REQ. Connection happens when a central hits a connectable advertiser with CONNECT_IND. Beacons are often non-connectable ads only.
What are connection interval, slave latency and supervision timeout?
I = how often the LE link schedules an event (7.5 ms–4 s). L = how many events the peripheral may skip. T = how long silence means the link is dead. Require T > (1+L)×I×2. Short I with L=0 is the watch-drain setting. After setup, lengthen I.
What is inquiry versus page on Classic?
Inquiry is "who is discoverable?" (GIAC). Page is "I know your BD_ADDR, please enter ACL." You page a bonded headset on reconnect; you do not need a full inquiry if the address is known. BLE has neither; it uses advertising.
Why must you not mix Bluetooth with Wi-Fi in an answer?
They may share a combo chip, antenna and a coexist scheduler (Qualcomm/MediaTek examples), but association, encryption, HCI and IP are different stacks. A2DP stutter is not a DHCP bug. Debug coexist as RF time-sharing only after each stack looks healthy. Wi-Fi walk: Wi-Fi.
What is a BD_ADDR, and why does a BLE address keep changing?
A 48-bit device address. Classic headsets usually have a stable public address. LE devices often use a Resolvable Private Address that rotates; a bonded central resolves it with the IRK. If you filter a hardcoded MAC in an app, the watch "disappears" every few minutes — that is privacy, not a stack bug.
What does BluetoothAdapter.enable() mean on modern Android?
Apps generally cannot silently turn radio on; the user (Settings, quick settings) or a privileged/companion flow does. enable() is restricted. Talk about BluetoothManagerService starting com.android.bluetooth and the HAL opening the transport, not about an app flipping a boolean.
Going deeper
Walk the Android Bluetooth layer cake from an app call to the air.
App → Binder → BluetoothManagerService (if this is adapter lifecycle) or profile/GATT AIDL in com.android.bluetooth → Java profile / GattService → JNI → Fluoride (L2CAP/profile) → HCI packets → AIDL IBluetoothHci → UART/USB/smem → kernel driver → controller firmware → Classic or LE LL on the air. Audio may additionally cross AudioFlinger and IBluetoothAudioProvider. Name one failure at a boundary (permission, Binder death, HAL timeout, firmware assert).
How does SSP pick Just Works versus Numeric Comparison?
Each side sends IO capabilities (DisplayYesNo, DisplayOnly, KeyboardOnly, NoInputNoOutput, KeyboardDisplay). The spec table maps the pair to an association model. A phone (DisplayYesNo) plus a headset (NoInputNoOutput) becomes Just Works — there is nothing to show a number on. Two phones become Numeric Comparison. Passkey appears when one side can type and the other can display. OOB is used when both advertise an OOB channel (NFC). MITM protection exists only for Numeric, Passkey and a trusted OOB path.
LE Secure Connections versus LE legacy pairing — what changes?
Legacy LE pairing (BT 4.0/4.1) can be passively cracked in Just Works/Passkey variants; STK/LTK derivation is weaker. LE Secure Connections (4.2+) uses ECDH P-256, the same association-model names, and a numeric comparison that actually binds the DH key. On AOSP you should prefer LE SC; a peer that only does legacy is a product decision, not "Android cannot pair." Bond still stores LTK + IRK.
Walk a BLE connection from advertise to a bonded encrypted link.
- Peripheral advertises (connectable; maybe extended).
- Central scans (window/interval); may active-scan for SCAN_RSP.
CONNECT_INDcreates the LE ACL with I, L, T and hop increment.- Optional ATT MTU exchange and GATT discovery (control-ish data).
- SMP pairing (LE SC if both can): IO caps, public keys, auth, key distribution.
- Bond: persist LTK/IRK/CSRK. Later connects encrypt immediately, including via RPA.
Then ATT notifies are the data plane. Do not start this list with AVDTP.
Walk GATT from BluetoothGatt to the controller.
App connectGatt → Binder → GattService in com.android.bluetooth → Fluoride GATT client → ATT PDUs on L2CAP CID 0x0004 (or EATT CIDs) → HCI ACL → IBluetoothHci → transport → firmware LL → peer ATT. Discovery is Read-by-group / Find-information. Notify enable is a CCCD write (0x0001). Default MTU 23 until Exchange MTU. Server role flips the same stack via BluetoothGattServer.
What is ATT_MTU, and why do firmware updates crawl?
Default ATT_MTU is 23, so a notification value is 20 bytes after the 3-byte ATT header. requestMtu() runs Exchange MTU; the effective size is the minimum of both peers and the controller buffer (often 517 on Android if everyone agrees). A DFU that writes 20-byte blobs over a 15 ms interval is a protocol bug, not a radio bug. Remember Write Command vs Write Request throughput (no ATT ack vs ack).
Notification versus indication — when do you use each?
Notification: server → client, no ATT ack; use for high-rate sensors (HR, HID reports) where a lost sample is acceptable. Indication: server waits for Handle Value Confirmation; use when the value must be processed (bond management, a one-shot alert). Indications head-of-line block that ATT bearer unless EATT provides another CID.
Walk A2DP from AudioTrack to the headset speaker.
App writes media usage → AudioFlinger mixes → AudioPolicy selects the A2DP device (not SCO, not speaker) → A2dpService / Fluoride AVDTP: discover, get capabilities, set config (SBC/AAC/LDAC/…), open, start → encoded frames on the AVDTP media L2CAP channel → ACL → controller → sink. Software encode lives on the AP; offload uses IBluetoothAudioProvider after the same AVDTP start. Focus and mixer: multimedia.
Why does A2DP use ACL instead of SCO?
SCO/eSCO is a low-rate reserved voice pipe (tens of kb/s, CVSD/mSBC). Music needs a variable, higher-rate packet pipe and a codec negotiation (AVDTP). ACL provides that. Putting music on SCO would sound like a phone call; putting a call on A2DP gives you one-way music latency and no guaranteed uplink mic. That is why two profiles exist — until LE Audio ISO replaces both.
Walk HFP from an incoming call to voice in the headset.
Modem/IMS signals the call → Telecom → HeadsetService sends AT RING / +CIEV over RFCOMM (ACL control) → user answers on headset or UI → AG/HF negotiate codec (CVSD vs mSBC) → HCI Setup Synchronous Connection → eSCO up → AudioPolicy device BLUETOOTH_SCO → voice frames both ways. If RFCOMM works and SCO fails, the call audio stays on the earpiece. The SIP/NAS call itself is not Fluoride.
mSBC versus CVSD — what has to be true on the air?
CVSD is narrowband (~8 kHz) on SCO or eSCO. mSBC is wideband HFP and needs eSCO plus both sides advertising the codec in AT +BAC / +BCS. A SCO-only controller or a car that rejects eSCO falls back to CVSD and "HD voice" disappears. That is negotiation, not a bad microphone capsule.
What does AVRCP do that A2DP does not?
AVRCP (AVCTP on ACL) is remote control and metadata: play/pause/skip, now-playing, absolute volume. A2DP is the media frames. You can have AVRCP buttons moving a local speaker if policy did not route to A2DP. Absolute volume can double-apply with the stream volume — look at AVRCP, not HCI UART.
Explain CIS and CIG in LE Audio unicast.
A CIS is one isochronous stream (e.g. left bud). A CIG groups CIS that share a timing domain (left+right, or speaker+mic). The controller schedules ISO events so both buds render the same sample clock. Control (PACS capabilities, ASCS ASE state) still rides GATT on LE ACL. Media bytes ride ISO, not ATT notifies.
What is Classic sniff mode, and when can you not use it?
After ACL goes idle, both sides agree a sniff interval and the radio only wakes at sniff anchors. That is the Classic standby lever. You cannot sniff while A2DP is streaming or SCO is up — those need regular slots. A page/reconnect loop also defeats sniff. BLE does not use sniff; it uses I and L.
Why does a short BLE connection interval drain a watch?
Each event the radio (and often the AP, if the controller delivers an HCI ACL) wakes. At I = 15 ms and L = 0 that is ~66 events/s, forever, even when the UI is asleep. Energy ≈ radio-on time × P_on + AP resumes. After pairing or a sync burst, request I in the hundreds of ms and a non-zero L so the watch may skip events. Companion policy: Wear OS; budget: power.
Scan window versus scan interval — what is the duty cycle?
Duty ≈ window / interval (then you still have to hit the 3 primary advertising channels). A 100% duty scan (window = interval) finds devices fastest and cooks the battery. Production companion scans use a low duty plus controller filters (UUID, IRK whitelist) so the AP stays suspended. Lab "always scanning" is not a ship setting.
What is the Bluetooth Audio HAL for?
AIDL IBluetoothAudioProvider (HIDL Bluetooth Audio on older devices) lets A2DP/HFP/LE Audio offload encode or PCM to a vendor DSP after Fluoride has set up AVDTP/SCO/CIS. Control still goes through Fluoride + HCI. If the provider fails, software fallback may still play at higher AP power and worse jitter. It is a data-plane shortcut, not a second pairing stack.
What is AIDL IBluetoothHci versus the old HIDL HCI?
Same job: move HCI command/event/ACL/SCO/ISO packets across the HAL. AOSP 13–15 devices should expose AIDL android.hardware.bluetooth.IBluetoothHci. HIDL 1.0/1.1 remains on older Treble devices. Interview-safe: name AIDL first, say HIDL on pre-13, do not invent extra packet types. Binder mechanics: Binder & AIDL.
How does a bonded Classic headset reconnect without pairing again?
The phone pages the stored BD_ADDR (or the headset pages the phone if it is the initiator). ACL comes up; both sides authenticate with the stored link key; encryption starts; SDP may be skipped if UUIDs are cached; A2DP/HFP state machines open AVDTP/RFCOMM. The user should see no numeric dialog. If one side wiped keys, authentication fails and you get a one-side-bond death spiral.
What is SDP, and when is it skipped?
Service Discovery Protocol on Classic ACL: browse UUIDs (A2DP sink, HFP HF, AVRCP, PBAP). Needed the first time you do not know the peer. Bonded reconnects often use a cached UUID list. BLE does not use SDP; it uses GATT discovery. An SDP timeout after ACL up is "profile never connects" with pairing already success.
What is RFCOMM used for on a phone?
A serial-port multiplexer over L2CAP. HFP AT commands, SPP vendor pipes, and the session bearer for PBAP/MAP (GOEP/OBEX on RFCOMM). It is control or bulk data on ACL — never A2DP media and never SCO voice. If RFCOMM cannot open, HFP buttons die even when ACL exists.
What does "dual-mode controller" mean?
Firmware that implements both Classic BR/EDR and LE link layers, usually on a combo chip that also has Wi-Fi. The host still speaks one HCI. A dual-mode headset can do A2DP and GATT; a BLE-only sensor cannot answer a Classic page. Coexist with Wi-Fi is RF scheduling, not a shared IP stack (Wi-Fi).
When do you mention ISO instead of ACL or SCO?
When the product is LE Audio: CIS/CIG unicast or BIS/BIG broadcast. ACL still carries GATT control (PACS/ASCS). SCO is Classic HFP only. Saying "LE Audio notify the audio on GATT" is wrong — GATT sets up the stream; ISO carries LC3 frames.
Advanced
Why is LE Audio the long-term replacement for A2DP and HFP, not a third codec on Classic?
A2DP and HFP are different pipes (ACL vs SCO), different codecs, poor stereo sync, and hearing aids were a side profile. LE Audio uses one ISO transport, one mandatory codec (LC3) for music and voice, CIG multi-stream sync for true-wireless buds, and BIS/Auracast for one-to-many. GATT (BAP/PACS/ASCS) is the control plane. Classic profiles stay for years of accessories; AOSP 13–15 still ship A2DP/HFP. Do not say "A2DP is deleted."
Explain BIS, BIG and Auracast without calling it a Wi-Fi hotspot.
A BIS is one broadcast isochronous stream; a BIG groups BIS (e.g. left/right or language tracks). The source advertises a Broadcast Audio Announcement; sinks sync the BIG and decode LC3. No per-listener ACL and usually no pairing for public broadcasts. Auracast is the product name. It is still Bluetooth LE ISO, not an SSID, not DHCP, not Wi-Fi.
LC3 versus SBC — what is the interview-safe comparison?
SBC is the mandatory A2DP fallback on Classic ACL: simple, robust, hungry at a given quality. LC3 is the mandatory LE Audio codec on ISO: better quality at lower bit-rate, and it covers voice and music so you do not need CVSD+SBC as two worlds. It is not "SBC but on BLE ACL." Bit-rates and quality charts belong in a codec review; the architecture point is transport + profile unification.
Walk A2DP offload versus the software encode path.
Both start with AudioPolicy picking A2DP and Fluoride completing AVDTP Start (control). Software: AP encodes SBC/AAC/LDAC, Fluoride writes HCI ACL for every frame — AP cannot deep-sleep. Offload: IBluetoothAudioProvider hands the session to a DSP/vendor path; HCI still carries start/stop and sometimes encoded fragments, but the hot PCM loop is not in Fluoride. If offload fails open, fallback to software. Confirm with dumpsys media.audio_flinger track type plus Bluetooth audio HAL logs. Mixer detail: multimedia.
How do SCO routing and A2DP policy collide during a call?
A2DP may stay connected. Policy must switch the voice usage to BLUETOOTH_SCO and typically pause or duck A2DP (some stacks suspend AVDTP). If policy leaves media on A2DP, ringtone or in-call tones go to the headset as music while the voice call is on the earpiece — or the reverse. Debug: HFP SLC + SCO complete in snoop, then dumpsys media.audio_policy devices for voice vs media. Two devices, two usages.
Who updates LE connection parameters, and what can go wrong?
Either side may send LL_CONNECTION_UPDATE (or L2CAP conn-param update on older peripherals). Android apps can request via GATT connection-priority APIs; the stack/controller may reject. Failures: T no longer satisfies (1+L)×I×2 → drops; central refuses a long I so a watch stays at 15 ms; a param update mid-DFU stalls throughput. Always read the accepted I/L/T in snoop, not the requested ones.
Give the supervision-timeout inequality and a numeric example.
T_supervision > (1 + L) × I × 2. Example: I = 200 ms, L = 4 → (5)×200 ms×2 = 2 s, so T must be greater than 2 s (pick 4–6 s). If someone sets T = 1 s "to detect dead peers quickly," the watch dropping into a Faraday lift looks like a stack crash. Quote the formula, then the accepted values from snoop.
How do RPA and IRK work, and what breaks if you ignore them?
A peripheral may advertise a Resolvable Private Address that rotates. A bonded central uses the IRK from SMP key distribution to resolve that RPA to an identity. If the host whitelist is identity-based, the controller can filter in firmware. Apps that persist the first seen MAC will lose the device. Clearing the IRK (one-side bond) looks like "it only connects when I forget the device."
What keys does SMP distribute, and what is each for?
LTK (or the LE-SC derived LTK) encrypts the link. IRK resolves RPAs. CSRK signs ATT writes without encryption (rare on phones). Classic bonding stores a link key instead. Identity address is distributed so you can show a stable Settings entry. Missing IRK is a privacy bug; missing LTK is "pairs every time."
What is the Bluetooth Mainline module, and why does that matter in a bring-up?
Fluoride + Java profiles ship as a Mainline/APEX module (com.android.bt / packages/modules/Bluetooth), updatable separately from the vendor HAL. A GMS update can change stack behaviour without a new vendor image. Bring-up still needs a matching IBluetoothHci and audio provider, firmware, and kernel driver. "We flashed AOSP and BT died" is often HAL/firmware, not Java.
What happens when com.android.bluetooth dies?
Profile proxies disconnect; adapter appears OFF then ON as BluetoothManagerService restarts the process; bonds should reload from the config store; in-flight SCO/A2DP/GATT all drop. system_server should survive. A crash loop is firmware/HAL death or a native abort in Fluoride — tombstone + HCI timeout, not an app ANR. Users see every headset fall off at once.
Combo chip coexist: what may you say, and what must you not say?
You may say the same die often hosts Wi-Fi + BT (Qualcomm/MediaTek examples), shares an antenna, and a coexist scheduler grants TDD slots. You must not say they share association, IP, or HCI. Debug BT first with snoop; if BT slots starve only when Wi-Fi is in heavy TX, then talk coexist. Kernel pieces: Linux Kernel & BSP.
What do Bluetooth 5 advertising extensions change?
Legacy ads are 31 bytes on 3 primary channels. Extended advertising puts a small header on primary and the payload (up to 255 bytes per PDU, chainable) on secondary channels; periodic advertising adds a timed sync. LE Audio announcements and richer beacons use this. It does not speed Classic inquiry and it is not a second A2DP.
What problem does EATT solve?
Classic ATT is one bearer (CID 0x0004). A long Read Blob or indication handshake blocks notifies. EATT opens additional L2CAP CIDs so a sensor notify can proceed while a DFU write runs. Both peers must support it; otherwise you stay on 0x0004. Mention it when they ask why a busy GATT client feels lossy.
What is absolute volume, and how does it bite you?
AVRCP Absolute Volume lets the phone slider drive the headset's volume register so the UI matches the cup. Bugs: headset ignores the set, phone also scales the PCM (double volume or inaudible), or a car applies its own gain. HCI ACL looks healthy. Dump AVRCP volume events and the stream volume; do not reflash firmware first.
What is Bluetooth Quality Report (BQR) at interview depth?
A vendor/AOSP mechanism (HCI vendor events + framework) that reports RSSI, SNR, packet loss, SCO/A2DP quality. Use it to distinguish "RF is terrible" from "AVDTP never started." Exact event IDs move — say "BQR / vendor quality events in snoop and dumpsys; I would read the current AOSP parser" rather than reciting a magic opcode.
Scenario & debugging
Pairing fails. Walk the bisect.
- Permissions / CDM cancel — never reaches HCI.
- Discovery: inquiry response or adv in snoop? Wrong transport (Classic page to BLE-only)?
- SSP/SMP: IO caps, numeric reject, passkey miss, Pairing Failed reason.
- HCI Authentication Failure after a stale bond (one-side keys).
- Clear bond on both ends; retry; confirm keys persist across reboot.
Commands: dumpsys bluetooth_manager, HCI snoop, logcat SMP/BTM tags. Do not start with Wi-Fi.
The device is bonded but will not reconnect after a reboot.
Check the bond store still lists the device after boot (dumpsys bluetooth_manager). If the phone lost keys, the peer will reject authentication. If the phone has keys and pages, look for page timeout (peer not in page-scan / not advertising) versus auth failure. Watches that only use RPA need the IRK. A firmware wipe that keeps Settings UI "bonded" is a UI/cache bug — trust snoop.
A2DP shows connected; music stays on the speaker.
Profile connected ≠ routed. Confirm AVDTP Start and a codec in snoop. Then dumpsys media.audio_policy / audio_flinger: is the media device A2DP or speaker? Focus stolen by another app, a usage mismatch, or an offload open failure that never fell back. This is often policy, not HCI. See multimedia.
During a call the headset buttons work but audio stays on the phone speaker.
RFCOMM AT is up (control); SCO/eSCO is not (data). Look for Setup Synchronous Connection success, eSCO vs SCO, mSBC reject falling into a failed SCO. Then policy device for voice must be BLUETOOTH_SCO. Fix the SCO handshake or the route; do not re-pair unless keys are actually gone.
A Wear OS watch dies in a day after a stack change. Where do you look?
Dump the LE connection parameters actually accepted (I, L, T). A 15 ms interval with L=0 is enough. Check scan duty on both sides, reconnect loops after bond loss, and whether a chatty GATT notify keeps the AP awake. HCI snoop timestamps + a current rail beat guessing. Product context: Wear OS; energy model: power.
GATT onCharacteristicChanged never fires after you "enabled notify."
Snoop for a CCCD write to 0x2902 with value 0x0001 (or 0x0002). setCharacteristicNotification(true) alone is local. Also check: encrypted link required by the peer, ATT error on the write, MTU leaving you parsing fragments wrong, or the peripheral not sending because a sensor is off. Connection drops (T too small) look like "one notify then silence."
How do you collect an HCI snoop log on Android?
Enable Developer options → Enable Bluetooth HCI snoop log (or the persist.bluetooth.btsnooplogmode / path properties on that build). Toggle Bluetooth so the file is created. Pull /data/misc/bluetooth/logs/btsnoop_hci.log or extract it from adb bugreport. Open as btsnoop in Wireshark. Confirm the property actually flipped — some user builds ignore it without a debug overlay.
Bluetooth process crash-loops after an OTA. How do you bisect?
tombstone in Fluoride vs Java vs HAL. If HCI initialize times out, suspect firmware/HAL/kernel transport, not Settings. Roll back the Bluetooth Mainline module versus the vendor image to see which side moved. IBluetoothHci version mismatch after a Treble/HAL bump is a classic. Kernel oops on the BT tty is BSP. Bonds may still be intact after you fix the crash.
Headset pairs; A2DP music is fine; HFP never connects.
SDP: does the peer advertise HFP HF? RFCOMM channel open fail? AG feature bits? Some headsets ship A2DP-only. If SDP shows HFP and RFCOMM dies, look at security (encrypt required) and the HFP state machine logs. Do not "fix" it by forcing SCO without an SLC — that violates the profile.
LE scan finds nothing in the field; nRF Connect on the same phone sees the beacon.
Your app filter (service UUID, name, PHY, legacy vs extended) is tighter than the other scanner, or you lack BLUETOOTH_SCAN / location rules, or you used a low-duty scan that misses a rare advertiser. Confirm with HCI: are LE Set Scan Enable and advertising reports present? If the controller reports ads and Java filters them, it is the app. If no reports, it is scan params, offload filter, or a disabled adapter.
True-wireless buds: only one ear has music.
On Classic this is often a vendor relay (one bud is the ACL peer; it forwards to the other) — a bud-side bug, not Android AVDTP. On LE Audio, check that the CIG actually has two CIS and both ASEs went streaming; a single CIS is "mono by setup." Do not debug it as A2DP codec quality. Snoop ISO/CIS setup and ASCS states.
A2DP stutters only when Wi-Fi is busy. Is that a Bluetooth bug?
After you prove AVDTP is started and the buffer is underrunning in quality reports, yes — coexist: the combo chip is starving BT slots. Fix is scheduler/antenna, not a new SBC bitpool. If Wi-Fi is idle and it still stutters, look at AP encode, offload jitter, or Classic RF. Do not start with DHCP. See Wi-Fi only for the coexist half.
Wear pairing is stuck on "Connecting…" after the numeric confirm.
SMP already succeeded; the hang is usually GATT service discovery, a companion account/CDM step, or the Data Layer transport coming up — not SSP. Snoop: encrypted LE link, ATT discovery completing, then whatever the companion writes next. Align phone and watch logs. Product flow: Wear OS. Do not wipe bonds until you see which hop never finishes.
Android 12+ app gets a SecurityException on getBondedDevices().
Missing BLUETOOTH_CONNECT (and a permission rationale/UI). This is not an HCI failure. Companion associations can grant connect for that device. Target-SDK and permission flags matter; a system UID Settings app is a bad comparison. Fix the manifest/runtime request, then retry.
How do you structure a 90-second "trace music to a Bluetooth headset" answer?
One sentence control (already bonded, A2DP connected). Then: AudioTrack → AudioFlinger → policy device A2DP → AVDTP already started → codec frames → ACL → controller → sink. Offer the offload fork. Contrast one sentence: a call would be SCO/HFP instead. Point mixer/focus at multimedia and the layer map at data-flow.
dumpsys says HFP connected; snoop has no SCO; user hears echo on speakerphone. What is going on?
SLC without a voice pipe. Policy may have fallen back to speaker/earpiece while HFP stays up for buttons. Or SCO completed and policy still has speaker — then snoop would show SCO and you would fix audio. Here snoop has no SCO, so establish eSCO (codec, AG/HF features) before chasing AEC. Echo on speakerphone is the fallback path working as designed.
After am crash com.android.bluetooth, bonds vanish. Is that expected?
No. A process restart should reload bt_config (or the current module equivalent). Vanishing bonds mean the config was not flushed, the file is corrupt, or you crashed during a write. Adapter OFF/ON from Settings should still list them. If a factory-reset flag or a wipe-on-crash path ran, that is a platform bug — capture the file and the crash.
Numeric Comparison numbers do not match, but the user accepts anyway. What should the stack do?
If the user confirms mismatched numbers, they have just opted into an active MITM. The stack will still create a link key — SSP cannot save a user who presses Pair on both sides without reading. Product UX should make the digits hard to ignore. Just Works has no digits at all; that is the headset case, not this one.