1,在init.qcom.rc中
service jj /system/bin/jj.sh
class main
user root
group root
oneshot
//------------------------一般在device下----------------------------
2,在file_contexts中
/system/bin/jj.sh u:object_r:jj_exec:s0
3,在jj.te中
type jj, domain; //domain表明是在进程中
type jj_exec,exec_type, file_type; //声明类型
permissive jj; //去掉selinux保护---很重要
init_daemon_domain(jj) //无分号;
allow jj jj_exec:file {execute read open execute_no_trans};
allow jj shell_exec:file { read };
allow jj system_file:file { execute_no_trans };
PS:补充:
tcontext:system_file
tclass:file
4,在/system/bin/jj.sh
#!/system/bin/sh
echo "jj here"
echo "just test" >> /data/jjtest
insmod /system/lib/modules/gpio_keys.ko
5,在Sepolicy/Android.mk中
增加 jj.te
PS:另外可以增加Product.mk中拷贝 PRODUCT_COPY_FILES += \ 变更bin文件路径