Search code examples
androidandroid-serviceipcrootandroid-binder

Android service with root permission


My goal is to create a service with root permission on an Android device such that I can communicate with this service from a regular app. Assume I have access to the platform build, but would like the least amount of change to it. The service could have functions making native system calls or using restricted APIs, and the regular app would be able to use IPC with the service to do work requiring root permission.

After looking into this, it seems an option is to create a native system service, register it with the SystemServer.java, and launch the service in init.rc. Alternatively, I could just add the service to init.rc without using the system server and use some other form of IPC, like unix domain sockets. What is the best approach?


Solution

  • Making your service as System Service (register it in SystemServer.java) should serve your purpose. If you need your service all the time, please start after getting boot complete intent.