android 7.1 服务进程 open串口设备失败

来源:互联网 发布:素颜美女知乎 编辑:程序博客网 时间:2024/06/12 23:13

写了一个简单的helloworld程序作为一个服务,运行后出现各种avc权限问题,如open(/dev/tty*)设备返回-1,log如下:

01-01 11:47:51.200  1714  1714 W helloworld: type=1400 audit(0.0:96): avc: denie
d { read write } for name="ttyVCOM0" dev="tmpfs" ino=3390 scontext=u:r:helloworl
d:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=0


解决办法:

在helloworld.te中添加

allow helloworld device:chr_file rw_file_perms;

原创粉丝点击