Android P添加自定义property

参考:https://blog.csdn.net/ch853199769/article/details/82501078

在Android P系统应用中使用SystemProperties.set时出现错误提示:

init: Unable to set property 'android.nav_status' to 'show' from uid:10021 gid:10021 pid:17383: SELinux permission check failed

selinux: avc:  denied  { set } for property=android.nav_status pid=17429 uid=10021 gid=10021 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:system_prop:s0 tclass=property_service permissive=0

这个问题是因为Google在Android O以后,为了降低vendor和system之间的耦合度,对property的作用区域也做了明确的区分。

那么要添加自定义的property怎么添加呢?

1.

/system/sepolicy/private/property_contexts

/system/sepolicy/prebuilts/api/28.0/private/property_contexts
在这两个文件内添加property定义

android.                     u:object_r:system_prop:s0

2.

/system/sepolicy/private/platform_app.te
/system/sepolicy/prebuilts/api/28.0/private/platform_app.te

这两个文件中设置property权限,按照规则allow scontex tcontex:tclass action

allow platform_app system_prop:property_service set;

重新编译后即可解决。
 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值