Skip to content

fix(android): ensure enable() promise waits for PoweredOn state before resolving#1336

Open
alexviar wants to merge 1 commit intodotintent:masterfrom
alexviar:fix/android-enable-wait
Open

fix(android): ensure enable() promise waits for PoweredOn state before resolving#1336
alexviar wants to merge 1 commit intodotintent:masterfrom
alexviar:fix/android-enable-wait

Conversation

@alexviar
Copy link
Copy Markdown

@alexviar alexviar commented Apr 18, 2026

This PR fixes a critical bug on Android where the enable() promise resolves prematurely before the Bluetooth adapter has actually completed the transition to PoweredOn.

The Problem:
In BleModule.java, the state change logic uses takeUntil followed by firstOrError. Since RxBleAdapterStateObservable emits the current state immediately upon subscription, if the adapter is STATE_OFF, the stream emits this value (which passes the takeUntil predicate as it's not the final state) and firstOrError resolves the JS promise instantly.

The Solution:
Replacing takeUntil with filter ensures the sequence only continues (and thus resolves the promise) when the desired state is actually reached.

@alexviar alexviar marked this pull request as draft April 18, 2026 22:29
@alexviar alexviar marked this pull request as ready for review April 18, 2026 22:38
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.

1 participant