你所不知道的权限-Custom permission issue

本文探讨了在GMS认证测试中遇到的权限问题,涉及代码安全,具体表现为某些权限可能导致恶意第三方应用执行组件逻辑。问题起源于Lolipop系统后不允许重复定义自定义权限。解决方案是利用Android Framework来避免此类问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题来源:手机厂商在进行GMS认证测试时测试出的问题,比如如下代码会产生权限安全问题

<receiver
    android:name=".wxapi.WXRegister"
    android:permission="com.tencent.mm.plugin.permission.SEND" >
    <intent-filter>
        <action android:name="com.tencent.mm.plugin.openapi.Intent.ACTION_REFRESH_WXAPP" />
    </intent-filter>
</receiver>

com.sohu.newsclient.wxapi.WXRegister (com.tencent.mm.plugin.permission.SEND)

问题分析:

      1.任何具有com.tencent.mm.plugin.permission.SEND权限的代码可能会执行你组件(如BroadCastReceiver)中的逻辑。

      2.如果第三方危害性的应用首先安装已经注册了这com.tencent.mm.plugin.permission.SEND权限


,并且设置android:protectionLevel="signature",那咱们的应用就会应为签名不同而无法安装,如
<uses-permission android:name="com.master.me.CUSTOM_PERMISSION_TEST"    android:protectionLevel="signature"/>

问题根源:At the beginning Lolipop OS, Basically, Duplicated custom permission definition is not allowed.  (If A App defines Permission P and is installed, B App which defines Permission P can not be installed if A app and B App's signature is different.)


解决方法:

1.利用Android FrameWork来规避此问题

manifest>
...
    <activity
        android:name=".InternalActivity"
        android:permission="com.hiqes.sample.frm_enf_perm"
        android:exported="false" >

        <intent-filter>
            <action android:name="com.hiqes.sample.INTERNAL_ACTION1" />
            <category android:name="android.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.hiqes.sample.INTERNAL_ACTION2" />
            <category android:name="android.category.DEFAULT" />
        </intent-filter>
        ...
    </activity>
....
</manifest>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值