Skip to content

android: detect auto-reconnected AirPods without waiting for SDP UUID lookup#570

Draft
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
thisisAcidic:fix-airpods-autoconnect-detection
Draft

android: detect auto-reconnected AirPods without waiting for SDP UUID lookup#570
thisisAcidic wants to merge 1 commit intokavishdevar:mainfrom
thisisAcidic:fix-airpods-autoconnect-detection

Conversation

@thisisAcidic
Copy link
Copy Markdown
Contributor

@thisisAcidic thisisAcidic commented May 3, 2026

The ACL_CONNECTED handler in `bluetoothReceiver` was checking `bluetoothDevice.uuids` immediately after calling `fetchUuidsWithSdp()`, but that call is asynchronous (the result arrives later via `ACTION_UUID`), so the immediate check only succeeded if the UUIDs happened to be cached. When the cache was cold the AirPods reconnected silently and the app stayed in the "AirPods not connected" state until the user manually tapped "Reconnect to last connected device".

This PR changes two things:

  1. The actual detection broadcast now fires from a new `ACTION_UUID` handler. `ACL_CONNECTED` either fires detection immediately if UUIDs are already cached, or kicks off `fetchUuidsWithSdp()` and waits. When the system delivers the resulting `ACTION_UUID`, we either match the discovered UUIDs against the Apple AAP UUID, or fall back to matching the saved `mac_address` for known devices. That removes the race against SDP completion without resorting to a hard-coded delay.

  2. `connectToSocket` now retries up to three times with 500 ms backoff when called from the auto-detect path. The L2CAP server on the AirPods sometimes is not yet ready the very instant the ACL link comes up. The same is true when force-connecting from Bluetooth settings while the AirPods were owned by another device. Manual reconnects keep the original behaviour and show the error toast on first failure.

Closes #569

@thisisAcidic thisisAcidic force-pushed the fix-airpods-autoconnect-detection branch from 99c1af3 to 5bf4e00 Compare May 3, 2026 14:00
@thisisAcidic thisisAcidic marked this pull request as draft May 3, 2026 14:30
…CAP socket connect

ACL_CONNECTED only kicks off SDP via fetchUuidsWithSdp; the actual
detection broadcast fires from the ACTION_UUID handler, which the
system delivers once SDP completes. That is the correct ready-signal
instead of polling the cached UUIDs immediately.

connectToSocket now retries up to three times with 500 ms backoff
when called from the auto-detect path. The L2CAP server on the
AirPods sometimes is not ready the first instant the ACL link
comes up (also seen when force-connecting from Bluetooth settings
while the AirPods were owned by another device). Manual reconnects
keep the original behaviour and show the error toast on first failure.

Closes kavishdevar#569
@thisisAcidic thisisAcidic force-pushed the fix-airpods-autoconnect-detection branch from 5bf4e00 to 7ec7741 Compare May 3, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App does not detect auto-reconnected AirPods until "connect last device" is tapped

1 participant