2

What are the differences between the services shown by these commands? How can I start a Service from normal Java classes and see it in "service list" to be able to access it from another native process to share data?

I have a native (C/C++ Code) binary running on the device and want it to connect to a service started in java. I already used the binder interface to share things between two different native applications. But is there a way to go directly up to java? (JNI might not work cause the binary has other permissions and is running long ago when the Java-App starts. When the app starts the service, the native code will automatically connect and start sending data.)

I have code where the native code starts a service and the Java part connects to. But in this case I do not have permissions to create services in the native part. But I can connect to an already running one.

Onik
  • 19,396
  • 14
  • 68
  • 91
user3387542
  • 611
  • 1
  • 8
  • 28
  • so you can bind to already started service, cannot you? you will then get a IBinder to talk to the service – pskink Sep 08 '14 at 16:46
  • @pskink I could not create a service in java wehere I can connect to from native code. How would you do this? Using another native binary creating the server, connecting on this service was no problem. – user3387542 Sep 08 '14 at 17:11
  • what api are you using to start/bind to a service? – pskink Sep 08 '14 at 17:15
  • @pskink I'm using the tools from https://github.com/vecio/AndroidIPC adapted to my needs. – user3387542 Sep 08 '14 at 19:37
  • maybe i missed something but i don't see any methods for binding to the Service, only sharable memory stuff – pskink Sep 08 '14 at 19:54
  • the fd (file descriptor) is sent using binder. The additional ASHMEM isn't important to me in this example. The important source file is this one. https://github.com/vecio/AndroidIPC/blob/master/jni/BinderSHM.cpp status_t setFD(uint32_t fd) is the method called using binder (server side). And virtual status_t setFD(uint32_t fd) is calling it (client side). The code is compiled twice, once using main as server and once using the jni methods from java (client). I need it the other way round now. (java or jni as server and main as client) – user3387542 Sep 08 '14 at 20:06
  • well, seems i cannot help here as it looks like a black magic for me... – pskink Sep 08 '14 at 20:25
  • Did you ever figure this one out? I have a service that has a package name like name but the C++ binder can't seem to find it/service list doesn't see it – Allison Nov 23 '20 at 07:41

0 Answers0