由于工厂测试是直接读写取呼吸灯的文件节点,测试app没有selinux权限去读写该节点,需要增加selinux权限。
该工厂测试模块属于system app,所以对应的要加在system_app.te中
MTK FAQ:
https://online.mediatek.com/FAQ#/SW/FAQ11486
https://online.mediatek.com/FAQ#/SW/FAQ13635
一:根据FAQ11486和以下log:
在system_app.te中增加allow system_app sysfs_leds:dir search;
<36>[18068.630431] (1)[334:logd.auditd]type=1400 audit(1548337628.189:14011): avc: denied { search } for pid=19546 comm="pri.factorytest" name="leds" dev="sysfs" ino=9315 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_leds:s0 tclass=dir permissive=0
二:上一步后仍然无法写成功,但log不一样
根据FAQ13635 和以下log做修改
<36>[ 229.420022] (3)[335:logd.auditd]type=1400 audit(1548397141.547:3543): avc: denied { write } for pid=4583 comm="pri.factorytest" name="brightness" dev="sysfs" ino=13673 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_leds:s0 tclass=file permissive=0
修改:
device/mediatek/sepolicy/basic/non_plat/system_app.te:
allow system_app sysfs_leds:dir search;
allow system_app sys_lcd_brightness_file:file {rw_file_perms open};
device/mediatek/sepolicy/basic/non_plat//basic/non_plat/file.te:
type sys_lcd_brightness_file, fs_type, sysfs_type;
device/mediatek/sepolicy/basic/non_plat//basic/non_plat/file_contexts:
/sys/devices/platform/leds-mt65xx/leds/green/brightness u:object_r:sys_lcd_brightness_file:s0
注意:该文件节点必须为真实节点,不能是连接
三、增加普通权限
在对应device/mediatek/mt6xxx/init.mt6xxx.rc
chmod 0664 /sys/class/leds/green/brightness
此处只已绿灯为例,红、黄灯也是一样处理
参考:https://blog.youkuaiyun.com/long375577908/article/details/79384527