Boot my own service as the first one.

116 views
Skip to first unread message

dywis...@gmail.com

unread,
Jun 12, 2013, 11:52:19 PM6/12/13
to android...@googlegroups.com
I want to boot my own service right after all ".img" file were mounted and before any other service was going to boot.

dywis...@gmail.com

unread,
Jun 12, 2013, 11:53:43 PM6/12/13
to android...@googlegroups.com
Any suggestions would be greatly appreciated.

Pratik Prajapati

unread,
Jun 13, 2013, 1:05:23 AM6/13/13
to android...@googlegroups.com
As far as i know you can not start your java service on first of all other services. Technically you can start it from init.rc but you can not get any other system service object in your service. you can not even get system context, nothing will work, your service will crash. But if you want to run some native code you can do it. look into init.rc where vold starts.


--
Regards,
Pratik


--
--
unsubscribe: android-kerne...@googlegroups.com
website: http://groups.google.com/group/android-kernel
---
You received this message because you are subscribed to the Google Groups "Android Linux Kernel Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-kerne...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

董钰

unread,
Jun 13, 2013, 2:34:16 AM6/13/13
to android...@googlegroups.com
Thank you for reply. My service is written in native c ,and I've already can boot my service through adding code in init.rc. But I can't make it the first service to boot.


2013/6/13 Pratik Prajapati <pratik.p...@gmail.com>
You received this message because you are subscribed to a topic in the Google Groups "Android Linux Kernel Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-kernel/obskHZkaKBI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to android-kerne...@googlegroups.com.

biAji

unread,
Jun 13, 2013, 10:03:41 AM6/13/13
to android...@googlegroups.com
maybe modify init.c and add your service in front of all others
biAji

Durgadoss Ramanathan

unread,
Jun 13, 2013, 12:48:23 PM6/13/13
to android...@googlegroups.com
You can try adding your service in init.rc inside system/core/rootdir/ in the early-init section.
May be you can try adding it before 'start ueventd'.

Regards
Durgadoss

Pratik Prajapati

unread,
Jun 13, 2013, 3:23:07 PM6/13/13
to android...@googlegroups.com
You might need to start your service "on boot" 
--
Regards,
Pratik

董钰

unread,
Jun 13, 2013, 10:30:10 PM6/13/13
to android...@googlegroups.com
Thanks everybody,
What I did just now is adding a new "on" section like this:

on myservice
     class_start myservice

service myservice /system/bin/myservice
    class myservice
    user root 
    group root
    oneshot

and adding a line in init.c like:

    action_for_each_trigger("myservice", action_add_queue_tail);

before the similar line starting "early_boot".

In this way, among so many system boot, sometimes myservice can boot firstly, sometimes can't.

I've tried to add a "class_start myservice" or "start myservice" in "on boot" before "class_start core" and "class_start main", but it worked not so well. It booted firstly only few times.

And I used to copy the code of myservice into init.c, the compilation works fine. but the android system can't boot. I debuged it and found that the fopen and fgets result in the boot failure.

So is there any way to make sure that myservice is booted right before other services every time?



2013/6/14 Pratik Prajapati <pratik.p...@gmail.com>

Steve Jones

unread,
Jun 14, 2013, 1:43:22 AM6/14/13
to android...@googlegroups.com
Hi there,

If you want your service to boot first then as already mentioned you put it before ueventd in the on early-init section, although that probably not a good idea if you service relies on anything in /dev . you would also need to build a statically linked version and include it in your bootimage /sbin directory so you can access it before system is mounted.




Reply all
Reply to author
Forward
0 new messages