Android: Initialize jni-utils #449
Open
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.
I'm in the process of integrating this library into an Android application and am hoping to contribute a handful of improvements to help address some of the challenges folks face when getting this to work.
This first change is to push initialization of the
jni-utils-rscrate into this library directly. This is a critical step to getting callbacks from the Java code to wake up Rust futures, but is not consistently shown in the examples I've tracked down. Some examples establish peer dependencies onbtleplugandjni-utils-rs, but those need to be carefully version-matched, causing fragility (and unfortunately in my testing, silent bugs that are hard to run down).Since
btleplugdirectly depends on this crate, the initialization here made sense. I don't love theunwrap()and am very open to ideas about how to better surface these types of early initialization errors to the application.