1、修改init.project.rc增加文件权限和自定义服务
a、打开device/XXX/产品/init.project.rc文件,在on post-fs-data这个动作下面增加(注意前要加四个空格)
chmod 0755 /system/bin/hellotest
b、在文件内很多service的位置附近增加服务
service hellotest /system/bin/hellotest
class main
user root
group root
c、有些服务只需要启动一次,可以在自定义服务的下面增加oneshot选项。
d、如有些服务需要条件启动,可以在自定义服务的下面增加disabled选项,再配合某个属性来启动如下。
on property:sys.service.hellotest=enabled
start hellotest
2、增加selinux权限
a、打开device/XXX/产品/sepolicy/file_contexts新增下面这一行
/system/bin/hellotest u:object_r:hellotest_exec:s0
b、新增一个device/XXX/产品/sepolicy/hellotest.te文件
文件的内容是:
type hellotest, domain;<