-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AndroidApp::vm_as_ptr() and ::activity_as_ptr() APIs #61
Conversation
@MarijnS95 hopefully this looks like a reasonable initial solution for exposing the JNI pointers we need without needing the |
I think, as long as there is a builder pattern available to explicitly pass these values from |
This enables applications to make JNI calls without needing the `ndk-context` crate - which we would like to deprecate. Fixes: rust-mobile#60
645e5fa
to
dc9ca83
Compare
Thanks for looking over the patch. I've applied the suggested changes.
Yeah - probably my main concern with this direction atm is that the ergonomics aren't going to be great. These APIs that accept raw pointers will need to be Regardless of exactly how the dots are joined though I think it still makes sense that there is at least some way to access the JNI pointers directly from an |
Agreed, we can't have the latter without at least having the former (this PR). Did we already have an issue describing how to proceed to get rid of For starters I'd look at the few consumers of |
* Since [1] android-activity exposes jvm and activity pointers. Use them directly instead of depending on ndk-context. Passing them via OnceLock isn't the prettiest way but well... it works. [1]: rust-mobile/android-activity#61
This enables applications to make JNI calls without needing the
ndk-context
crate - which we would like to deprecate.For now this just exposes the raw pointers, and makes no assumptions about what crates an application will use to make JNI calls - which means that some amount of
unsafe
code will be required when passing these to other crates.The added
_as_ptr()
suffix makes this clear, and also means we can consider adding similar (suffix-free) getters later that would returnjni
crate types that could reduce the need for unsafe code before making JNI calls.Fixes: #60