在默认的selinux规则中, 非系统APP无权访问很多类型的字符设备.         
下面以访问串行设备为例
确认android / platform / external / sepolicy / file_contexts 文件是否添加对应节点 串行设备的节点, android 原生系统已经声明, 不用另外添加, 如果是其他没有声明的设备, 可以自行添加.  /dev/ttyS[0-9]* u:object_r:serial_device:s0



修改 android/external/sepolicy/ device.te。

diff --git a/device.te b/device.te
--- a/device.te
+++ b/device.te
@@ -33,7 +33,7 @@ type kmsg_device, dev_type;
 type null_device, dev_type, mlstrustedobject;
 type random_device, dev_type, mlstrustedobject;
 type sensors_device, dev_type;
-type serial_device, dev_type;
+type serial_device, dev_type, mlstrustedobject;

 type socket_device, dev_type;
 type owntty_device, dev_type, mlstrustedobject;
 type tty_device, dev_type;





diff --git a/sepolicy/untrusted_app.te b/sepolicy/untrusted_app.te
--- a/sepolicy/untrusted_app.te
+++ b/sepolicy/untrusted_app.te
@@ -16,3 +16,4 @@ allow system_server media_rw_data_file:dir relabelfrom;
 allow untrusted_app domain:dir { getattr search };
 allow untrusted_app domain:file { read getattr open };
 allow untrusted_app domain:lnk_file read;
+allow untrusted_app serial_device:chr_file rw_file_perms;

更多相关文章

  1. Android(安卓)查看SharedPreferences中的数据
  2. 【Android(安卓)Developers Training】 51. 序言:打印内容
  3. android 布局 px or dip
  4. adb devices List of devices attached 为空
  5. 如何在Android(安卓)Studio和eclipse中查看File Explorer视图(设
  6. Android(安卓)上层应用读写设备节点
  7. 深入理解Android音频框架AudioTrack到AudioFlinger及Mix过程
  8. AndroidManifest.xml文件剖析
  9. Android操作framebuffer

随机推荐

  1. 【阿里云镜像】配置阿里云RepoForge 镜像
  2. 【阿里云镜像】使用阿里云oVirt镜像部署o
  3. 【阿里云镜像】安装编译Apache环境
  4. 【阿里云镜像】下载安装KaOS镜像
  5. 表单提交与内联框架及列表集(内置课程表及
  6. 用table做课程表、用表单做注册界面
  7. 盘点|2021年最受欢迎Linux桌面操作系统前
  8. Android中WebView的简单使用
  9. Android(安卓)读取已知包名的uses-permis
  10. android绘制图标