Let’s have some practical activities in the AOSP development domain. We are going to implement communication between the application layer and a HAL service through an AIDL interface. To do that, we should take some steps. In fact, we should implement a service in the HAL layer, an application or service in the application layer, and develop an AIDL interface as well. But it’s all of that because we will have something to do with SELinux as well.
I will try to break it into some steps. Then we can follow them to reach the communication. It is going to be fun. We will implement the HAL service with C++, the AIDL interface has its own simple language; and the application layer will be developed with Kotlin.
The steps that should be taken
- Implement an AIDL interface
- Implement a HAL service with the AIDL interface
- Add required SELinux policies
- Implement an application and communicate through AIDL
All the steps will be done as part of AOSP. So, that can be supposed a journey among AOSP. But before the next step, you should clone and build AOSP locally. You can read another post through the link below to set it up:
I need to prepare a separate post for each step; otherwise, it will be a long post that you cannot walk over and will also be boring and confusing. In each step, I will prepare a brief of what we’re going to do and how it works. Then it will be followed by the code and a GitHub link where you can find the code. Finally, we will test them in the emulator and see the result.
The next posts will come soon!
how to add sepolicies to this
You can find the sepolicies in the sample code in Github.
https://github.com/Heydarchi/AIDL-HAL-Service
could you please explain the file locations briefly
hai bro, if i am following your steps then my service is not registering in android 12 version so do we need to add in systemserviceregistry.java and systemserver.java to register our service.
No, the registration is taking place in main() function for the HAL service. But to make it available it should be added to PRODUCT_PACKAGES and the se-policies should be configured correctly.
But to find the problem if it relates to SELinux you can run the emulator in Permissive mode.