fix(android): retry GATT subscribes dropped by GATT-busy races (1/4) - #210
Merged
Conversation
Android's GATT client allows one operation in flight; a CCCD write that races another subscribe is silently refused, leaving CAN notifications dead until reconnect. Replace the fire-and-forget descriptor write in DashKitDataSource with DashKitBleManager .subscribeWithRetry(), which verifies the write was queued and retries (up to 3x, 250ms apart). The helper is shared and will also back the Tesla status subscription.
This was referenced Aug 25, 2026
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.
Bottom layer of a 4-PR stacked series (the Android VIN / Tesla onboarding work above it builds on this). Also perfectly mergeable on its own.
Problem
Android's GATT client allows only one operation in flight. The CCCD (notification-enable) descriptor write that starts CAN notifications races other GATT operations during connection setup — and when it loses the race, Android silently refuses it. The old code ignored the write result entirely, so the app could sit connected with a subscribed-but-never-enabled characteristic: intermittent "connected but no dashboard data" until reconnect.
Fix
DashKitBleManager.subscribeWithRetry()— verifies the CCCD write was actually queued and retries up to 3× at 250 ms.DashKitDataSource.onServicesReady()uses it instead of the fire-and-forget inline write.The helper is deliberately generic ("CAN"/"Status" label params): the Tesla app-channel status subscription introduced later in this stack uses the same helper.
Scope discipline: 2 files, +42/−15. No behavior change beyond retry-on-refusal; no feature code.
Full
testDebugUnitTestgreen againstmain@b506147.Stack context
mainSupersedes parts of closed #201 / #206–#208 (re-layered so this fix ships independently of feature review).