I am trying to execute a daemon on boot of my Nexus 5. This is a daemon built from source in c++
. But whenever I build AOSP and flash the images on my Nexus 5 device, the daemon is not running in the background. I added this code to my init.rc file: (which should make it run in the background on boot)
setenforce 0
service my_daemon /system/bin/my_daemon
class main # Also tried: class core (but it didn't make a difference)
user root
group root
setenforce 1
The reason I use setenfonce is because of SELinux on Android 5.0 and above. The problem is that on boot, the daemon is not running on boot. I don't have any clue as to why. Any suggestions?
It is a program to initialize the elements of the Android system. Unlike Linux, Android uses its own initialization program. This Android init program processes 2 files, and it executes the commands it finds in both programs.
rc file, located in the /etc/init/ directory of the partition where they reside. There is a build system macro, LOCAL_INIT_RC, that handles this for developers. Each init . rc file should additionally contain any actions associated with its service.
It is the last step of the kernel boot sequence. /etc/inittab Specifies the init command control file. init script initializes the service. So, it responsible for initializing the system. Init scripts are also called rc scripts (run command scripts)
I got the same issue with nexus 9. I added code to device/htc/flounder/init.flounder.rc but doesnt work.
service pollingclient /system/bin/sh logwrapper
class late_start
user root
group root
oneshot
on property:dev.bootcomplete=1
start pollingclient
My quick fix is added code to start my daemon in system/core/adb/adb_auth_client.c after fdevent_add(&t->auth_fde, FDE_READ);
kill_if_exist_service("mydaemon");
system("sleep 5; mydaemon");
It works but its some kind of "quick fix". I am still investigating right solution.
update: I disable selinux by edit ./arch/arm64/configs/flounder_defconfig set CONFIG_SECURITY_SELINUX=n then recompile kernel and recompile boot.img. Wow, it works!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With