2013年9月20日 星期五

Android startup app from init.rc

1. facerecognition.sh
#!/system/bin/sh /system/bin/am start -n com.luxand.facerecognition/com.luxand.facerecognition.MainActivity

2. topeet_6dq.mk
gedit /mnt/ssd/iTOP-iMX6_android4.4.2/device/fsl/imx6/topeet_6dq.mk
#add
PRODUCT_COPY_FILES += \
device/fsl/matrix_io/etc/facerecognition.sh:system/etc/facerecognition.sh

3. If use Android 6.0
gedit /mnt/ssd/imx6_M601_210/myandroid/external/sepolicy/domain.te
#find
neverallow {
  domain
  -init
  -zygote
  -installd
  -dex2oat
  -shell #---> add this
} dalvikcache_data_file:file no_w_file_perms;
###
neverallow {
  domain
  -init
  -installd
  -dex2oat
  -zygote
  -shell #---> add this
} dalvikcache_data_file:dir no_w_dir_perms;

4. facerecognition.te
type facerecognition, domain;
type facerecognition_exec, exec_type, file_type;
init_daemon_domain(facerecognition);

5. shell.te
allow shell dalvikcache_data_file:dir { write add_name remove_name };
allow shell dalvikcache_data_file:file { write create unlink };
allow shell facerecognition_exec:file { read open };

6. file_contexts
/system/etc/facerecognition.sh        ubject_r:facerecognition_exec:s0
                                                       
7. init.rc
gedit /mnt/ssd/iTOP-iMX6_android4.4.2/device/fsl/imx6/etc/init.rc
#add
service facerecognition /system/bin/sh /system/etc/facerecognition.sh
class late_start
seclabel u:r:shell:s0
disabled
oneshot

on property:dev.bootcomplete=1
     start facerecognition

8. init.rc (another simple way no need .te, file_contexts)
on property:dev.bootcomplete=1
     exec u:r:shell:s0 shell shell input log adb sdcard_rw net_bt_admin net_bt inet net_bw_stats -- /system/bin/sh /system/bin/am start -n com.luxand.facerecognition/com.luxand.facerecognition.MainActivity

沒有留言:

張貼留言