andriod JNI 访问权限 open总是失败

现象:JNI中open 总是失败,打印信息如下

[  622.188592] type=1400 audit(1718.939:13): avc: denied { read write } for pid=6144 comm="ter.com.control" name="sc20_gpio" dev="tmpfs" ino=9251 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:sc20_gpio_device:s0 tclass=chr_file permissive=0

执行 setenforce 0 ,chmod 777 /dev/sc20_gpio 后打开成功,说明是selinux原因

修改如下:
1.device\qcom\sepolicy\common\untrusted_app.te下添加
type sc20_gpio_device, dev_type,mlstrustedobject;

2.device\qcom\sepolicy\common\untrusted_app.te 下添加
allow untrusted_app sc20_gpio_device:chr_file rw_file_perms;

3.device\qcom\sepolicy\common\file_contexts 下添加
/dev/sc20_gpio u:object_r:sc20_gpio_device:s0

4.device\qcom\common\rootdir\etc\init.qcom.rc 下添加
chmod 0777 /dev/sc20_gpio

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值