Repository navigation
Reconnect after the phone's Bluetooth restarts - #19
Merged
Merged
Conversation
A user's card was stuck on "Connected. Not synced" with android.os.DeadObjectException. The phone's Bluetooth stack had restarted, no disconnect callback came, and every sync retried on the dead GATT handle. - A GATT call that throws DeadObjectException now counts as a lost link. - Bluetooth turning off ends the link at once. While it's off no reconnect is tried, and turning back on reconnects without the backoff. - A link lost mid-sync stops the sync instead of ending as Done. - The card no longer shows a wrapped exception's class name. Tested on the Fold with Bluetooth off/on and am crash com.android.bluetooth: back in 3 to 8 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a Bluetooth restart the strap reconnected but didn't sync: the 15 minute gap since the last auto sync still applied, so a sync the restart cut off waited up to an hour, with the card on "Sync stopped". - A reconnect syncs at once when the last sync failed. - A sync cut off by the old link can end only after the reconnect has skipped its own sync (it still showed as running). When it ends failed on a session that's been replaced, a full sync runs on the new one. - A sync that lost its link says "The link to the strap dropped." instead of whatever the dead link threw (a missing characteristic). Tested on the Fold with Bluetooth off mid-sync and a stack crash mid-sync: the sync ran again on the new link and the card showed Synced just now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A user's strap card was stuck on "Connected. Not synced" with
Sync stopped. android.os.DeadObjectException. The phone's Bluetooth stack had restarted. No disconnect callback came, so OpenStrap kept the dead GATT handle, still showed Connected, and every automatic sync retried on it and failed.Changes
GattClient: a GATT call that throwsDeadObjectExceptionnow marks the link lost, so the usual reconnect runs with a fresh handle.StrapManager: listens for Bluetooth turning off and on. Off ends the link at once and no reconnect is tried while it's off (Zepp'sjv3.L()also waits). On reconnects at once, without the backoff.HistorySync: a link lost mid-sync stops the sync instead of failing each remaining type and ending as Done, and the card says "The link to the strap dropped." instead of a wrapped exception's class name or whatever the dead link threw.Zepp has no equivalent: nothing on its strap side reacts to Bluetooth coming back on, and a failed write on a dead link doesn't end its connection (codemap 02 §8.4 in the analysis repo).
Testing
adb shell cmd bluetooth_manager disablethenenable, andadb shell am crash com.android.bluetooth. Both were back connected in 3 to 8 s, with no reconnect attempts while Bluetooth was off.DeadObjectExceptionpath itself (the Fold broadcasts Bluetooth off when its stack crashes, so the receiver gets there first).🤖 Generated with Claude Code