Issue
I have seen a few very old posts, like How to launch a native server application (ELF) on a rooted Android at/after boot? with this answer: https://stackoverflow.com/a/9920463/ and this questions Android daemon process which both touch on my issue but not really give an answer what I need to do. Also since there are only a few questions on this topic either this is so obviously simple that there is no need to ask a question or I'm not searching with the correct terminology
I have a natively built application which I run as root on an Android(AOSP) development board.
Starting this program from the console works fine but I would like it to start automatically in the background on boot-up.
- What would be a simple way of starting my process in the background at startup?
- What is be the currently recommended way of doing it?
Solution
This is how I solved this problem. My tool builds in the aosp tree.
- added a file
mytool.rcthis file is pushed to/etc/init
on boot
start myservice
service myservice /bin/mytool
user root
seclabel u:r:su:s0
disabled
- added rc-file to
Android.bp
cc_binary {
name: "mytool",
init_rc: ["mytool.rc"],
defaults: ["mytool_defaults"],
srcs: [
"mytool.cpp",
],
}
- Temporary set SELinux to permissive mode by running shell command
setenforce 0 - service is started with shell command
start mytool
Answered By - Simson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.