Android 5.0升级后,SELinux模式已经升级为Enforcing, 并且是everything Enforcing, 不像Android 4.4时只是几个主要process为Enforcing,其余仍是permissive.android
直接举例: 好比要生成一个10MB大小的EXT4 格式helloworld.img 对里面的内容打上u:object_r:hello_world_t:s0的 label 首先在out 目录下建立helloworld 文件夹 make_ext4fs -l 10485760 -S out/root/file_contexts -a helloworld out/helloworld.img out/helloworld
参数-S 用来指定file_contexts文件路径,它会指定打什么标签,重要 -a 参数用来指定文件系统在android里的挂载点,能够使用默认的owner group等,在android_filesystem_config.h里指定 此路径会在-S指定的file_contexts里用到,因此-a 必须是helloworldapp
file_contexts:
/helloworld(/.*)? u:object_r:hello_world_t:s0ci
接下来天然要加label 许可。 首先弄清楚访问/helloworld的app是何种app, 好比system app, 那么要在system_app.te 来增长对应的许可。 固然前提是已经增长hello_world_t 的定义。object