Search code examples
androidandroid-sourcesystem-services

AOSP SystemService with TCP communication only


I am building a custom Android and I want to have a SystemService, which monitors some files. It needs system permissions, so that it can access files of other applications.

When searching the internet on how to build an Android SystemService, I only find examples, where some apps communicate with that service via a Manager and Binder. This is not necessary for me, as the Service should do its periodic checks and send reports via TCP/UDP. How would I build a very simple service (like a hello-world example), how would I start it automatically on boot, and how would I verify that it runs? adb shell service list?

Further, I already have a regular Android Service. Is there any easy way to integrate it as a System Service? Any help is much appreciated!


Solution

  • See this question: How to add a system service to the Android Framework

    Basically you would need to modify com.android.server.SystemServer to use a newly implemented com.android.server.SystemService subclass of your own creation. Look at com.android.server.twilight.TwilightService for an example.