Conversation
Platforms only reported "paired / not paired", which conflated two very different outcomes: the user explicitly refusing the system pairing dialog, and the peripheral being unable to bond at all. Consumers could not tell them apart, so an app had no way to abort a connection when the user said no, while still tolerating devices that cannot bond. `pairingStateStream`, `onPairingStateChange` and the native `onPairStateChange` callback now emit a `PairingState` (paired / pairing / rejectedByUser / failed / unpaired). - Android: read `BluetoothDevice.EXTRA_REASON` from ACTION_BOND_STATE_CHANGED and map UNBOND_REASON_AUTH_REJECTED, AUTH_CANCELED and AUTH_TIMEOUT to `rejectedByUser`. - Android: BOND_BONDING no longer completes a pending `pair()` future; it is surfaced as `PairingState.pairing` progress. - Linux: map BlueZ AuthenticationRejected/Canceled/Timeout to `rejectedByUser`. BREAKING CHANGE: `pairingStateStream`, `onPairingStateChange` and `onPairStateChange` expose `PairingState` instead of `bool`.
The initial PairingState work only classified the outcome on Android and Linux. Windows kept passing a bool into the regenerated `OnPairStateChange(..., PairingState, ...)` signature, which no longer compiles, and Apple reported no pairing outcome at all. - Windows: map `DevicePairingResultStatus` to `PairingState`, so a cancelled prompt or a handler rejection becomes `rejectedByUser` while unpairable hardware stays `failed`. - Apple: CoreBluetooth has no bonding API — pairing is triggered by touching an encrypted characteristic, so classify the error of that operation and publish the resulting `PairingState`. Errors unrelated to the ceremony report nothing instead of a misleading state.
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.
universal_bleresolves user's connect cancellation of Bluetooth pairing as just "not paired", instead of give us exact statepairingStateStream,onPairingStateChangeand the nativeonPairStateChangecallback now emit aPairingState(paired / pairing / rejectedByUser / failed / unpaired).BluetoothDevice.EXTRA_REASONfromACTION_BOND_STATE_CHANGEDand mapUNBOND_REASON_AUTH_REJECTED,AUTH_CANCELEDandAUTH_TIMEOUTtorejectedByUser.pair()future; it is surfaced asPairingState.pairingprogress.rejectedByUser.BREAKING CHANGE:
pairingStateStream,onPairingStateChangeandonPairStateChangeexposePairingStateinstead ofbool.