Search code examples
androidandroid-sourcerpcandroid-binder

How to provide RPC interface in an Android system service?


I'm developing a (native) service process whose executable resides on the system partition on Android 8.1/9.0. Let's call the process S. S is supposed to provide RPC service to a process V whose executable resides on the vendor partition. I read from Android Treble architecture that system components are separated from vendor ones by HIDL interfaces. Shall I use the callback interface in HIDL to accommodate my need, or shall I use some other mechanisms such as AIDL?


Solution

  • Yes, you need to use the Hardware Binder context together with HIDL.

    Background: There are now three Binder contexts:

    1. Framework Binder (/dev/binder)
      This is for IPC on system/framework side only. This Binder context uses AIDL.
    2. Vendor Binder (/dev/vndbinder)
      This is for IPC on vendor side only. This Binder context uses AIDL as well.
    3. Hardware Binder (/dev/hwbinder)
      This context allows connecting services from the vendor side with services from the system/framework side. Since Trebles goal is to allow system and vendor partitions to be updated individually, AIDL wasn't safe enough anymore. Thus HIDL was introduced and is used by this context.