获得读写sys/class/的权限

System.err: java.io.FileNotFoundException: /sys/class/i2c-dev/i2c-3/device/3-0038/glove_mode (Permission denied)
01-23 09:36:01.633 18238 18238 W System.err:     at java.io.FileOutputStream.open0(Native Method)
01-23 09:36:01.633 18238 18238 W System.err:     at java.io.FileOutputStream.open(FileOutputStream.java:287)

adb shell dmesg

[21646.053069] lovdream_enable_spk_ext_pa: Enable external speaker PA
[21647.340394] ft5x06 +++glove mode = 0x0
[21648.693471] type=1400 audit(1516710267.889:160): avc: denied { search } for pid=23090 comm="Worker-1" name="zram0" dev="sysfs" ino=27690 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:sysfs_zram:s0 tclass=dir permissive=0
[21648.693541] type=1400 audit(1516710980.399:161): avc: denied { write } for pid=23059 comm="ndroid.settings" name="glove_mode" dev="sysfs" ino=28788 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0


没有写权限需要驱动改


diff --git a/system/sepolicy/private/app.te b/system/sepolicy/private/app.te
index 6f2b820..5e4ba51 100755
--- a/system/sepolicy/private/app.te
+++ b/system/sepolicy/private/app.te
@@ -473,9 +473,8 @@ neverallow { appdomain -shell } efs_file:dir_file_class_set read;
 # Write to various pseudo file systems.
 neverallow { appdomain -bluetooth -nfc }
     sysfs:dir_file_class_set write;
-neverallow appdomain
-    proc:dir_file_class_set write;
 
+neverallow { appdomain -system_app} proc:dir_file_class_set write;
 # Access to syslog(2) or /proc/kmsg.
 neverallow appdomain kernel:system { syslog_read syslog_mod syslog_console };
 
diff --git a/system/sepolicy/private/system_app.te b/system/sepolicy/private/system_app.te
index 7950044..cc72962 100644
--- a/system/sepolicy/private/system_app.te
+++ b/system/sepolicy/private/system_app.te
@@ -77,7 +77,7 @@ allow system_app keystore:keystore_key {
     clear_uid
     user_changed
 };
-
+allow system_app proc:file write;
 # /sys access
 r_dir_file(system_app, sysfs_type)


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值