I am not sure what you are trying to accomplish.
If you want a service that runs in system process then you should have a loot at: http://processors.wiki.ti.com/index.php/Android-Adding_SystemService.
If you want this service to restart whenver someone kills it, or whenever the servicemanager is killed. Then you need to do the follwing:
- Your class must have a
void main(int arcgc, argv[]) that runs it. This means that your service must be an executable (written in cpp)
- Add this to
init.rc:
service your_service_name location
class main
critical
onrestart restart zygote
And also modify where it says servicemanager:
service servicemanager /system/bin/servicemanager
class core
user system
group system
critical
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm
onrestart restart your_service_name
You should have a look at: https://github.com/android/platform_system_core/blob/master/init/README.md
for more options.
If you want a reference to look at bootanim in init.rc and see how it is implemented