How can my Android application communicate with my native daemon?

So, I have a custom Android application that works like System (built into the system application in my ROM). And Ive written a native daemon that works great and works as root. However, I was wondering how they can communicate? I know that I can have my own daemon creating a network socket, and the application connects to it, but using a local socket for IPC seems even better, but I'm struggling to find some code for it.

I decided that I could create a socket as described here , but I have no idea how to communicate with it in Java.

Any help would be greatly appreciated.

In addition, at first I wrote my own library and used JNI to communicate with it with Java, but quickly realized that it clearly works in the application context, so it cannot be run as root, which is a requirement, and something that can make own demon. Is using sockets a better alternative here or will binder work?

Thank you, ton!

+6
source share
1 answer

The solution here was to look at AOSP and see how installd interacts with the Installer Java application. In init.rc, you see how a named local socket is created, and in installd.c you see how native code interacts with the socket. In Installer.java you see how this is done in Java.

Do not think that Binder will be the right way for my particular use case.

+2
source

Source: https://habr.com/ru/post/954187/


All Articles