Re: Access JNI methods from C++ Binder service

174 views
Skip to first unread message

Glenn Kasten

unread,
Dec 5, 2012, 10:59:22 PM12/5/12
to android-...@googlegroups.com
An example of what I think you're trying to do is AudioFlinger service within the native mediaserver process.
It accesses other services via binder, and those other services are implemented in Java programming language.
Note that AudioFlinger does not directly call JNI since it mediaserver is a native process, not a Dalvik process.
See the code in frameworks/{base,av}/services/audioflinger to see how it does this,
you'll also need to read the code in the other libraries that it links to.

On Tuesday, November 27, 2012 3:16:18 AM UTC-8, Arun wrote:
Hi,

I have a requirement to access a Java service from a native process.
The entry point is the native process started by init.rc and there is no UI, since I dont have any JVM reference I cannot initiate any communication to the java service from this process.
The way I am planning to do is, I have created a c++ binder service and my native process sends requests to this service, and through this Binder service I would like to access java class directly or through JNI.
Please let me know if it is possible.
This java service has a native interface, if my binder service is linked to that library can I call back java methods?
In summary can I access JNI or Java methods from a binder service without having JVM reference? 
please provide some example code if possible.
Thank you for your time.

br
Arun
Reply all
Reply to author
Forward
0 new messages