JuulLabs / able

Able: Android Bluetooth Low Energy library
Apache License 2.0
160 stars 11 forks source link

Reconsider when to configure KeepAliveGatt's internal Gatt #80

Closed twyatt closed 4 years ago

twyatt commented 4 years ago

With #72, the KeepAliveGatt's internal Gatt property was changed to be configured prior to invoking the onConnectAction.

This resolves potential crashes when attempting to invoke KeepAliveGatt I/O methods from within the connection handler functions, but opens up potential bugs.

If a library consumer performs some critical I/O from within the onConnected connection handler (and needs those actions to be perform before any other I/O) then allowing I/O operations on KeepAliveGatt during the onConnected function could cause hard to track down bugs. It would be preferred that the external I/O threw NotReady (as that is the expected state until onConnected handler has completed.

tl;dr Consider reverting 024fc38.

twyatt commented 4 years ago

For now, decided to leave the current implementation as-is. The event Flow does not suspend connection handling so the benefits of restricting this would not be helpful anyways.

It would be too limiting to prevent operations from within the event handling Flow.