6

I'm currently studying how binders work in general. By looking at the following projects :

https://github.com/qianjigui/android_system_service_example https://github.com/cloudchou/NativeBinderJavaClientDemo

I understand that binder transaction is possible in

  • Native Service <-> Java Client
  • Native Service <-> Native Client
  • Java Service <-> Java Client

One last question that keeps bugging me is, is the following possible...?

  • Java Service <-> Native Client

I can't find any articles or code that actually implement this, neither people discussing about the possibility of it. From what I understand is the transaction is based purely on the .aidl description, so the implementation language doesn't matter so the above should be possible. But I just want to be sure...

Onik
  • 19,396
  • 14
  • 68
  • 91

3 Answers3

0

I think it can hardly use a native binder client, since binder API is not part of NDK. Here's a reference link:How to Create a android native service and use binder to communicate with it?

However, if you can get the ASOP all source codes, and use the android built tools, it will get possible.

0

With NDK binder API it became possible (available from Android 10), but service still cannot be started/bound from native code (without using private APIs).

https://developer.android.com/ndk/reference/group/ndk-binder

nsk
  • 310
  • 2
  • 9
0

It is fully possible: Binder crosses process boundaries, so the programming language used to implement the service or its caller is irrelevant. You can see native client -> java service easily, by using "service call" (for fun, try "service call phone 2 s16 555-1234" to bring up the dial window, or "service call statusbar 1", "service call statusbar 2", etc. The transaction does not require AIDL - AIDL merely creates the boilerplate code to facilitate it.

Note, however, that if you want to deal with Java objects, you'd need to do the "parceling" (serialization) yourself. That is, figure out what the Parcelable interface ordering is (in the readFromParcel), and then lay the primitive types (uint32_t, float, String, etc) one by one.

Technologeeks
  • 7,674
  • 25
  • 36