Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android init.rc trigger on service-exited

I was able to start my own services from the init script (init.rc) in Android, following the guides found at: http://www.androidenea.com/2009/08/init-process-and-initrc.html or with the official documentation found at https://android.googlesource.com/platform/system/core/+/froyo-release/init/readme.txt

There is a trigger called "on service-exit-<name>" where name is the name of the service which has to exit before the actions of this trigger are executed. However, this trigger does not seem to work. I started a small shell script as a service and created the trigger accordingly to start all remaining services afterwards. The init process seems to be stuck after the execution of my script and does not continue with the remaining services.

The final goal would be to achieve something like a controlled or 'staged' boot process, where I can make sure that this script is executed first and then the remainnig services are started. I also tried to accomplish that with using different service classes but failed

Any help on that subject is appreciated.

like image 683
user634010 Avatar asked Apr 27 '26 17:04

user634010


1 Answers

reading the sources i found that init sets a property (init.svc.<name>) to "stopped" when a service exits. this means you can use property triggers to achieve what service-exit-<name> is supposed to do:

service 2nd_svc /system/bin/2nd_svc
    oneshot
    disabled

on property:init.svc.1st_svc=stopped
    start 2nd_svc
like image 144
Matthias Kaehlcke Avatar answered Apr 29 '26 07:04

Matthias Kaehlcke