Re: Accessing native service from an application
See inline.., what I tell u is only something works but may not be the good way On Apr 20, 2009, at 12:07 PM, Archer archerstark...@gmail.com wrote: Greetings, Dianne, Yi and others, I have a need to do something similar, that is to access a backend native service from the application. Going through the messages here, there are several things that are unclear to me. I'd really appreciate if you can provide more information on them. (1) On the native service side (C/C++), I can create a native binder service class. I can also implement a native executable to instantiate the binder service and add the service to the service manager. Then what is the right way to start the native service? (Run the native executable in some start up scripts?) [yi] I hook it up from init.rc (2) On the application side (Java), Dianne, you mentioned make a shared library that apps request with uses-library, exactly what is this shared library? Is it the native shared library containing the interface implementation of the service? [yi] take a look at developer/samples/platform you will get it Archer On Apr 1, 10:46 am, Dianne Hackborn hack...@android.com wrote: On Wed, Apr 1, 2009 at 5:39 AM, iblues iblues@gmail.com wrote: With respect to performance, which approach is more better? Because all the other modules in Android such as Camera or Media Recorder module all use native binding and JNI layer for java access. It just depends how you want to structure things. Eventually you are going to hit the IPC barrier; the most important thing is probably to keep that as efficient as possible (in particular reducing the number of IPCs that occur as much as possible). -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
Sorry, the path mentioned in the last e-mail is wrong. The correct path is development/samples/PlatformLibrary/ On Mon, Apr 20, 2009 at 12:22 PM, Yi Sun beyo...@gmail.com wrote: See inline.., what I tell u is only something works but may not be the good way On Apr 20, 2009, at 12:07 PM, Archer archerstark...@gmail.com wrote: Greetings, Dianne, Yi and others, I have a need to do something similar, that is to access a backend native service from the application. Going through the messages here, there are several things that are unclear to me. I'd really appreciate if you can provide more information on them. (1) On the native service side (C/C++), I can create a native binder service class. I can also implement a native executable to instantiate the binder service and add the service to the service manager. Then what is the right way to start the native service? (Run the native executable in some start up scripts?) [yi] I hook it up from init.rc (2) On the application side (Java), Dianne, you mentioned make a shared library that apps request with uses-library, exactly what is this shared library? Is it the native shared library containing the interface implementation of the service? [yi] take a look at developer/samples/platform you will get it Archer On Apr 1, 10:46 am, Dianne Hackborn hack...@android.com wrote: On Wed, Apr 1, 2009 at 5:39 AM, iblues iblues@gmail.com wrote: With respect to performance, which approach is more better? Because all the other modules in Android such as Camera or Media Recorder module all use native binding and JNI layer for java access. It just depends how you want to structure things. Eventually you are going to hit the IPC barrier; the most important thing is probably to keep that as efficient as possible (in particular reducing the number of IPCs that occur as much as possible). -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
Got it. That's very helpful. Thank you so much, Yi. Archer On Apr 20, 12:56 pm, Yi Sun beyo...@gmail.com wrote: Sorry, the path mentioned in the last e-mail is wrong. The correct path is development/samples/PlatformLibrary/ On Mon, Apr 20, 2009 at 12:22 PM, Yi Sun beyo...@gmail.com wrote: See inline.., what I tell u is only something works but may not be the good way On Apr 20, 2009, at 12:07 PM, Archer archerstark...@gmail.com wrote: Greetings, Dianne, Yi and others, I have a need to do something similar, that is to access a backend native service from the application. Going through the messages here, there are several things that are unclear to me. I'd really appreciate if you can provide more information on them. (1) On the native service side (C/C++), I can create a native binder service class. I can also implement a native executable to instantiate the binder service and add the service to the service manager. Then what is the right way to start the native service? (Run the native executable in some start up scripts?) [yi] I hook it up from init.rc (2) On the application side (Java), Dianne, you mentioned make a shared library that apps request with uses-library, exactly what is this shared library? Is it the native shared library containing the interface implementation of the service? [yi] take a look at developer/samples/platform you will get it Archer On Apr 1, 10:46 am, Dianne Hackborn hack...@android.com wrote: On Wed, Apr 1, 2009 at 5:39 AM, iblues iblues@gmail.com wrote: With respect to performance, which approach is more better? Because all the other modules in Android such as Camera or Media Recorder module all use native binding and JNI layer for java access. It just depends how you want to structure things. Eventually you are going to hit the IPC barrier; the most important thing is probably to keep that as efficient as possible (in particular reducing the number of IPCs that occur as much as possible). -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
Not me, it is Dianne :-) On Mon, 2009-04-20 at 15:39 -0700, Archer wrote: Got it. That's very helpful. Thank you so much, Yi. Archer On Apr 20, 12:56 pm, Yi Sun beyo...@gmail.com wrote: Sorry, the path mentioned in the last e-mail is wrong. The correct path is development/samples/PlatformLibrary/ On Mon, Apr 20, 2009 at 12:22 PM, Yi Sun beyo...@gmail.com wrote: See inline.., what I tell u is only something works but may not be the good way On Apr 20, 2009, at 12:07 PM, Archer archerstark...@gmail.com wrote: Greetings, Dianne, Yi and others, I have a need to do something similar, that is to access a backend native service from the application. Going through the messages here, there are several things that are unclear to me. I'd really appreciate if you can provide more information on them. (1) On the native service side (C/C++), I can create a native binder service class. I can also implement a native executable to instantiate the binder service and add the service to the service manager. Then what is the right way to start the native service? (Run the native executable in some start up scripts?) [yi] I hook it up from init.rc (2) On the application side (Java), Dianne, you mentioned make a shared library that apps request with uses-library, exactly what is this shared library? Is it the native shared library containing the interface implementation of the service? [yi] take a look at developer/samples/platform you will get it Archer On Apr 1, 10:46 am, Dianne Hackborn hack...@android.com wrote: On Wed, Apr 1, 2009 at 5:39 AM, iblues iblues@gmail.com wrote: With respect to performance, which approach is more better? Because all the other modules in Android such as Camera or Media Recorder module all use native binding and JNI layer for java access. It just depends how you want to structure things. Eventually you are going to hit the IPC barrier; the most important thing is probably to keep that as efficient as possible (in particular reducing the number of IPCs that occur as much as possible). -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
Hi Dave, With respect to performance, which approach is more better? Because all the other modules in Android such as Camera or Media Recorder module all use native binding and JNI layer for java access. Regards, iblues On Mar 31, 10:36 am, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.comwrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.comwrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.comwrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.comwrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.comwrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.comwrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.comwrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.comwrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en
Re: Accessing native service from an application
Could you please explain more what you are trying to do? If you are trying to add a service with a public API for applications to use, one approach you can take is to make a shared library that apps request with uses-library which has APIs to retrieving and calling the service. That shared library can use non-SDK classes like the ServiceManager, since it is intended to be bundled with the device. But I really don't know enough about what you are trying to accomplish to help more. On Tue, Mar 31, 2009 at 3:54 PM, Yi Sun beyo...@gmail.com wrote: So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.comwrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.comwrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.com wrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as
Re: Accessing native service from an application
I'm trying to relay some information (events) between Android application and a native application. The idea is to have a background native process running as a service that can be accessed by Android applications through binder interface. The native process is written by C and it will be a lot works to convert it to other lang. It will be easier to add a Binder interface into it and make it work as a android service. I guess we could use socket to do this as well. But I hope we use an unified interface like Binder. Yi On Tue, Mar 31, 2009 at 4:14 PM, Dianne Hackborn hack...@android.comwrote: Could you please explain more what you are trying to do? If you are trying to add a service with a public API for applications to use, one approach you can take is to make a shared library that apps request with uses-library which has APIs to retrieving and calling the service. That shared library can use non-SDK classes like the ServiceManager, since it is intended to be bundled with the device. But I really don't know enough about what you are trying to accomplish to help more. On Tue, Mar 31, 2009 at 3:54 PM, Yi Sun beyo...@gmail.com wrote: So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.comwrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.comwrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.com wrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer
Re: Accessing native service from an application
Okay so just do what I suggested, add your own shared library for accessing it. You are going to need to do that anyway, since you will at least need to have the binder interface somewhere for someone to link to, or if you weren't going to use the binder surely you would have something besides a raw socket as the API for applications. On Tue, Mar 31, 2009 at 4:22 PM, Yi Sun beyo...@gmail.com wrote: I'm trying to relay some information (events) between Android application and a native application. The idea is to have a background native process running as a service that can be accessed by Android applications through binder interface. The native process is written by C and it will be a lot works to convert it to other lang. It will be easier to add a Binder interface into it and make it work as a android service. I guess we could use socket to do this as well. But I hope we use an unified interface like Binder. Yi On Tue, Mar 31, 2009 at 4:14 PM, Dianne Hackborn hack...@android.comwrote: Could you please explain more what you are trying to do? If you are trying to add a service with a public API for applications to use, one approach you can take is to make a shared library that apps request with uses-library which has APIs to retrieving and calling the service. That shared library can use non-SDK classes like the ServiceManager, since it is intended to be bundled with the device. But I really don't know enough about what you are trying to accomplish to help more. On Tue, Mar 31, 2009 at 3:54 PM, Yi Sun beyo...@gmail.com wrote: So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.comwrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.com wrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.com wrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a
Re: Accessing native service from an application
Dianne, BTW--- should we make the binder.c in the service_manager directory into a library? So that people who write native service by C can reuse the code. What do you think? Yi On Tue, Mar 31, 2009 at 4:41 PM, Yi Sun beyo...@gmail.com wrote: Dianne, Thank you for the hint. I will try this out to see if I can make it work or not. Yi On Tue, Mar 31, 2009 at 4:24 PM, Dianne Hackborn hack...@android.comwrote: Okay so just do what I suggested, add your own shared library for accessing it. You are going to need to do that anyway, since you will at least need to have the binder interface somewhere for someone to link to, or if you weren't going to use the binder surely you would have something besides a raw socket as the API for applications. On Tue, Mar 31, 2009 at 4:22 PM, Yi Sun beyo...@gmail.com wrote: I'm trying to relay some information (events) between Android application and a native application. The idea is to have a background native process running as a service that can be accessed by Android applications through binder interface. The native process is written by C and it will be a lot works to convert it to other lang. It will be easier to add a Binder interface into it and make it work as a android service. I guess we could use socket to do this as well. But I hope we use an unified interface like Binder. Yi On Tue, Mar 31, 2009 at 4:14 PM, Dianne Hackborn hack...@android.comwrote: Could you please explain more what you are trying to do? If you are trying to add a service with a public API for applications to use, one approach you can take is to make a shared library that apps request with uses-library which has APIs to retrieving and calling the service. That shared library can use non-SDK classes like the ServiceManager, since it is intended to be bundled with the device. But I really don't know enough about what you are trying to accomplish to help more. On Tue, Mar 31, 2009 at 3:54 PM, Yi Sun beyo...@gmail.com wrote: So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.comwrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.com wrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.com wrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.com wrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.comwrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like
Re: Accessing native service from an application
Sorry I have never actually looked at that code; I have only dealt with the C++ code. On Tue, Mar 31, 2009 at 5:11 PM, Yi Sun beyo...@gmail.com wrote: Dianne, BTW--- should we make the binder.c in the service_manager directory into a library? So that people who write native service by C can reuse the code. What do you think? Yi On Tue, Mar 31, 2009 at 4:41 PM, Yi Sun beyo...@gmail.com wrote: Dianne, Thank you for the hint. I will try this out to see if I can make it work or not. Yi On Tue, Mar 31, 2009 at 4:24 PM, Dianne Hackborn hack...@android.comwrote: Okay so just do what I suggested, add your own shared library for accessing it. You are going to need to do that anyway, since you will at least need to have the binder interface somewhere for someone to link to, or if you weren't going to use the binder surely you would have something besides a raw socket as the API for applications. On Tue, Mar 31, 2009 at 4:22 PM, Yi Sun beyo...@gmail.com wrote: I'm trying to relay some information (events) between Android application and a native application. The idea is to have a background native process running as a service that can be accessed by Android applications through binder interface. The native process is written by C and it will be a lot works to convert it to other lang. It will be easier to add a Binder interface into it and make it work as a android service. I guess we could use socket to do this as well. But I hope we use an unified interface like Binder. Yi On Tue, Mar 31, 2009 at 4:14 PM, Dianne Hackborn hack...@android.comwrote: Could you please explain more what you are trying to do? If you are trying to add a service with a public API for applications to use, one approach you can take is to make a shared library that apps request with uses-library which has APIs to retrieving and calling the service. That shared library can use non-SDK classes like the ServiceManager, since it is intended to be bundled with the device. But I really don't know enough about what you are trying to accomplish to help more. On Tue, Mar 31, 2009 at 3:54 PM, Yi Sun beyo...@gmail.com wrote: So it seems that I only have following choices: 1. write my own JNI to access my service. 2. hack the ApplicationContext to add my service into into getSystemService. I also need to build my own service class into android.app package. In my client, I will call getSystemService collect my service handle and do binder operations. Yi On Tue, Mar 31, 2009 at 2:31 PM, Dianne Hackborn hack...@android.com wrote: It is not in the SDK, and as a rule applications should not be directly accessing system services. You'll note that there are tons of system services in the standard android platform, and they all have appropriate SDK APIs for calling them (and the Context.getSystemService() API to allow apps to access them). On Tue, Mar 31, 2009 at 1:47 PM, Yi Sun beyo...@gmail.com wrote: But, the ServiceManager is not an exported java API at all. Thanks Yi On Tue, Mar 31, 2009 at 12:48 AM, Dianne Hackborn hack...@android.com wrote: You are mixing two different things. You are creating a low-level core system service, and then trying to connect to it as if it is a high-level application service. If you are using service manager to publish it, you need to use service manager (in Java ServiceManager) to access it. On Mon, Mar 30, 2009 at 10:45 PM, Yi Sun beyo...@gmail.comwrote: Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.com wrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.comwrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement
Re: Accessing native service from an application
Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---
Re: Accessing native service from an application
Hi Dianne, Thanks for the reply. Actually here is what I want to do: On the service side (C code), reusing binder.c in the service_manager directory. So my code will call 1. binder_open, 2. bio stuff to build an io block for adding service, 3.binder_call to add service to service_manager. 4. binder_loop to wait for requests. (Just do a quick prototype here, so no multi-threads) On the client side (java), send request to the service I built and receive replies. Now, if I run /system/bin/service list, I can see my service like this: # /system/bin/service list Found 43 services: 0Binder.Test.IBindertest: [] But, on the java side, I can not really get the binder object for this service. The bindService call failed with following error messages: W/ActivityManager( 581): Unable to start service Intent { action=Binder.Test.IBindertest }: not found Yi On Mon, Mar 30, 2009 at 10:01 PM, Dianne Hackborn hack...@android.comwrote: If you are writing a low-level system service, the high-level Service API (onBind() etc) is irrelevant. The aidl stuff is part of the primitive Binder IPC stuff; Service is a much higher-level facility built on top of it. On Mon, Mar 30, 2009 at 7:21 PM, beyounn beyo...@gmail.com wrote: Ok, let me try out the AIDL part, it seems simpler. But I do have a question about it and hope you could give more hits. I took a look on the AIDL, it seems that on the service(server) side, we have to implement onBind and other methods. For my case, does it mean that I don't need to care about the service side works and only need to implement something like RemoteServiceBinding.java in the example code for my self? Thanks Yi On Mar 30, 6:36 pm, Dave Sparks davidspa...@android.com wrote: You can write AIDL to generate your Java binding, or you can write your own native binding and put a JNI layer on top of that. If you don't plan on calling your service from native code, AIDL is much easier. On Mar 30, 6:08 pm, beyounn beyo...@gmail.com wrote: Hello, I'm writing a service by C. My code calls binder to add a service called myservice into servicemanager. And I can add myservice without any problem. Also, when I run /system/bin/service list, it shows the service added by me. The question is -- What is the correct way to access this service from my application that is written by java? Thanks Yi -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups android-framework group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~--~~~~--~~--~--~---