Android系统中如何添加权限

Android系统中如何添加权限-----以TP为例

以添加TP权限为例讲解

比如我真正代码文件里有一个节点:

/sys/devices/platform/mtk-tpd/tp_firmware_version

在权限文件中具体对应节点自定义了三个文件名(可以随意起):

touch_firm  -------------》对应节点/sys/devices/platform/mtk-tpd/tp_firmware_version

1、  首先在device\mediatek\common\sepolicy\basic\file.te文件添加自己自定义的文件名,并给予文件类型(在这里定义为“文件类型、系统文件类型”)

type touch_firm,file_type,sysfs_type;

2、  在device\mediatek\common\sepolicy\basic\file_contexts文件中让代码中的节点与自定义文件名关联  [u:object_r表示当前用户 s0表示等级,最低权限等级]

/sys/devices/platform/mtk-tpd/tp_firmware_version u:object_r:touch_firm:s0

3、  在device\mediatek\common\sepolicy\basic\shell.te中加入权限(最重要的一个文件)

allow shell touch_firm:filerx_file_perms;

有些人是按下面方式加的(加两条):

allow shell touch_firm:dir {getattr search open read };

allow shell touch_firm:filer_file_perms;


上面的三条是权限所必须的,以下的文件是选择性的添加的,比如我们知道后续哪个模式下使用该节点或者手机在具体的模式报avc错误,那我们就在对应模式权限文件下面添加如下类似的权限即可:

4、  在device\mediatek\common\sepolicy\basic\radio.te中添加权限(这个我们可以不加,该项好像是Midtest模式下的一些权限,*#87下面)

allow radio sysfs_mtk_tpd_file:file rx_file_perms;

allow radio sysfs_mtk_tpd_file:dir search;

5、  device\mediatek\common\sepolicy\bsp\ueventd.te这个里面是log显示让加的,一般我们不会加的,注意

allow ueventd sysfs_mtk_tpd_file:file w_file_perms;

6、  device\mediatek\common\sepolicy\basic\meta_tst.te这个里面加meta相关权限,比如TPSTester.exe测试时出问题,一般就是这里少权限了。

allow meta_tst sysfs_mtk_tpd_file:file { open read };

allow meta_tst sysfs_mtk_tpd_file:file r_file_perms;

allow meta_tst sysfs_mtk_tpd_file:dir search;

allow meta_tst sysfs_mtk_tpd_file:dir { getattr search openread };

7、device\mediatek\common\sepolicy\bsp\factory.te  如果是Factory出问题一般就在这里添加。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值