1

i want to register my service or my application in init.rc

In other words , a normal android application has ZYGOTE as its parent , which can be killed after a force stop . But if registering or making my application parent init.rc , i would be able to achieve what i want to !

Any information on same ? Thanks in advance

rolling.stones
  • 496
  • 3
  • 9
  • 20

2 Answers2

1

AFAIK only executables can be started from init.rc. there is no way to start a android service from init.rc.

nandeesh
  • 24,740
  • 6
  • 69
  • 79
  • alright , how do i put my executable in side init.rc for it to be auto executed ? – rolling.stones Oct 06 '12 at 12:52
  • Also if i edit the init.rc... does it get rolled back to original ? how can i manage that ? – rolling.stones Oct 06 '12 at 12:53
  • If you prepare a custom ROM, you are free to modify **/init.rc**; otherwise if the device is rooted, you can remount **/** as r/w. But even then the ROM can restore it from a secure backup. AFAIK this happens on Samsung Galaxy family. – Alex Cohn Oct 06 '12 at 15:48
  • 1
    init.rc is part of ramdisk and not system partition. So at bootup, the init.rc picked up will be from ramdisk. So whatever changes you do to init.rc in system partition will not get reflected. Do check this [post](http://stackoverflow.com/questions/9768103/make-persistent-changes-to-init-rc) – nandeesh Oct 06 '12 at 18:05
1

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

Moaaz Ali
  • 93
  • 15
EyalBellisha
  • 1,874
  • 19
  • 28