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

写了一个简单的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;

你可能感兴趣的:(android 7.1 服务进程 open串口设备失败)