Fix: Stop device settings disappearing in crowded Bluetooth areas#484
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Fixed an issue where the device settings screen for connected AirPods would suddenly hide all controls (Noise Control, Conversation Awareness, etc.) when used in crowded Bluetooth environments — typically reproducible while commuting on trains or in busy public spaces. Settings now remain accessible as long as the AirPods are still connected, even if Bluetooth LE advertisements get drowned out by surrounding devices.
Technical Context
DeviceMonitor.deviceshad two merge branches for building each unifiedPodDevice—liveDevices(when a BLE snapshot was present) andcachedOnlyDevices(when only cache existed). The cached-only branch hardcodedaap = null, discarding the perfectly healthy AAP L2CAP connection whenever the BLE scan went stale (every 20-30 s in crowded RF environments).PodDevice.isAapConnectedthen flipped to false andDeviceSettingsScreenremoved every settings item from the LazyColumn.liveDevices, masking the bug entirely. The reporter could only repro on trains and in busy areas.isAapConnected = truewas always available — the merge just discarded it. The user-reported "AAP unstable" hypothesis didn't fit; the debug log shows AAP messages arriving 18+ seconds after the BLE eviction timestamp.forProfilehelper onMap<BluetoothAddress, AapPodState>and routed both branches through it, so they cannot silently drift apart again — this exact bug came from drift between branches.profile.addressonly (nocached.addressfallback):AapAutoConnectearly-returns ifprofile.addressis null, so AAP can never be active for a profile with a null bonded address. Adding a cached-address fallback would only create a risk of binding to a stale address from a previous run.DeviceMonitorTestwith 4 cases including the exact Settings disappear when not seen for >=25 seconds #483 scenario (BLE absent + cache present + AAP present → AAP must stay attached).Verified end-to-end on a Pixel 8 with bonded AirPods Pro 2 USB-C: temporarily shrank
STALE_DEVICE_TIMEOUTto 2 s to force continuous eviction, observed the settings UI remain visible across ~19 consecutiveRemoving stale device from cachelog entries, and confirmed an ANC mode change command still successfully reached the AAP socket while BLE was stale.Closes #483