-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support for exposing services #53
Comments
looked into this a bit. unlike the |
Thanks for looking into this. I'm going to close the issue for now, as I don't see a way forward. |
Hi, I'm a complete noob to this stuff and trying to write my first android app in rust, so sorry if this is a dumb question. Would it be possible to let users define services and have I was hoping to avoid having to deal with java and android studio, and it's cool that this project allows me to do that for the simple test app that I've written, but now I want to run my app as a background service. Since ordinary non-OEM developers are allowed to define services, and since (Again, sorry for the noise if I'm being dumb. I've only been learning android for an entire hour.) |
It may be possible to invent a NativeService. I guess the first step would be to copy the NativeActivity (from the Android sources) and try to build an APK using the custom NativeActivity instead of the stock one. Then we could discuss extending cargo-apk/ndk-glue/etc with some service callbacks. |
For the record android-ndk-rs doesn't generate anything besides AndroidManifest.xml. The rest is C bindings (and safe wrappers) around the NDK, toolchain discovery and setting up the compiler/linker to target Android. Since the NDK does not provide any API to host native services this sounds like a separate project/crate that does all the heavy Java lifting through JNI. |
I agree with you that any jni stuff is out of scope (last part of the diagram below). But this is about the entry point:
I think this might be in scope for |
@dvc94ch Ah, right, that sounds okay I guess. We have much better support for custom Manifest entries in That said I do wonder if you can get away with implementing this in pure Rust through the JNI, instead of going through Java and |
That isn't possible, all apks are java applications with possibly native dynamic libraries. In addition there is a default java activity called |
I guess once someone gives it a go and opens a PR and there is a concrete proposal we can discuss it further. I think we will have to create a custom rust loader in java and support it in ndk-glue and cargo-apk. |
@dvc94ch Indeed |
@s1341 I see you wrote a rust binder implementation interfacing directly with /dev/binder. does this actually work without rooting? |
You cannot register a service without root, unfortunately. But you can talk to existing services/content-providers/etc. |
Doesn't the NDK expose a Binder API nowadays? https://developer.android.com/ndk/reference/group/ndk-binder |
I'm a bit confused. android.jar seems to be mostly thin wrappers around aidl generated code. aidl has a c++ and rust backend. why doesn't the ndk generate support for all the services? Can we use the rust aidl backend to generate bindings that work? |
Isn't that Rust backend fairly new? I'm not surprised/confused why our But I'm all in favour of adding a new |
It doesn't seem like there is currently support for exposing services from an application.
I'd like to add this feature... How do I wire up the service from the 'java' to a function?
The text was updated successfully, but these errors were encountered: