• 文件开放权限


    转载:https://www.jianshu.com/p/058970ae46fd

    SEAndroid 为Sys设备节点开放访问(读或写)权限方法(如:sys/class/leds/red_aux/brightness)

    1.APP层写节点之前,必须确保当前应用程序能够有权限去读写

    否则是无法正常写入的,如果应用没有权限写设备节点,首先进入源码目录中system/core/rootdir/init.rc;
    修改内容如下:

           //开放节点让系统进程可以访问
         chown system system /sys/class/leds/red_aux/brightness
           //修改设备节点可读可写
         chmod 0666 /sys/class/leds/red_aux/brightness
    

    2.修改file.te

    进入/device/XXX/sepolicy/common
    找到file.te文件,加入以下的类型声明:
    定义selinux type

    # leds file
    type sysfs_ledred_leds, fs_type, sysfs_type;
    

    3.修改file_contexts

    进入/device/XXX/sepolicy/common
    找到修改file_contexts文件
    绑定sysfs_ledred_leds到对应的实际节点,加入以下声明:

    /sys/devices/soc/75b5000.i2c/i2c-7/7-0045/leds/red_aux/brightness u:object_r:sysfs_ledred_leds:s0
    

    4.修改sysetem_app.te文件

    找到修改sysetem_app.te文件
    加入以下权限声明:

    allow system_app sysfs_ledred_leds:file rw_file_perms;
    

    //rw_file_perms代表读写权限,该话的意思事允许system_app进程能够拥有对sysfs_ledred_leds的这个字符设备的读写权限;如果system_server 则表示是system_server进程

    allow system_app sysfs_ledred_leds:file { create open read setattr write };
    

    注意:以上的sysfs_ledred_leds必须与file.te文件中声明的文件类型、名称必须一致。

    5.APP

    APP 配置为系统APP
    在AndroidMainefest.xml中配置
    android:sharedUserId=”android.uid.system”;

    write_init("/sys/class/leds/red_aux/brightness", 255);
    

    6.kernel 中sysfs 读写权限

    S_IWUGO 全部用户读写

    S_IWUSR 用户读写

  • 相关阅读:
    CAS在tomcat6.0.18下的SSO
    CAS在tomcat6.0.18下的SSO
    PL/SQL 0.几秒出结果,SQL效率一定高吗?
    优化大型复杂SQL
    C++ ProtoBuf小结
    protobuf c++入门
    Oracle_inner join,left join,right join,full join 的区别,用例子说明
    Linux_查看修改SWAP大小
    Oracle 优化器
    Oracle 行转列两种方法
  • 原文地址:https://www.cnblogs.com/hellokitty2/p/13325051.html
Copyright © 2020-2023  润新知